You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make sure you specify the "read" dialect eg. parse_one(sql, read="spark")
Make sure you specify the "write" dialect eg. ast.sql(dialect="duckdb")
Check if the issue still exists on main
✅
Fully reproducible code snippet
Please include a fully reproducible code snippet or the input sql, dialect, and expected output.
fromsqlglotimportparse_onesf_query="""SELECT TO_CHAR(RAW_ORDERS."ORDER_DATE", 'YYYY-MM') AS ORDER_YEAR_MONTHFROM DEVELOPER.SCHEMA.RAW_ORDERS AS RAW_ORDERS"""sf_query=parse_one(query, dialect="snowflake")
duckdb_query=sf_query.sql(dialect="duckdb", pretty=True)
Expected output
SELECT
STRFTIME(RAW_ORDERS."ORDER_DATE", '%Y-%m') AS ORDER_YEAR_MONTH
FROMDEVELOPER.SCHEMA.RAW_ORDERS AS RAW_ORDERS
Actual output
SELECT
CAST(RAW_ORDERS."ORDER_DATE"ASTEXT) AS ORDER_YEAR_MONTH
FROMDEVELOPER.SCHEMA.RAW_ORDERS AS RAW_ORDERS
The ORDER_DATE column is a timestamp.
Happy to provide more info as needed. This might be quite challenging since TO_CHAR is quite flexible, but the usage patterns for timestamp conversions are fairly small.
Before you file an issue
parse_one(sql, read="spark")
ast.sql(dialect="duckdb")
✅
Fully reproducible code snippet
Please include a fully reproducible code snippet or the input sql, dialect, and expected output.
Expected output
Actual output
The ORDER_DATE column is a timestamp.
Happy to provide more info as needed. This might be quite challenging since TO_CHAR is quite flexible, but the usage patterns for timestamp conversions are fairly small.
https://docs.snowflake.com/en/sql-reference/functions/to_char
https://duckdb.org/docs/stable/sql/functions/dateformat.html
The text was updated successfully, but these errors were encountered: