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

Fix BigQueryGetDataOperator Response Serialisation #22936

Merged
merged 1 commit into from
Apr 13, 2022

Conversation

pankajastro
Copy link
Member

@pankajastro pankajastro commented Apr 12, 2022

Currently, if I do not pass the selected_fields parameter in BigQueryGetDataOperator which is equivalent to select * from table and bigquery table has a column having type Date, Time, Datetime or Decimal then the Python JSON module fails to serialise the response of this operator and the task fails.

This happens because when we do not pass the column name in the google client request then it returns a column value in form of an object Python JSON fails to serialise it but if I'm passing the column name then it is returned as a string

There is existing work around it by setting enable_xcom_pickling to true in default_airflow.cfg but this is insecure

Changes:

  • Send all columns as selected_fields in case the selected_fields param is None

After this change below task will succeed and store the response in xcom for any bigquery column type without setting up enable_xcom_pickling to true

get_data = BigQueryGetDataOperator(
        task_id='get_data_from_bq',
        dataset_id=DATASET_NAME,
        table_id='dummy_table',
        max_results=100,
    )

@kaxil @phanikumv

@boring-cyborg boring-cyborg bot added area:providers provider:google Google (including GCP) related issues labels Apr 12, 2022
@pankajastro pankajastro changed the title Type cast bigquery response Fix BigQueryGetDataOperator Response Serialisation Apr 12, 2022
@pankajastro pankajastro marked this pull request as ready for review April 12, 2022 06:26
@pankajastro pankajastro force-pushed the type_cast_bigquery_response branch 2 times, most recently from 68baccd to 671808d Compare April 12, 2022 12:24
@kaxil kaxil requested a review from uranusjr April 12, 2022 15:55
@pankajastro pankajastro force-pushed the type_cast_bigquery_response branch 2 times, most recently from 62fbdb0 to 9e10d04 Compare April 13, 2022 05:57
Use in instead of get for conditinal check
@github-actions github-actions bot added the okay to merge It's ok to merge this PR as it does not require more tests label Apr 13, 2022
@github-actions
Copy link

The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease.

@potiuk potiuk merged commit aa317d9 into apache:main Apr 13, 2022
@pankajastro pankajastro deleted the type_cast_bigquery_response branch March 17, 2023 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers okay to merge It's ok to merge this PR as it does not require more tests provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants