-
Notifications
You must be signed in to change notification settings - Fork 116
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-1513884: Local Testing Issues with dateadd and current_timestamp Functions in Snowpark Python #1859
Comments
Hello @hima-gopisetty , Thanks for raising the issue, we are looking into it, will update. Regards, |
Hello @hima-gopisetty , I tried the code with local testing and its working as expected. There are no Null or Nat values getting inserted, and you need to change the code to add 10 days to column 'RECORD_CREATED_TS' For the current_timestamp addition: Q1. I expected that adding the current timestamp would successfully append a new column current_timestamp to each row, showing the exact current timestamp, with no null or NaT values Ans: Its not adding null or NaT values, proper current_timestamp is getting added to the dataframe. Q2 For the date_plus_10_days calculation: The expectation was that the dateadd function would add 10 days to the dates in the RECORD_CREATED_TS column without any errors, accurately reflecting the new dates. Ans: The code needs to be modified, please use the following code sf_df_with_added_days = sf_df.with_column("date_plus_10_days", dateadd("day", lit(10), col("RECORD_CREATED_TS"))) Please find the updated code and output `from snowflake.snowpark.functions import dateadd, lit, current_timestamp Create a session - ensure you set up your own configuration appropriatelysession = Session.builder.config('local_testing', True).create() Create a Snowflake DataFramesf_df = session.create_dataframe( Add current_timestamp to the DataFramesf_ts = sf_df.with_column("current_timestamp", current_timestamp()) Attempt to add 10 days to each date in the DataFrame using dateaddsf_df_with_added_days = sf_df.with_column("date_plus_10_days", dateadd("day", lit(10), current_timestamp())) Add 10 days to the RECORD_CREATED_TS column using dateaddsf_df_with_added_days = sf_df.with_column("date_plus_10_days", dateadd("day", lit(10), col("RECORD_CREATED_TS"))) |"ROLE_NAME" |"GIT_COMMIT_VALUE" |"RECORD_CREATED_TS" ||RL_TEST_ROLE_GRANTS |ABC123 |2000-01-01 00:00:00 |
|
Hi @sfc-gh-sghosh , Could you let me know if you are using the same snowflake-snowpark-python==1.14.0 version as mine? When I run it again locally, I encounter the same issue where it's adding NaT to rows. In fact, it's adding NaT to all rows except the first one -------------------------------------------------------------------------------------------------
|"ROLE_NAME" |"GIT_COMMIT_VALUE" |"RECORD_CREATED_TS" |"CURRENT_TIMESTAMP" |
-------------------------------------------------------------------------------------------------
|RL_TEST_ROLE_GRANTS |ABC123 |2000-01-01 00:00:00 |2024-07-04 21:53:13.171780 |
|RL_TEST_ROLE_SUPPORT |ABC123 |2000-01-01 00:00:00 |NaT |
|RL_TEST_ROLE_SUPPORT2 |ABC123 |2000-01-01 00:00:00 |NaT |
|RL_TEST_ROLE_SUPPORT3 |ABC123 |2000-01-01 00:00:00 |NaT |
-------------------------------------------------------------------------------------------------
|
Hello @hima-gopisetty , Yes, you are right. The issue is with snowpark python 1.14.0. I am also getting NaT. Regards, |
Please answer these questions before submitting your issue. Thanks!
1. What version of Python are you using?
2. What are the Snowpark Python and pandas versions in the environment?
3. What did you do?
I was using the Snowflake Snowpark Python library to work with DataFrames, specifically adding current timestamps and manipulating date values. Below is the complete, executable code that led to the issues
4. What did you expect to see?
For the
current_timestamp
addition:current_timestamp
to each row, showing the exact current timestamp, with no null orNaT
values.For the
date_plus_10_days
calculation:dateadd
function would add 10 days to the dates in theRECORD_CREATED_TS
column without any errors, accurately reflecting the new dates.5. What happened instead?
current_timestamp
addition:current_timestamp
unexpectedly includedNaT
values for rows whereROLE_NAME
was 'RL_TEST_ROLE_SUPPORT'.The following table illustrates the issue with the
CURRENT_TIMESTAMP
column, where one row unexpectedly contains aNaT
value:date_plus_10_days
calculation:numpy.core._exceptions._UFuncBinaryResolutionError: ufunc 'add' cannot use operands with types dtype('<M8[ns]') and dtype('O')
, indicating a problem with how data types are handled during date arithmetic in Snowpark.Additional Note:
The text was updated successfully, but these errors were encountered: