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,
|
||||
LookmlModel,
|
||||
LookmlModelExplore,
|
||||
LookWithQuery,
|
||||
Query,
|
||||
User,
|
||||
WriteQuery,
|
||||
@ -64,6 +65,7 @@ class LookerAPIStats(BaseModel):
|
||||
all_looks_calls: int = 0
|
||||
all_models_calls: int = 0
|
||||
get_query_calls: int = 0
|
||||
get_look_calls: int = 0
|
||||
search_looks_calls: int = 0
|
||||
search_dashboards_calls: int = 0
|
||||
|
||||
@ -255,6 +257,14 @@ class LookerAPI:
|
||||
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(
|
||||
self, fields: Union[str, List[str]], deleted: str
|
||||
) -> Sequence[Dashboard]:
|
||||
|
@ -1199,7 +1199,18 @@ class LookerDashboardSource(TestableSource, StatefulIngestionSourceBase):
|
||||
logger.info(f"query_id is None for look {look.title}({look.id})")
|
||||
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[
|
||||
LookerDashboardElement
|
||||
|
@ -311,7 +311,8 @@ def setup_mock_look(mocked_client):
|
||||
)
|
||||
]
|
||||
|
||||
mocked_client.query.return_value = Query(
|
||||
mocked_client.look.return_value = LookWithQuery(
|
||||
query=Query(
|
||||
id="1",
|
||||
view="sales_explore",
|
||||
model="sales_model",
|
||||
@ -321,6 +322,7 @@ def setup_mock_look(mocked_client):
|
||||
dynamic_fields=None,
|
||||
filters=None,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def setup_mock_soft_deleted_look(mocked_client):
|
||||
|
Loading…
x
Reference in New Issue
Block a user