Bigquery support for env without passing any config (#2160)

* Bigquery support for env without passing any config

* Bigquery File formatted
This commit is contained in:
Ayush Shah 2022-01-23 11:55:48 +05:30 committed by GitHub
parent a784bc217d
commit 6f5a4eafe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -2,9 +2,6 @@
"source": {
"type": "bigquery",
"config": {
"project_id": "project_id",
"host_port": "bigquery.googleapis.com",
"username": "gcpuser@project_id.iam.gserviceaccount.com",
"service_name": "gcp_bigquery",
"options":{
"credentials":{

View File

@ -54,6 +54,8 @@ _types.get_columns = get_columns
class BigQueryConfig(SQLConnectionConfig):
scheme = "bigquery"
host_port: Optional[str] = "bigquery.googleapis.com"
username: Optional[str] = None
project_id: Optional[str] = None
duration: int = 1
service_type = "BigQuery"
@ -72,7 +74,11 @@ class BigquerySource(SQLSource):
def create(cls, config_dict, metadata_config_dict, ctx):
config: SQLConnectionConfig = BigQueryConfig.parse_obj(config_dict)
metadata_config = MetadataServerConfig.parse_obj(metadata_config_dict)
if config.options.get("credentials", None):
if config.options.get("credentials_path"):
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = config.options[
"credentials_path"
]
elif config.options.get("credentials", None):
cred_path = create_credential_temp_file(config.options.get("credentials"))
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = cred_path
config.options["credentials_path"] = cred_path