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/05/27 00:26:43 UTC

[GitHub] [airflow] ZackBarry opened a new issue #16101: BigQueryHook `create_empty_dataset` missing `datasetReference`

ZackBarry opened a new issue #16101:
URL: https://github.com/apache/airflow/issues/16101


   <!--
   
   Welcome to Apache Airflow!  For a smooth issue process, try to answer the following questions.
   Don't worry if they're not all applicable; just try to include what you can :-)
   
   If you need to include code snippets or logs, please put them in fenced code
   blocks.  If they're super-long, please use the details tag like
   <details><summary>super-long log</summary> lots of stuff </details>
   
   Please delete these comment blocks before submitting the issue.
   
   -->
   
   <!--
   
   IMPORTANT!!!
   
   PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
   NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!
   
   PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!
   
   Please complete the next sections or the issue will be closed.
   These questions are the first thing we need to know to understand the context.
   
   -->
   
   **Apache Airflow version**:
   2.0.2
   
   **Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
   1.19
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**: GKE
   - **OS** (e.g. from /etc/os-release): Debian GNU/Linux 10 (buster)
   - **Kernel** (e.g. `uname -a`): x86_64 GNU/Linux
   - **Install tools**:
   - **Others**:
   
   **What happened**:
   
   Using the `dataset_reference` argument for `BigQueryCreateEmptyDatasetOperator` to set table expiration throws an error:
   ```
   [2021-05-27 00:03:23,999] {taskinstance.py:1455} ERROR - 'datasetReference'
   Traceback (most recent call last):
     File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1112, in _run_raw_task
       self._prepare_and_execute_task_with_callbacks(context, task)
     File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1285, in _prepare_and_execute_task_with_callbacks
       result = self._execute_task(context, task_copy)
     File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1315, in _execute_task
       result = task_copy.execute(context=context)
     File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/providers/google/cloud/operators/bigquery.py", line 1419, in execute
       bq_hook.create_empty_dataset(
     File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/providers/google/common/hooks/base_google.py", line 425, in inner_wrapper
       return func(self, *args, **kwargs)
     File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/providers/google/cloud/hooks/bigquery.py", line 414, in create_empty_dataset
       specified_param = dataset_reference["datasetReference"].get(param)
   KeyError: 'datasetReference'
   ```
   
   **What you expected to happen**:
   
   I expected no error, the operator shows a similar `dataset_reference` dict in its documentation:
   ```
   create_new_dataset = BigQueryCreateEmptyDatasetOperator(                
       dataset_id='new-dataset',                
       project_id='my-project',                
       dataset_reference={"friendlyName": "New Dataset"}, 
       gcp_conn_id='_my_gcp_conn_',                
       task_id='newDatasetCreator',                
       dag=dag
   )
   ```
   
   **How to reproduce it**:
   
   ```
   create_dataset = BigQueryCreateEmptyDatasetOperator(
       task_id='create_dataset',
       project_id=PROJECT,
       dataset_id=DATASET,
       dataset_reference={"defaultTableExpirationMs": str(1000 * 60 * 60 * 24 * 30)},
       dag=dag
   )
   ```
   
   **Anything else we need to know**:
   
   The `create_empty_dataset` method from the `BigQueryHook` class expects `datasetReference` to always be a key in the dictionary:
   
   https://github.com/apache/airflow/blob/86768859c689bf02ced96e71996a3a30da1b5888/airflow/providers/google/cloud/hooks/bigquery.py#L442
   
   I was able to fix the error adding it:
   ```
   create_dataset = BigQueryCreateEmptyDatasetOperator(
       task_id='create_dataset',
       project_id=PROJECT,
       dataset_id=DATASET,
       dataset_reference={"datasetReference": {}, "defaultTableExpirationMs": str(1000 * 60 * 60 * 24 * 30)},
       dag=dag
   )
   ```
   


-- 
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 #16101: BigQueryHook `create_empty_dataset` missing `datasetReference`

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #16101:
URL: https://github.com/apache/airflow/issues/16101#issuecomment-849209119


   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] potiuk commented on issue #16101: BigQueryHook `create_empty_dataset` missing `datasetReference`

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #16101:
URL: https://github.com/apache/airflow/issues/16101#issuecomment-849326478


   Would you be willing to provide a PR fixing it @ZackBarry ?


-- 
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] lucas-houles commented on issue #16101: BigQueryHook `create_empty_dataset` missing `datasetReference`

Posted by GitBox <gi...@apache.org>.
lucas-houles commented on issue #16101:
URL: https://github.com/apache/airflow/issues/16101#issuecomment-1000304446


   Hello this issue still open?
   If so can i tackle it?


-- 
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] ZackBarry commented on issue #16101: BigQueryHook `create_empty_dataset` missing `datasetReference`

Posted by GitBox <gi...@apache.org>.
ZackBarry commented on issue #16101:
URL: https://github.com/apache/airflow/issues/16101#issuecomment-849726818


   Sure thing @potiuk 


-- 
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 #16101: BigQueryHook `create_empty_dataset` missing `datasetReference`

Posted by GitBox <gi...@apache.org>.
mik-laj commented on issue #16101:
URL: https://github.com/apache/airflow/issues/16101#issuecomment-850853852


   I hope that soon Google will add full support for SQL and we won't have to maintain so many operators for one service. Other data warehouses only have one or two operators but are not less powerfull.
   ```
   $ curl -s 'https://raw.githubusercontent.com/apache/airflow/master/airflow/providers/google/cloud/operators/bigquery.py' | grep '^class' | grep -v "^class _" | grep -v "enum.Enum" | grep -v "BaseOperatorLink" | wc -l
         18
   ```


-- 
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] lucas-houles removed a comment on issue #16101: BigQueryHook `create_empty_dataset` missing `datasetReference`

Posted by GitBox <gi...@apache.org>.
lucas-houles removed a comment on issue #16101:
URL: https://github.com/apache/airflow/issues/16101#issuecomment-1000304446


   Hello this issue still open?
   If so can i tackle it?


-- 
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