Skip to content

Commit

Permalink
open-metadata#14099: fix bigquery test connection & SP query (open-me…
Browse files Browse the repository at this point in the history
…tadata#14106)

* Fix open-metadata#14099: fix bigquery test connection & sp query

* fix unquote condition

* pyformat
  • Loading branch information
ulixius9 authored Nov 28, 2023
1 parent e2043a3 commit 49a5557
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Source connection handler
"""
import os
from datetime import datetime
from functools import partial
from typing import Optional

Expand Down Expand Up @@ -122,7 +123,8 @@ def test_connection_inner(engine):
test_query,
engine=engine,
statement=BIGQUERY_TEST_STATEMENT.format(
region=service_connection.usageLocation
region=service_connection.usageLocation,
creation_date=datetime.now().strftime("%Y-%m-%d"),
),
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def get_schema_description(self, schema_name: str) -> Optional[str]:
)

query_result = [result.schema_description for result in query_resp.result()]
return query_result[0]
return fqn.unquote_name(query_result[0])
except IndexError:
logger.debug(f"No dataset description found for {schema_name}")
except Exception as err:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
)

BIGQUERY_TEST_STATEMENT = textwrap.dedent(
"""SELECT query FROM `region-{region}`.INFORMATION_SCHEMA.JOBS_BY_PROJECT limit 1"""
"""SELECT query FROM `region-{region}`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
where creation_time > '{creation_date}' limit 1"""
)


Expand Down Expand Up @@ -81,7 +82,7 @@
user_email as user_name
FROM `region-{region}`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE statement_type = 'SCRIPT'
AND start_time >= '{start_date}'
AND creation_time >= '{start_date}'
AND job_type = "QUERY"
AND state = "DONE"
AND error_result is NULL
Expand All @@ -102,7 +103,7 @@
WHERE statement_type <> 'SCRIPT'
AND query NOT LIKE '/* {{"app": "OpenMetadata", %%}} */%%'
AND query NOT LIKE '/* {{"app": "dbt", %%}} */%%'
AND start_time >= '{start_date}'
AND creation_time >= '{start_date}'
AND job_type = "QUERY"
AND state = "DONE"
AND error_result is NULL
Expand Down
2 changes: 1 addition & 1 deletion ingestion/src/metadata/utils/fqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _build(*args, quote: bool = True) -> str:


def unquote_name(name: str) -> str:
return name[1:-1] if name is not None and '"' in name else name
return name[1:-1] if name and name[0] == '"' and name[-1] == '"' else name


def quote_name(name: str) -> str:
Expand Down

0 comments on commit 49a5557

Please sign in to comment.