Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sqlglot/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6100,6 +6100,10 @@ class CurrentUser(Func):
arg_types = {"this": False}


class LocalTime(Func):
Copy link
Collaborator

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.

Suggested change
class LocalTime(Func):
class Localtime(Func):

arg_types = {"this": False}


class UtcDate(Func):
arg_types = {}

Expand Down
1 change: 1 addition & 0 deletions sqlglot/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class Parser(metaclass=_Parser):
TokenType.CURRENT_TIME: exp.CurrentTime,
TokenType.CURRENT_TIMESTAMP: exp.CurrentTimestamp,
TokenType.CURRENT_USER: exp.CurrentUser,
TokenType.LOCALTIME: exp.LocalTime,
}

STRUCT_TYPE_TOKENS = {
Expand Down
2 changes: 2 additions & 0 deletions sqlglot/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class TokenType(AutoName):
CURRENT_SCHEMA = auto()
CURRENT_TIME = auto()
CURRENT_TIMESTAMP = auto()
LOCALTIME = auto()
CURRENT_USER = auto()
DECLARE = auto()
DEFAULT = auto()
Expand Down Expand Up @@ -799,6 +800,7 @@ class Tokenizer(metaclass=_Tokenizer):
"LIMIT": TokenType.LIMIT,
"LOAD": TokenType.LOAD,
"LOCK": TokenType.LOCK,
"LOCALTIME": TokenType.LOCALTIME,
Copy link
Collaborator

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.

"MERGE": TokenType.MERGE,
"NAMESPACE": TokenType.NAMESPACE,
"NATURAL": TokenType.NATURAL,
Expand Down