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-862622 Add support for timestamp variations #943

Merged
merged 4 commits into from
Jul 20, 2023

Conversation

sfc-gh-azhan
Copy link
Collaborator

@sfc-gh-azhan sfc-gh-azhan commented Jul 13, 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.

    SNOW-862622 Add support for timestamp variations

  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.

    Please write a short description of how your code change solves the related issue.

This PR adds support for Snowflake timestamp variations, e.g., TIMESTAMP_NTZ, TIMESTAMP_TZ, TIMESTAMP_LTZ. Today Snowpark Python only supports Timestamp alias for Timestamp types and the underlying type is controlled by TIMESTAMP_TYPE_MAPPING. This PR allows user to specify which variation of TIMESTAMP type to use by adding a TimestampType attribute tz.

@sfc-gh-azhan sfc-gh-azhan force-pushed the azhan-timestmap-tz-862622 branch 3 times, most recently from 025b930 to 53dcd6a Compare July 14, 2023 22:41
@codecov
Copy link

codecov bot commented Jul 14, 2023

Codecov Report

Merging #943 (5eb0d94) into main (edd7f29) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #943   +/-   ##
=======================================
  Coverage   98.46%   98.47%           
=======================================
  Files          51       51           
  Lines        9079     9122   +43     
  Branches     1626     1642   +16     
=======================================
+ Hits         8940     8983   +43     
  Misses         55       55           
  Partials       84       84           
Impacted Files Coverage Δ
...ake/snowpark/_internal/analyzer/datatype_mapper.py 97.70% <100.00%> (+0.16%) ⬆️
src/snowflake/snowpark/_internal/type_utils.py 98.14% <100.00%> (+0.07%) ⬆️
src/snowflake/snowpark/session.py 98.84% <100.00%> (+0.01%) ⬆️
src/snowflake/snowpark/types.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@sfc-gh-azhan sfc-gh-azhan changed the title [WIP] SNOW-862622 preserve timezone for timestamp types SNOW-862622 Add support for timestamp variations Jul 17, 2023
@sfc-gh-azhan sfc-gh-azhan marked this pull request as ready for review July 17, 2023 18:02
@sfc-gh-azhan sfc-gh-azhan requested a review from a team as a code owner July 17, 2023 18:02
Copy link
Collaborator

@sfc-gh-sfan sfc-gh-sfan left a comment

Choose a reason for hiding this comment

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

Looks good. You might want to test in stored proc (job) and see if it works.

src/snowflake/snowpark/_internal/type_utils.py Outdated Show resolved Hide resolved
@sfc-gh-azhan
Copy link
Collaborator Author

Looks good. You might want to test in stored proc (job) and see if it works.

running https://ci-dev-142.int.snowflakecomputing.com/job/PythonStoredProcBuildPrecommitTest/464/

@@ -285,6 +294,10 @@ def infer_type(obj: Any) -> DataType:
if datatype is DecimalType:
# the precision and scale of `obj` may be different from row to row.
return DecimalType(38, 18)
elif datatype is TimestampType and obj.tzinfo is not None:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sfc-gh-azhan sfc-gh-azhan force-pushed the azhan-timestmap-tz-862622 branch 2 times, most recently from 530c10e to 9d43416 Compare July 19, 2023 04:02
@sfc-gh-azhan
Copy link
Collaborator Author

@sfc-gh-azhan sfc-gh-azhan merged commit 618c17a into main Jul 20, 2023
41 checks passed
@sfc-gh-azhan sfc-gh-azhan deleted the azhan-timestmap-tz-862622 branch July 20, 2023 15:42
@github-actions github-actions bot locked and limited conversation to collaborators Jul 20, 2023
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