Fix #16370 - Added view/DDL definition rule (#16486)

* added rule includeDDL

* code optimize

* review changes
This commit is contained in:
Suman Maharana 2024-06-05 11:11:04 +05:30 committed by GitHub
parent b87956cbf0
commit cdca199ec8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 20 deletions

View File

@ -630,7 +630,7 @@ class BigquerySource(
self.connection, table_name, schema_name self.connection, table_name, schema_name
) )
schema_definition = ( schema_definition = (
str(schema_definition.strip()) str(schema_definition).strip()
if schema_definition is not None if schema_definition is not None
else None else None
) )

View File

@ -156,16 +156,19 @@ class ClickhouseSource(CommonDbSourceService):
if table_type in {TableType.View, TableType.MaterializedView}: if table_type in {TableType.View, TableType.MaterializedView}:
definition_fn = inspector.get_view_definition definition_fn = inspector.get_view_definition
schema_definition = definition_fn(table_name, schema_name) schema_definition = definition_fn(table_name, schema_name)
else: return (
schema_definition = inspector.get_table_ddl( str(schema_definition).strip()
self.connection, table_name, schema_name if schema_definition is not None
else None
) )
schema_definition = ( schema_definition = inspector.get_table_ddl(
str(schema_definition.strip()) self.connection, table_name, schema_name
)
return (
str(schema_definition).strip()
if schema_definition is not None if schema_definition is not None
else None else None
) )
return schema_definition
except NotImplementedError: except NotImplementedError:
logger.warning("Schema definition not implemented") logger.warning("Schema definition not implemented")

View File

@ -458,12 +458,17 @@ class CommonDbSourceService(
inspector=self.inspector, inspector=self.inspector,
) )
schema_definition = self.get_schema_definition( schema_definition = (
table_type=table_type, self.get_schema_definition(
table_name=table_name, table_type=table_type,
schema_name=schema_name, table_name=table_name,
inspector=self.inspector, schema_name=schema_name,
inspector=self.inspector,
)
if self.source_config.includeDDL
else None
) )
table_constraints = self.update_table_constraints( table_constraints = self.update_table_constraints(
table_constraints, foreign_columns table_constraints, foreign_columns
) )

View File

@ -154,20 +154,23 @@ class OracleSource(StoredProcedureMixin, CommonDbSourceService):
schema_definition = inspector.get_table_ddl( schema_definition = inspector.get_table_ddl(
self.connection, table_name, schema_name self.connection, table_name, schema_name
) )
return (
str(schema_definition).strip()
if schema_definition is not None
else None
)
else: definition_fn = inspector.get_view_definition
definition_fn = inspector.get_view_definition if table_type == TableType.MaterializedView:
if table_type == TableType.MaterializedView: definition_fn = inspector.get_mview_definition
definition_fn = inspector.get_mview_definition
schema_definition = definition_fn(table_name, schema_name) schema_definition = definition_fn(table_name, schema_name)
schema_definition = ( return (
str(schema_definition.strip()) str(schema_definition).strip()
if schema_definition is not None if schema_definition is not None
else None else None
) )
return schema_definition
except NotImplementedError: except NotImplementedError:
logger.warning("Schema definition not implemented") logger.warning("Schema definition not implemented")