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

SnowflakeIO: do not quote empty fields #33803

Merged
merged 3 commits into from
Jan 31, 2025
Merged

Conversation

turb
Copy link
Contributor

@turb turb commented Jan 29, 2025

When sending CSV to Snowflake for COPY, do not quote empty fields ('').

With some types, like integer, it leads to an error like this: net.snowflake.client.jdbc.SnowflakeSQLException: Numeric value '' is not recognized.

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.

@turb turb force-pushed the snowflake-empty-fields branch from 1b0d71a to 4269912 Compare January 29, 2025 19:22
Copy link
Contributor

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @Abacn for label java.
R: @chamikaramj for label io.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Copy link
Contributor

@Abacn Abacn left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. It sounds a valid edge case.

Ideally is there a way to unit test the change? e.g. to confirm

before: "1","","3","",
after "1",,"3",,

(not "1",,"3")

it does not introduce side effect like dropping a field, making the column mismatch

@@ -1192,7 +1192,13 @@ private String quoteField(String field) {
}

private String quoteField(String field, String quotation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

consider rename this private method (and its overload above) to sth like "quoteNonEmptyField" for clarity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixup 016e641

@turb
Copy link
Contributor Author

turb commented Jan 30, 2025

Ideally is there a way to unit test the change? e.g. to confirm

Added in fixup 54ec742

@Abacn Abacn merged commit 2360711 into apache:master Jan 31, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants