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

Bigquery sqlalchemy metastore #1352

Merged
merged 3 commits into from
Nov 29, 2023
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
8 changes: 4 additions & 4 deletions querybook/server/clients/google_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def get_google_credentials(creds_info=None):
)

cred_to_use = creds_info or QuerybookSettings.GOOGLE_CREDS
assert cred_to_use is not None, "Invalid Google credentials"

credentials = service_account.Credentials.from_service_account_info(cred_to_use)

return credentials
if cred_to_use is not None:
return service_account.Credentials.from_service_account_info(cred_to_use)
else:
return None


GOOGLE_AUTH_CONFIG = "https://accounts.google.com/.well-known/openid-configuration"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ def get_all_schema_names(self) -> List[str]:
return self._inspect.get_schema_names()

def get_all_table_names_in_schema(self, schema_name: str) -> List[str]:
return self._inspect.get_table_names(schema=schema_name)
if self._engine.dialect.name == "bigquery":
return [table.split(".")[1] for table in self._inspect.get_table_names(schema=schema_name)]
else:
return self._inspect.get_table_names(schema=schema_name)

def get_table_and_columns(
self, schema_name, table_name
Expand Down
8 changes: 5 additions & 3 deletions querybook/server/lib/query_executor/clients/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ def __init__(self, google_credentials_json=None, *args, **kwargs):
if google_credentials_json is not None
else None
)
cred = get_google_credentials(parsed_google_json)

client = Client(project=cred.project_id, credentials=cred)
if parsed_google_json is not None:
cred = get_google_credentials(parsed_google_json)
client = Client(project=cred.project_id, credentials=cred)
else:
client = Client()

self._conn = dbapi.connect(client=client)
super(BigQueryClient, self).__init__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@
(
"google_credentials_json",
FormField(
helper="The JSON string used to log in as service account. If not provided then **GOOGLE_CREDS** from settings will be used.",
helper="""
<p>The JSON string used to log in as service account.</p>
<p>If not provided then **GOOGLE_CREDS** from settings will be used</p>
<p>If both are empty, Application default credentials are used</p>
""",
),
)
)
9 changes: 4 additions & 5 deletions requirements/engine/bigquery.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
google-cloud-bigquery==1.28.0

# Downgrade Protobuf to fix error with bigquery:
# TypeError: Descriptors cannot not be created directly.
protobuf==3.20.1
google-cloud-bigquery==3.12.0
google-cloud-bigquery-storage==2.22.0
pyarrow==13.0.0
sqlalchemy-bigquery==1.8.0