Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ingestion/looker): column name missing in explore #10892

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading