Fix #12106 - Fix looker chart sourceUrl & Array datatype handling (#12113)

* Fix looker chart url

* Handle array datatype

* Handle array datatype
This commit is contained in:
Pere Miquel Brull 2023-06-25 17:18:36 +02:00 committed by GitHub
parent 67ffa1cce3
commit 97e08ee25c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -96,11 +96,14 @@ def get_columns_from_model(
columns = [] columns = []
all_fields = (model.fields.dimensions or []) + (model.fields.measures or []) all_fields = (model.fields.dimensions or []) + (model.fields.measures or [])
for field in cast(Sequence[LookmlModelExploreField], all_fields): for field in cast(Sequence[LookmlModelExploreField], all_fields):
type_ = LOOKER_TYPE_MAP.get(field.type, DataType.UNKNOWN)
columns.append( columns.append(
Column( Column(
name=field.name, name=field.name,
displayName=getattr(field, "label_short", field.label), displayName=getattr(field, "label_short", field.label),
dataType=LOOKER_TYPE_MAP.get(field.type, DataType.UNKNOWN), dataType=type_,
# We cannot get the inner type from the sdk of .lkml
arrayDataType=DataType.UNKNOWN if type_ == DataType.ARRAY else None,
dataTypeDisplay=field.type, dataTypeDisplay=field.type,
description=field.description, description=field.description,
) )

View File

@ -724,7 +724,9 @@ class LookerSource(DashboardServiceSource):
displayName=chart.title or chart.id, displayName=chart.title or chart.id,
description=self.build_chart_description(chart) or None, description=self.build_chart_description(chart) or None,
chartType=get_standard_chart_type(chart.type).value, chartType=get_standard_chart_type(chart.type).value,
sourceUrl=f"{clean_uri(self.service_connection.hostPort)}/dashboard_elements/{chart.id}", sourceUrl=chart.query.share_url
if chart.query is not None
else f"{clean_uri(self.service_connection.hostPort)}/merge?mid={chart.merge_result_id}",
service=self.context.dashboard_service.fullyQualifiedName.__root__, service=self.context.dashboard_service.fullyQualifiedName.__root__,
) )
self.status.scanned(chart.id) self.status.scanned(chart.id)

View File

@ -100,7 +100,9 @@ MOCK_DASHBOARD_ELEMENTS = [
body_text="Some body text", body_text="Some body text",
note_text="Some note", note_text="Some note",
type="line", type="line",
query=Query(model="model", view="view"), query=Query(
model="model", view="view", share_url="https://my-looker.com/hello"
),
) )
] ]
@ -365,7 +367,7 @@ class LookerUnitTest(TestCase):
displayName="chart_title1", displayName="chart_title1",
description="subtitle; Some body text; Some note", description="subtitle; Some body text; Some note",
chartType=ChartType.Line, chartType=ChartType.Line,
sourceUrl="https://my-looker.com/dashboard_elements/chart_id1", sourceUrl="https://my-looker.com/hello",
service=self.looker.context.dashboard_service.fullyQualifiedName.__root__, service=self.looker.context.dashboard_service.fullyQualifiedName.__root__,
) )