mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-13 18:04:55 +00:00
fix(ingest/looker): update for Looker query API breaking change (#9865)
This commit is contained in:
parent
ae1806fefa
commit
cda34b50fc
@ -17,6 +17,7 @@ from looker_sdk.sdk.api40.models import (
|
|||||||
Look,
|
Look,
|
||||||
LookmlModel,
|
LookmlModel,
|
||||||
LookmlModelExplore,
|
LookmlModelExplore,
|
||||||
|
LookWithQuery,
|
||||||
Query,
|
Query,
|
||||||
User,
|
User,
|
||||||
WriteQuery,
|
WriteQuery,
|
||||||
@ -64,6 +65,7 @@ class LookerAPIStats(BaseModel):
|
|||||||
all_looks_calls: int = 0
|
all_looks_calls: int = 0
|
||||||
all_models_calls: int = 0
|
all_models_calls: int = 0
|
||||||
get_query_calls: int = 0
|
get_query_calls: int = 0
|
||||||
|
get_look_calls: int = 0
|
||||||
search_looks_calls: int = 0
|
search_looks_calls: int = 0
|
||||||
search_dashboards_calls: int = 0
|
search_dashboards_calls: int = 0
|
||||||
|
|
||||||
@ -255,6 +257,14 @@ class LookerAPI:
|
|||||||
transport_options=self.transport_options,
|
transport_options=self.transport_options,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_look(self, look_id: str, fields: Union[str, List[str]]) -> LookWithQuery:
|
||||||
|
self.client_stats.get_look_calls += 1
|
||||||
|
return self.client.look(
|
||||||
|
look_id=look_id,
|
||||||
|
fields=self.__fields_mapper(fields),
|
||||||
|
transport_options=self.transport_options,
|
||||||
|
)
|
||||||
|
|
||||||
def search_dashboards(
|
def search_dashboards(
|
||||||
self, fields: Union[str, List[str]], deleted: str
|
self, fields: Union[str, List[str]], deleted: str
|
||||||
) -> Sequence[Dashboard]:
|
) -> Sequence[Dashboard]:
|
||||||
|
@ -1199,7 +1199,18 @@ class LookerDashboardSource(TestableSource, StatefulIngestionSourceBase):
|
|||||||
logger.info(f"query_id is None for look {look.title}({look.id})")
|
logger.info(f"query_id is None for look {look.title}({look.id})")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
query: Query = self.looker_api.get_query(look.query_id, query_fields)
|
if look.id is not None:
|
||||||
|
query: Optional[Query] = self.looker_api.get_look(
|
||||||
|
look.id, fields=["query"]
|
||||||
|
).query
|
||||||
|
# Only include fields that are in the query_fields list
|
||||||
|
query = Query(
|
||||||
|
**{
|
||||||
|
key: getattr(query, key)
|
||||||
|
for key in query_fields
|
||||||
|
if hasattr(query, key)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
dashboard_element: Optional[
|
dashboard_element: Optional[
|
||||||
LookerDashboardElement
|
LookerDashboardElement
|
||||||
|
@ -311,15 +311,17 @@ def setup_mock_look(mocked_client):
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
mocked_client.query.return_value = Query(
|
mocked_client.look.return_value = LookWithQuery(
|
||||||
id="1",
|
query=Query(
|
||||||
view="sales_explore",
|
id="1",
|
||||||
model="sales_model",
|
view="sales_explore",
|
||||||
fields=[
|
model="sales_model",
|
||||||
"sales.profit",
|
fields=[
|
||||||
],
|
"sales.profit",
|
||||||
dynamic_fields=None,
|
],
|
||||||
filters=None,
|
dynamic_fields=None,
|
||||||
|
filters=None,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user