diff --git a/metadata-ingestion/src/datahub/ingestion/source/dbt/dbt_common.py b/metadata-ingestion/src/datahub/ingestion/source/dbt/dbt_common.py index 21e4b0b5d7..ae5cb135c0 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/dbt/dbt_common.py +++ b/metadata-ingestion/src/datahub/ingestion/source/dbt/dbt_common.py @@ -699,23 +699,27 @@ def get_upstreams_for_test( def make_mapping_upstream_lineage( - upstream_urn: str, downstream_urn: str, node: DBTNode + upstream_urn: str, + downstream_urn: str, + node: DBTNode, + convert_column_urns_to_lowercase: bool, ) -> UpstreamLineageClass: - cll = None - if node.columns: - cll = [ + cll = [] + for column in node.columns or []: + field_name = column.name + if convert_column_urns_to_lowercase: + field_name = field_name.lower() + + cll.append( FineGrainedLineage( upstreamType=FineGrainedLineageUpstreamType.FIELD_SET, - upstreams=[ - mce_builder.make_schema_field_urn(upstream_urn, column.name) - ], + upstreams=[mce_builder.make_schema_field_urn(upstream_urn, field_name)], downstreamType=FineGrainedLineageDownstreamType.FIELD, downstreams=[ - mce_builder.make_schema_field_urn(downstream_urn, column.name) + mce_builder.make_schema_field_urn(downstream_urn, field_name) ], ) - for column in node.columns - ] + ) return UpstreamLineageClass( upstreams=[ @@ -727,7 +731,7 @@ def make_mapping_upstream_lineage( ), ) ], - fineGrainedLineages=cll, + fineGrainedLineages=cll or None, ) @@ -1255,6 +1259,7 @@ class DBTSourceBase(StatefulIngestionSourceBase): upstream_urn=upstream_dbt_urn, downstream_urn=node_datahub_urn, node=node, + convert_column_urns_to_lowercase=self.config.convert_column_urns_to_lowercase, ) if self.config.incremental_lineage: # We only generate incremental lineage for non-dbt nodes. @@ -1601,6 +1606,7 @@ class DBTSourceBase(StatefulIngestionSourceBase): ), downstream_urn=node_urn, node=node, + convert_column_urns_to_lowercase=self.config.convert_column_urns_to_lowercase, ) else: upstream_urns = get_upstreams(