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

Allow JSON type in TableSchema for BigQuery FILE_LOAD #29923

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

Abacn
Copy link
Contributor

@Abacn Abacn commented Jan 4, 2024

Fixes #23025 ; fixes #27448

  • Warn instead of fail validation and link to documentation

  • Add test for this use case

Please add a meaningful description for your change here


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

* Warn instead of fail validation and link to documentation

* Add test for this use case

p.run().waitUntilFinish();
}

@Test
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The write tests also read from bigquery table for validation with pipelines, with exactly same pipelines of the read test. So I have consolidated these two read tests into writeandread.

Copy link
Contributor

github-actions bot commented Jan 4, 2024

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@Abacn
Copy link
Contributor Author

Abacn commented Jan 8, 2024

R: @ahmedabu98

Copy link
Contributor

github-actions bot commented Jan 8, 2024

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

Copy link
Contributor

@ahmedabu98 ahmedabu98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of comments but otherwise looks good.

Can we add the TableSchema instructions to the documentation somewhere?

Comment on lines 3581 to 3584
LOG.warn(
"Found JSON type in TableSchema for 'FILE_LOADS' write method. \n"
+ "Make sure the TableSchema field is a parsed JSON to ensure the read as a "
+ "JSON type. Otherwise it will read as a raw (escaped) string.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean the TableRow value should be a parsed JSON?

Copy link
Contributor Author

@Abacn Abacn Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is documented behavior of BQ FILE_LOAD API

e.g., instead of "someColumn": "[1]", it needs to be "someColumn": [1]. Otherwise it will write as a single string (string is also valid json object)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, can we change it to Make sure the TableRow value is a parsed JSON...?

Can we also include a link to the documented behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see. I meant to TableRow value. It was a typo.

@@ -3575,11 +3573,22 @@ private <DestinationT> WriteResult continueExpandTyped(
!getPropagateSuccessfulStorageApiWrites(),
"withPropagateSuccessfulStorageApiWrites only supported when using storage api writes.");

// Batch load jobs currently support JSON data insertion only with CSV files
// Beam does not yet support Batch load jobs with Avro files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this comment? I think it's supported for all types now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for catching this

@Abacn Abacn closed this Jan 26, 2024
@Abacn Abacn deleted the bqjsonload branch January 26, 2024 18:23
@Abacn Abacn restored the bqjsonload branch January 26, 2024 18:24
@Abacn Abacn reopened this Jan 26, 2024
@Abacn
Copy link
Contributor Author

Abacn commented Jan 26, 2024

R: @ahmedabu98 missed tracking this, PTAL

Copy link
Contributor

@ahmedabu98 ahmedabu98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warnings are pretty good. I suggest we add that content to the class javadoc as well (non-blocker)

LGTM though

@Abacn
Copy link
Contributor Author

Abacn commented Jan 26, 2024

Failed test FhirIOWriteIT known flaky, not related to the change, merging for now

@Abacn Abacn merged commit 8485ab4 into apache:master Jan 26, 2024
31 of 33 checks passed
@Abacn Abacn deleted the bqjsonload branch January 26, 2024 19:39
@Abacn Abacn mentioned this pull request Feb 27, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants