Skip to content

Commit

Permalink
fix(ingestion/looker): column name missing in explore (#10892)
Browse files Browse the repository at this point in the history
  • Loading branch information
sid-acryl authored and yoonhyejin committed Jul 16, 2024
1 parent f6cd95f commit beae5a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,26 +347,20 @@ def _form_field_name(
model_name: str,
upstream_views_file_path: Dict[str, Optional[str]],
config: LookerCommonConfig,
remove_variant: bool = False,
) -> Optional[ColumnRef]:
assert self.field.name is not None

if len(self.field.name.split(".")) != 2:
return None # Inconsistent info received

assert self.explore.name

view_name: Optional[str] = (
self.explore.name
if self.field.original_view is not None
else self.field.original_view
)
view_name: Optional[str] = self.explore.name
if self.field.original_view is not None:
view_name = self.field.original_view

field_name = self.field.name.split(".")[1]

if (
self.field.field_group_variant is not None
and self.field.field_group_variant.lower() in field_name.lower()
):
if remove_variant and self.field.field_group_variant is not None:
# remove variant at the end. +1 for "_"
field_name = field_name[
: -(len(self.field.field_group_variant.lower()) + 1)
Expand All @@ -381,7 +375,7 @@ def _form_field_name(

file_path: Optional[str] = (
upstream_views_file_path.get(view_name)
if upstream_views_file_path.get(view_name) is not None
if upstream_views_file_path.get(view_name)
else ViewFieldValue.NOT_AVAILABLE.value
)

Expand Down Expand Up @@ -413,7 +407,7 @@ def upstream(
) -> Optional[ColumnRef]:
assert self.field.name is not None

if self.field.dimension_group is None: # It is not part of Dimensional Group
if self.field.dimension_group is None or self.field.field_group_variant is None:
return self._form_field_name(
view_project_map,
explore_project_name,
Expand All @@ -422,15 +416,6 @@ def upstream(
config,
)

if self.field.field_group_variant is None:
return self._form_field_name(
view_project_map,
explore_project_name,
model_name,
upstream_views_file_path,
config,
) # Variant i.e. Month, Day, Year ... is not available

if self.field.type is None or not self.field.type.startswith("date_"):
return self._form_field_name(
view_project_map,
Expand All @@ -456,6 +441,7 @@ def upstream(
model_name,
upstream_views_file_path,
config,
remove_variant=True,
)


Expand Down Expand Up @@ -999,12 +985,15 @@ def from_api( # noqa: C901

view_fields: List[ViewField] = []
field_name_vs_raw_explore_field: Dict = {}

if explore.fields is not None:

if explore.fields.dimensions is not None:
for dim_field in explore.fields.dimensions:
if dim_field.name is None:
continue
else:

field_name_vs_raw_explore_field[dim_field.name] = dim_field

view_fields.append(
Expand Down Expand Up @@ -1045,6 +1034,7 @@ def from_api( # noqa: C901
if measure_field.name is None:
continue
else:

field_name_vs_raw_explore_field[
measure_field.name
] = measure_field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class LookMLSourceConfig(
AllowDenyPattern.allow_all(),
description="List of regex patterns for LookML views to include in the extraction.",
)
parse_table_names_from_sql: bool = Field(False, description="See note below.")
parse_table_names_from_sql: bool = Field(True, description="See note below.")
sql_parser: str = Field(
"datahub.utilities.sql_parser.DefaultSQLParser", description="See note below."
)
Expand Down

0 comments on commit beae5a4

Please sign in to comment.