-
Notifications
You must be signed in to change notification settings - Fork 983
support: no param function: localtime #5982
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
base: main
Are you sure you want to change the base?
support: no param function: localtime #5982
Conversation
What dialect supports |
we need to test for all the dialect present in sqlglot? as i only tested for 11 and from that i found these support it. |
We generally want to test the most common dialects, i.e.:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests for this PR:
- For the dialects that don't support
LOCALTIME
, we should test thatSELECT localtime
roundtrips without being changed & thatselects[0].assert_is(exp.Column)
- For the dialects that support it,
LOCALTIME
should roundtrip to the supported syntax. You may need to add logic in the generator for rewriting it toLOCALTIME
instead ofLOCALTIME()
which is the default.
arg_types = {"this": False} | ||
|
||
|
||
class LocalTime(Func): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Func
subclass names have implicit semantics. If you do LocalTime
, that means the parser will recognize and produce this expression for LOCAL_TIME
, not LOCALTIME
.
class LocalTime(Func): | |
class Localtime(Func): |
"LIMIT": TokenType.LIMIT, | ||
"LOAD": TokenType.LOAD, | ||
"LOCK": TokenType.LOCK, | ||
"LOCALTIME": TokenType.LOCALTIME, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should pop this token off of KEYWORDS
for BigQuery, ClickHouse, Hive (affects Spark2, Spark, Databricks– which is correct), Oracle, Redshift, T-SQL. Otherwise, we'll incorrectly produce a Localtime
node instead of a Column
. See this comment.
This PR enriches the AST by adding proper support for parsing LOCALTIME as a dedicated expression node instead of treating it as a column.
SQL:
Previously:
Now: