mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-01 19:18:05 +00:00
Co-authored-by: Mayur SIngal <mayursingal@Mayurs-MacBook-Pro.local>
This commit is contained in:
parent
db72447b95
commit
b4ebf5ce87
@ -19,7 +19,11 @@ from sqlalchemy_vertica.base import VerticaDialect
|
||||
from metadata.ingestion.ometa.openmetadata_rest import MetadataServerConfig
|
||||
from metadata.ingestion.source.sql_source import SQLSource
|
||||
from metadata.ingestion.source.sql_source_common import SQLConnectionConfig
|
||||
from metadata.utils.sql_queries import VERTICA_GET_COLUMNS, VERTICA_GET_PRIMARY_KEYS
|
||||
from metadata.utils.sql_queries import (
|
||||
VERTICA_GET_COLUMNS,
|
||||
VERTICA_GET_PRIMARY_KEYS,
|
||||
VERTICA_VIEW_DEFINITION,
|
||||
)
|
||||
|
||||
|
||||
@reflection.cache
|
||||
@ -168,8 +172,33 @@ def _get_column_info(
|
||||
return column_info
|
||||
|
||||
|
||||
@reflection.cache
|
||||
def get_view_definition(self, connection, view_name, schema=None, **kw):
|
||||
if schema is not None:
|
||||
schema_condition = "lower(table_schema) = '%(schema)s'" % {
|
||||
"schema": schema.lower()
|
||||
}
|
||||
else:
|
||||
schema_condition = "1"
|
||||
|
||||
s = sql.text(
|
||||
dedent(
|
||||
VERTICA_VIEW_DEFINITION.format(
|
||||
view_name=view_name.lower(), schema_condition=schema_condition
|
||||
)
|
||||
)
|
||||
)
|
||||
rows = [row for row in connection.execute(s)]
|
||||
if len(rows) >= 1:
|
||||
return rows[0][0]
|
||||
return None
|
||||
|
||||
|
||||
VerticaDialect.get_columns = get_columns # pylint: disable=protected-access
|
||||
VerticaDialect._get_column_info = _get_column_info # pylint: disable=protected-access
|
||||
VerticaDialect.get_view_definition = (
|
||||
get_view_definition # pylint: disable=protected-access
|
||||
)
|
||||
|
||||
|
||||
class VerticaConfig(SQLConnectionConfig):
|
||||
|
||||
@ -262,3 +262,10 @@ VERTICA_GET_PRIMARY_KEYS = """
|
||||
AND constraint_type = 'p'
|
||||
AND {schema_condition}
|
||||
"""
|
||||
|
||||
VERTICA_VIEW_DEFINITION = """
|
||||
SELECT VIEW_DEFINITION
|
||||
FROM V_CATALOG.VIEWS
|
||||
WHERE table_name='{view_name}'
|
||||
AND {schema_condition}
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user