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-1569842: to_date() function requires column name for the optional fmt parameter #2018

Open
padhia opened this issue Aug 1, 2024 · 2 comments
Assignees
Labels
feature New feature or request status-triage_done Initial triage done, will be further handled by the driver team

Comments

@padhia
Copy link

padhia commented Aug 1, 2024

What is the current behavior?

to_date() function signature seems to indicate that only Column names are accepted for the optional fmt parameter

What is the desired behavior?

to_date() function should accept string literals in addition to column names

How would this improve snowflake-snowpark-python?

Feature parity with SQL

References, Other Background

https://docs.snowflake.com/en/sql-reference/functions/to_date#arguments

@padhia padhia added the feature New feature or request label Aug 1, 2024
@github-actions github-actions bot changed the title to_date() function requires column name for the optional fmt parameter SNOW-1569842: to_date() function requires column name for the optional fmt parameter Aug 1, 2024
@sfc-gh-sghosh sfc-gh-sghosh self-assigned this Aug 14, 2024
@sfc-gh-sghosh
Copy link

Hello @padhia ,

Thanks for raising the concern.
In Snowpark functions, all parameters are via column name only, applicable to all snowpark functions.
If you want to pass direct string literals values to to_date, you can try using SQL expression, example

`
df = session.create_dataframe([("2021-07-01",)], schema=["date_string"])

df = df.select(expr("TO_DATE('2021-07-01')").alias("converted_date"))

result = df.collect()
for row in result:
print(row)`

Regards,
Sujan

@sfc-gh-sghosh sfc-gh-sghosh added the status-triage_done Initial triage done, will be further handled by the driver team label Aug 14, 2024
@padhia
Copy link
Author

padhia commented Aug 14, 2024

Hello Sujan,

Thank you for getting back. My comment was intended for the second parameter, the format specification. It's almost always the case that the format to convert to is already known. It'd therefore be convenient for the second parameter of the function to be a string literal rather than a Column specification, which requires one to use functions.lit to transform a simple literal string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

2 participants