UNIX_TIMESTAMP is not being transpiled from MySQL to DuckDB.
It remains UNIX_TIMESTAMP, but I expected it to be converted to EPOCH.
Fully reproducible code snippet
import sqlglot
import duckdb
# UNIX_TIMESTAMP is MySQL-specific; transpiling to DuckDB should produce EPOCH(...)
mysql_sql = "SELECT UNIX_TIMESTAMP(NOW())"
transpiled = sqlglot.transpile(mysql_sql, read="mysql", write="duckdb")[0]
print("Transpiled:", transpiled)
# Try to run the transpiled SQL in DuckDB
duckdb.sql(transpiled)
expected results:
Transpiled: SELECT EPOCH(NOW())
Actual results:
Transpiled: SELECT UNIX_TIMESTAMP(NOW())
Traceback (most recent call last):
File "/home/marko/repos/a.py", line 10, in <module>
duckdb.sql(transpiled)
~~~~~~~~~~^^^^^^^^^^^^
_duckdb.CatalogException: Catalog Error: Scalar Function with name unix_timestamp does not exist!
Did you mean "to_timestamp"?
Official Documentation
Please include links to official SQL documentation related to your issue.
https://duckdb.org/docs/current/sql/functions/timestamp
https://dev.mysql.com/doc/refman/9.7/en/date-and-time-functions.html#function_unix-timestamp
UNIX_TIMESTAMPis not being transpiled from MySQL to DuckDB.It remains
UNIX_TIMESTAMP, but I expected it to be converted toEPOCH.Fully reproducible code snippet
expected results:
Actual results:
Official Documentation
Please include links to official SQL documentation related to your issue.
https://duckdb.org/docs/current/sql/functions/timestamp
https://dev.mysql.com/doc/refman/9.7/en/date-and-time-functions.html#function_unix-timestamp