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-870432: use_logical_type for inferring timezone in pandas df #1134

Conversation

sfc-gh-aalam
Copy link
Contributor

@sfc-gh-aalam sfc-gh-aalam commented Nov 8, 2023

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 #870432, SNOW-886649: write_pandas inserts datetime64[ns] to Snowflake as an Invalid Date #991

  2. 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 a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    Port the fix from snowflake python connector to use_logical_type when inferring datatype from parquet files.

@sfc-gh-aalam sfc-gh-aalam marked this pull request as ready for review November 9, 2023 19:43
@sfc-gh-aalam sfc-gh-aalam requested a review from a team as a code owner November 9, 2023 19:43
@@ -1478,6 +1479,41 @@ def test_create_dataframe_with_semi_structured_data_types(session):
)


@pytest.mark.skipif(not is_pandas_available, reason="pandas is required")
def test_create_dataframe_with_pandas_df(session):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to port some changes to sp connector too to support use_logical_type in stored proc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right. We need to port this to sproc too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -2008,6 +2014,7 @@ def create_dataframe(
quote_identifiers=True,
auto_create_table=True,
table_type="temporary",
use_logical_type=True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a behavior change (i.e. wrong behavior -> correct behavior)? Should we highlight the implication in change log?

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'll update the changelog detailing what exactly is going to change

Copy link
Collaborator

@sfc-gh-yixie sfc-gh-yixie left a comment

Choose a reason for hiding this comment

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

Code looks good. One comment on the changelog.

CHANGELOG.md Outdated
Comment on lines 18 to 19
- Earlier timestamp columns without a timezone would be inferred as `LongType()` but will now be correctly inferred as `TimestampType(TimestampTimeZone.NTZ)`.
- Earlier timestamp columns without a timezone would be converted to nanosecond epochs, but will now be correctly be maintained as timestamp values.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these two lines for the same logic branch? If so please consider merging them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure. I'll merge them

@sfc-gh-aalam sfc-gh-aalam merged commit 4b81f5d into main Jan 3, 2024
56 of 57 checks passed
@sfc-gh-aalam sfc-gh-aalam deleted the aalam-SNOW-870432-use-logical-type-to-infer-timestamp-correctly branch January 3, 2024 18:59
@github-actions github-actions bot locked and limited conversation to collaborators Jan 3, 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.

4 participants