You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/06/01 21:45:55 UTC
[GitHub] [airflow] KristiKovacs opened a new issue #16209: BigQueryInsertJobOperator Expected OAuth 2 access token, login cookie or other valid authentication credential
KristiKovacs opened a new issue #16209:
URL: https://github.com/apache/airflow/issues/16209
We're trying to convert from Airflow 1.x to Airflow 2.0.2 and I've been stuck on getting this task to work. Previously we were using BigQueryOperator but is now deprecated, now I'm trying to get BigQueryInsertJobOperator to work:
```
hits_bq_extract = BigQueryInsertJobOperator(
dag=dag,
task_id='bq_query',
gcp_conn_id='google_cloud_default',
params={'data': util.querycontext},
configuration={
"query": {"query": "{% include 'sql/my_query.sql' %}", "useLegacySql": False,
"writeDisposition": "WRITE_TRUNCATE", "destinationTable": {"datasetId": bq_dataset}}
},
retries=16,
retry_delay=timedelta(minutes=20),
)
```
I see this following error:
https://bigquery.googleapis.com/bigquery/v2/projects/vice-analytics/jobs?prettyPrint=false:
This is the error I see in my logs:
[2021-05-31 22:24:05,972] {requests.py:182} DEBUG - Making request: POST https://accounts.google.com/o/oauth2/token
[2021-05-31 22:24:05,975] {connectionpool.py:955} DEBUG - Starting new HTTPS connection (1): accounts.google.com:443
[2021-05-31 22:24:06,007] {connectionpool.py:428} DEBUG - https://accounts.google.com:443 "POST /o/oauth2/token HTTP/1.1" 200 None
[2021-05-31 22:24:06,009] {connectionpool.py:955} DEBUG - Starting new HTTPS connection (1): bigquery.googleapis.com:443
[2021-05-31 22:24:06,232] {connectionpool.py:428} DEBUG - https://bigquery.googleapis.com:443 "POST /bigquery/v2/projects/vice-analytics/jobs?prettyPrint=false HTTP/1.1" 400 None
[2021-05-31 22:24:06,243] {taskinstance.py:1482} ERROR - Task failed with exception
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1138, in _run_raw_task
self._prepare_and_execute_task_with_callbacks(context, task)
File "/usr/local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1311, in _prepare_and_execute_task_with_callbacks
result = self._execute_task(context, task_copy)
File "/usr/local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1341, in _execute_task
result = task_copy.execute(context=context)
File "/usr/local/lib/python3.8/site-packages/airflow/providers/google/cloud/operators/bigquery.py", line 2193, in execute
job = self._submit_job(hook, job_id)
File "/usr/local/lib/python3.8/site-packages/airflow/providers/google/cloud/operators/bigquery.py", line 2152, in _submit_job
job = hook.insert_job(
File "/usr/local/lib/python3.8/site-packages/airflow/providers/google/common/hooks/base_google.py", line 425, in inner_wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/bigquery.py", line 1526, in insert_job
job.result()
File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/job/query.py", line 1159, in result
super(QueryJob, self).result(retry=retry, timeout=timeout)
File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/job/base.py", line 659, in result
self._begin(retry=retry, timeout=timeout)
File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/job/query.py", line 1033, in _begin
super(QueryJob, self)._begin(client=client, retry=retry, timeout=timeout)
File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/job/base.py", line 457, in _begin
api_response = client._call_api(
File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/client.py", line 640, in _call_api
return call()
File "/usr/local/lib/python3.8/site-packages/google/api_core/retry.py", line 281, in retry_wrapped_func
return retry_target(
File "/usr/local/lib/python3.8/site-packages/google/api_core/retry.py", line 184, in retry_target
return target()
File "/usr/local/lib/python3.8/site-packages/google/cloud/_http.py", line 438, in api_request
raise exceptions.from_http_response(response)
google.api_core.exceptions.BadRequest: 400 POST https://bigquery.googleapis.com/bigquery/v2/projects/vice-analytics/jobs?prettyPrint=false: Required parameter is missing
the gcp_conn_id = google_cloud_default has oauth2 (see below) which is what I think the operator is complaining about, so I'm not sure what else the issue could be?
export AIRFLOW_CONN_GOOGLE_CLOUD_DEFAULT="google-cloud-platform://?extra__google_cloud_platform__project=vice-analytics&extra__google_cloud_platform__keyfile_dict={\"type\": \"service_account\", \"project_id\": \"vice-analytics\", \"private_key_id\": \"${GCLOUD_PRIVATE_KEY_ID}\", \"private_key\": \"${GCLOUD_PRIVATE_KEY}\", \"client_email\": \"b@lytics.iam.gserviceaccount.com\", \"client_id\": \"12345678910\", \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\", \"token_uri\": \"https://accounts.google.com/o/oauth2/token\", \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\", \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/b%40lytics.iam.gserviceaccount.com\"}"
Is perhaps the formatting not correct?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mik-laj edited a comment on issue #16209: BigQueryInsertJobOperator required parameter is missing, but which?
Posted by GitBox <gi...@apache.org>.
mik-laj edited a comment on issue #16209:
URL: https://github.com/apache/airflow/issues/16209#issuecomment-854010814
For support questions please use Stackoverflow, Github Discussion or Slack. It is not a bug in Airflow, but in your task..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mik-laj commented on issue #16209: BigQueryInsertJobOperator required parameter is missing, but which?
Posted by GitBox <gi...@apache.org>.
mik-laj commented on issue #16209:
URL: https://github.com/apache/airflow/issues/16209#issuecomment-854010814
For support questions please use Stackoverflow, Github Discussion or Slack.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Jaxing commented on issue #16209: BigQueryInsertJobOperator required parameter is missing, but which?
Posted by GitBox <gi...@apache.org>.
Jaxing commented on issue #16209:
URL: https://github.com/apache/airflow/issues/16209#issuecomment-927823503
I found a solution to my problem. I could use googles QueryJobConfiguration to create the config.
```
db_copy_projects_query = "<SELECT Statement>"
conf = QueryJobConfig(
destination="<project_id>.testing.test_bq_operator",
write_disposition="WRITE_APPEND",
schema_update_options=["ALLOW_FIELD_ADDITION", "ALLOW_FIELD_RELAXATION"],
use_legacy_sql=False,
priority="BATCH").to_api_repr()
db_copy_projects = BigQueryInsertJobOperator(
task_id="db_copy_projects",
job_id="db_copy_projects",
configuration=conf,
project_id="<project_id>",
location='EU',
gcp_conn_id='google-cloud'
)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mik-laj closed issue #16209: BigQueryInsertJobOperator required parameter is missing, but which?
Posted by GitBox <gi...@apache.org>.
mik-laj closed issue #16209:
URL: https://github.com/apache/airflow/issues/16209
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mik-laj commented on issue #16209: BigQueryInsertJobOperator required parameter is missing, but which?
Posted by GitBox <gi...@apache.org>.
mik-laj commented on issue #16209:
URL: https://github.com/apache/airflow/issues/16209#issuecomment-854010814
For support questions please use Stackoverflow, Github Discussion or Slack.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mik-laj edited a comment on issue #16209: BigQueryInsertJobOperator required parameter is missing, but which?
Posted by GitBox <gi...@apache.org>.
mik-laj edited a comment on issue #16209:
URL: https://github.com/apache/airflow/issues/16209#issuecomment-854010814
For support questions please use Stackoverflow, Github Discussion or Slack. It is not a bug in Airflow, but in your task..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mik-laj closed issue #16209: BigQueryInsertJobOperator required parameter is missing, but which?
Posted by GitBox <gi...@apache.org>.
mik-laj closed issue #16209:
URL: https://github.com/apache/airflow/issues/16209
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on issue #16209: BigQueryInsertJobOperator Expected OAuth 2 access token, login cookie or other valid authentication credential
Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #16209:
URL: https://github.com/apache/airflow/issues/16209#issuecomment-852467827
Thanks for opening your first issue here! Be sure to follow the issue template!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Jaxing commented on issue #16209: BigQueryInsertJobOperator required parameter is missing, but which?
Posted by GitBox <gi...@apache.org>.
Jaxing commented on issue #16209:
URL: https://github.com/apache/airflow/issues/16209#issuecomment-926634257
I think this might be due to a bug.
This configuration of the operator works
```db_copy_projects = BigQueryInsertJobOperator(
task_id="db_copy_projects",
job_id="db_copy_projects",
configuration={
"query": {
"query": "<SELECT Statement>",
"useLegacySql": False
},
project_id="<project_id>",
location='EU',
gcp_conn_id='google-cloud'
)
```
But if I try to make it save it to a destination table like this
```db_copy_projects = BigQueryInsertJobOperator(
task_id="db_copy_projects",
job_id="db_copy_projects",
configuration={
"query": {
"query": "<SELECT Statement>",
"useLegacySql": False,
"destinationTable": {
"projectId": "<project_id>",
"datasetId": "testing",
"tabelId": "test_bq_operator"
},
"createDisposition": "CREATE_IF_NEEDED",
"write_Disposition": "WRITE_APPEND",
"priority": "BATCH",
"schemaUpdateOptions": ["ALLOW_FIELD_ADDITION", "ALLOW_FIELD_RELAXATION"],
"timePartitioning":{
"type": "DAY",
"field": "created"
}
}
},
project_id="",
location='EU',
gcp_conn_id='google-cloud'
)
```
I getting `google.api_core.exceptions.BadRequest: 400 POST https://bigquery.googleapis.com/bigquery/v2/projects/<project_id>/jobs?prettyPrint=false: Required parameter is missing`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Jaxing edited a comment on issue #16209: BigQueryInsertJobOperator required parameter is missing, but which?
Posted by GitBox <gi...@apache.org>.
Jaxing edited a comment on issue #16209:
URL: https://github.com/apache/airflow/issues/16209#issuecomment-926634257
@mik-laj
I think this might be due to a bug.
This configuration of the operator works
```db_copy_projects = BigQueryInsertJobOperator(
task_id="db_copy_projects",
job_id="db_copy_projects",
configuration={
"query": {
"query": "<SELECT Statement>",
"useLegacySql": False
},
project_id="<project_id>",
location='EU',
gcp_conn_id='google-cloud'
)
```
But if I try to make it save it to a destination table like this
```db_copy_projects = BigQueryInsertJobOperator(
task_id="db_copy_projects",
job_id="db_copy_projects",
configuration={
"query": {
"query": "<SELECT Statement>",
"useLegacySql": False,
"destinationTable": {
"projectId": "<project_id>",
"datasetId": "testing",
"tabelId": "test_bq_operator"
},
"createDisposition": "CREATE_IF_NEEDED",
"write_Disposition": "WRITE_APPEND",
"priority": "BATCH",
"schemaUpdateOptions": ["ALLOW_FIELD_ADDITION", "ALLOW_FIELD_RELAXATION"],
"timePartitioning":{
"type": "DAY",
"field": "created"
}
}
},
project_id="",
location='EU',
gcp_conn_id='google-cloud'
)
```
I getting `google.api_core.exceptions.BadRequest: 400 POST https://bigquery.googleapis.com/bigquery/v2/projects/<project_id>/jobs?prettyPrint=false: Required parameter is missing`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org