specify to use standard sql or not

This commit is contained in:
mystelynx 2016-07-21 21:44:16 +09:00
parent f524dda88b
commit 2dac682e8e

View File

@ -104,9 +104,9 @@ class BigQuery(BaseQueryRunner):
"type": "string", "type": "string",
'title': 'UDF Source URIs (i.e. gs://bucket/date_utils.js, gs://bucket/string_utils.js )' 'title': 'UDF Source URIs (i.e. gs://bucket/date_utils.js, gs://bucket/string_utils.js )'
}, },
'useLegacySql': { 'useStandardSql(Beta)': {
"type": "boolean", "type": "boolean",
'title': "use BigQuery's legacy SQL: https://cloud.google.com/bigquery/query-reference", 'title': "use BigQuery's standard SQL: https://cloud.google.com/bigquery/sql-reference/",
} }
}, },
'required': ['jsonKeyFile', 'projectId'], 'required': ['jsonKeyFile', 'projectId'],
@ -136,7 +136,7 @@ class BigQuery(BaseQueryRunner):
job_data = { job_data = {
"query": query, "query": query,
"dryRun": True, "dryRun": True,
"useLegacySql": self.configuration.get('useLegacySql', False), "useLegacySql": not self.configuration.get('useStandardSql(Beta)', False),
} }
response = jobs.query(projectId=self._get_project_id(), body=job_data).execute() response = jobs.query(projectId=self._get_project_id(), body=job_data).execute()
return int(response["totalBytesProcessed"]) return int(response["totalBytesProcessed"])
@ -147,7 +147,7 @@ class BigQuery(BaseQueryRunner):
"configuration": { "configuration": {
"query": { "query": {
"query": query, "query": query,
"useLegacySql": self.configuration.get('useLegacySql', False), "useLegacySql": not self.configuration.get('useStandardSql(Beta)', False),
} }
} }
} }