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

PostgresToGCSOperator does not allow nested JSON #23040

Closed
2 tasks done
xfoursea opened this issue Apr 15, 2022 · 3 comments · Fixed by #23063
Closed
2 tasks done

PostgresToGCSOperator does not allow nested JSON #23040

xfoursea opened this issue Apr 15, 2022 · 3 comments · Fixed by #23063
Assignees
Labels
area:providers good first issue kind:bug This is a clearly a bug provider:google Google (including GCP) related issues

Comments

@xfoursea
Copy link

Apache Airflow Provider(s)

google

Versions of Apache Airflow Providers

apache-airflow-providers-google==6.3.0

Apache Airflow version

2.1.4

Operating System

macOS Big Sur version 11.6.1

Deployment

Composer

Deployment details

No response

What happened

Postgres JSON column output contains extra \:

{"info": "{\"phones\": [{\"type\": \"mobile\", \"phone\": \"001001\"}, {\"type\": \"fix\", \"phone\": \"002002\"}]}", "name": null}

While in the previous version the output looks like
{"info": {"phones": [{"phone": "001001", "type": "mobile"}, {"phone": "002002", "type": "fix"}]}, "name": null}

The introduced extra \ will cause JSON parsing error in following GCSToBigQueryOperator

What you think should happen instead

The output should NOT contain extra \:
{"info": {"phones": [{"phone": "001001", "type": "mobile"}, {"phone": "002002", "type": "fix"}]}, "name": null}

It is caused by this new code change in https://github.com/apache/airflow/blob/main/airflow/providers/google/cloud/transfers/postgres_to_gcs.py
should comment out this block

if isinstance(value, dict):
return json.dumps(value)

How to reproduce

Try to output a Postgres table with JSON column --- you may use the the info above as example.

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@xfoursea xfoursea added area:providers kind:bug This is a clearly a bug labels Apr 15, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 15, 2022

Thanks for opening your first issue here! Be sure to follow the issue template!

@uranusjr uranusjr changed the title PostgresToGCSOperator introduce extra \ in JSON column output PostgresToGCSOperator does not allow nested JSON Apr 16, 2022
@eladkal
Copy link
Contributor

eladkal commented Apr 18, 2022

@pierrejeambrun would you like to take a look at this?

@eladkal eladkal added provider:google Google (including GCP) related issues good first issue labels Apr 18, 2022
@pierrejeambrun
Copy link
Member

Hello guys,

Yes I can take a look @eladkal, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers good first issue kind:bug This is a clearly a bug provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants