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
However, after transforming to the sqlgot IR, the function name could be mapped to its function name.
In this case, TIEMSTAMP_MILLIS will be transformed to UNIX_TO_TIME when the output dialect is None (used by our v3 API). If the output dialect is trino (used by our v2 API), it will be transformed to FROM_UNIXTIME(CAST(timestamp AS DOUBLE) / POW(10, 3)). After the v2 wren core planning, the function name will be transformed to TIEMSTAMP_SECONDS(CAST(timestamp AS DOUBLE) / POW(10, 3)), which function signature is wrong. TIMESTAMP_SECONDS only accepts INT64, but the result SQL tries to input a divided number (float64).
To Reproduce
Steps to reproduce the behavior:
For v2 case:
importsqlglotsql="""SELECT timestamp_millis(timestamp) from ask_question_traces"""ast=sqlglot.parse_one(sql, read="bigquery")
bq=ast.sql(dialect="trino")
result=sqlglot.transpile(bq, read="trino", write="bigquery")[0]
print(result)
The result is
SELECT TIMESTAMP_SECONDS(CAST(timestampAS FLOAT64) / POWER(10, 3)) FROM ask_question_traces
Describe the bug
When the model substitutes, we use sqlglot to transpile the dialect SQL to our dialect
wren-engine/ibis-server/app/mdl/substitute.py
Line 26 in 9c31174
However, after transforming to the sqlgot IR, the function name could be mapped to its function name.
In this case,
TIEMSTAMP_MILLIS
will be transformed toUNIX_TO_TIME
when the output dialect isNone
(used by our v3 API). If the output dialect istrino
(used by our v2 API), it will be transformed toFROM_UNIXTIME(CAST(timestamp AS DOUBLE) / POW(10, 3))
. After the v2 wren core planning, the function name will be transformed toTIEMSTAMP_SECONDS(CAST(timestamp AS DOUBLE) / POW(10, 3))
, which function signature is wrong.TIMESTAMP_SECONDS
only acceptsINT64
, but the result SQL tries to input a divided number (float64).To Reproduce
Steps to reproduce the behavior:
For v2 case:
The result is
For v3 case:
The result is
The v3 one is better. There is a only problem for
UNIX_TO_TIME
isn't included in our function lists.The text was updated successfully, but these errors were encountered: