We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Reproducible code:
import sqlglot sql = """select to_date(some_column, "yyyy-MM-dd) from df""" print(sqlglot.parse_one(sql, "spark").sql("snowflake"))
The output is:
SELECT TO_DATE(some_column, 'yyyy-mm-DD') FROM df
The problem is that the to_date() function behaves differently in Spark and in Snowflake. In Spark, it returns NULL if the input does not match the format provided. In Snowflake, it raises an error if the input does not match the format provided. The correct transpiled function in Snowflake should be TRY_TO_DATE(), which returns a NULL value instead of raising an error.
to_date()
TRY_TO_DATE()
The text was updated successfully, but these errors were encountered:
geooo109
Successfully merging a pull request may close this issue.
Reproducible code:
The output is:
The problem is that the
to_date()
function behaves differently in Spark and in Snowflake. In Spark, it returns NULL if the input does not match the format provided. In Snowflake, it raises an error if the input does not match the format provided. The correct transpiled function in Snowflake should beTRY_TO_DATE()
, which returns a NULL value instead of raising an error.The text was updated successfully, but these errors were encountered: