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

SNOW-878116 Add support for PARTITION BY to COPY INTO location #542

Merged
merged 12 commits into from
Nov 21, 2024

Conversation

sfc-gh-lcalderonachio
Copy link
Contributor

@sfc-gh-lcalderonachio sfc-gh-lcalderonachio commented Nov 13, 2024

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-878116: CopyInto does not support the PARTITION BY clause #430

Co-authored by @azban

  1. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding new credentials
    • I am adding a new dependency
  2. Please describe how your code solves the related issue.

This adds an argument to CopyInto which can be used to specify the PARTITION BY value.

Copy link

github-actions bot commented Nov 13, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sfc-gh-dszmolka sfc-gh-dszmolka changed the title Add support for PARTITION BY to COPY INTO location SNOW-878116 Add support for PARTITION BY to COPY INTO location Nov 14, 2024
@sfc-gh-lcalderonachio
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@sfc-gh-lcalderonachio sfc-gh-lcalderonachio marked this pull request as ready for review November 19, 2024 16:14
@sfc-gh-lcalderonachio sfc-gh-lcalderonachio requested a review from a team as a code owner November 19, 2024 16:14
@sfc-gh-lcalderonachio sfc-gh-lcalderonachio force-pushed the lcalderonachio-copyInto-partitionBy-test branch from c9f90d9 to c8dee12 Compare November 19, 2024 20:26
partition_by_value = copy_into.partition_by

partition_by = (
f"PARTITION BY {partition_by_value}" if partition_by_value != "" else ""
Copy link

@sfc-gh-ecuberojimenez sfc-gh-ecuberojimenez Nov 20, 2024

Choose a reason for hiding this comment

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

What happens if the actual partition_by_value is an empty string? The actual partition_by will have the value: "PARTITION BY". Is this the expected behaviour? I have the idea that if the partition_by_value is an empty string the partition_by variable should be empty or not taken into consideration when creating copy query command? Is this case even happening?

Copy link
Contributor Author

@sfc-gh-lcalderonachio sfc-gh-lcalderonachio Nov 20, 2024

Choose a reason for hiding this comment

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

Thanks for the observations here. I have updated the code to make partition_by_value None by default and check if the partition_by should be an empty string or not based on this as well.
Right now, if the partition_by_value variable is None (or empty string), then partition_by will be an empty string, effectively not adding anything related at all to the PARTITION BY to the COPY INTO statement.
The existing test case test_copy_into_location already validates the None case in most of the asserts where they do not have the PARTITION BY clause.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added an extra test case where the empty string case is being validated 5179d3e

@sfc-gh-lcalderonachio sfc-gh-lcalderonachio force-pushed the lcalderonachio-copyInto-partitionBy-test branch from 5179d3e to d374354 Compare November 20, 2024 22:11
DESCRIPTION.md Outdated
@@ -19,6 +19,7 @@ Source code is also available at:
- Add support for iceberg table with Snowflake Catalog
- Fix cluster by option to support explicit expressions
- Add support for MAP datatype
- Add support for partition by to copy into <location>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add this to Unreleased section

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. Changed in 300a4fb

@sfc-gh-lcalderonachio sfc-gh-lcalderonachio requested a review from a team as a code owner November 21, 2024 17:10
@sfc-gh-lcalderonachio sfc-gh-lcalderonachio merged commit 65754a4 into main Nov 21, 2024
45 checks passed
@sfc-gh-lcalderonachio sfc-gh-lcalderonachio deleted the lcalderonachio-copyInto-partitionBy-test branch November 21, 2024 22:06
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SNOW-878116: CopyInto does not support the PARTITION BY clause
4 participants