-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[CALCITE-5180] Implement BigQuery Date/Time Type Aliases and Constructors #3023
Changes from 1 commit
e367528
317616a
19f3ba6
5462e24
e90e43e
66408dc
14151c5
e863784
eb281b1
6e5b2f2
379ac33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4034,6 +4034,7 @@ SqlNode AtomicRowExpression() : | |
} | ||
{ | ||
( | ||
LOOKAHEAD(2) | ||
e = LiteralOrIntervalExpression() | ||
| | ||
e = DynamicParam() | ||
|
@@ -4630,6 +4631,98 @@ SqlLiteral DateTimeLiteral() : | |
} | ||
} | ||
|
||
/** | ||
* Parses BigQuery's built-in DATE() function. | ||
*/ | ||
SqlNode DateFunctionCall() : | ||
{ | ||
final SqlFunctionCategory funcType = SqlFunctionCategory.TIMEDATE; | ||
final SqlIdentifier qualifiedName; | ||
final Span s; | ||
final SqlLiteral quantifier; | ||
final List<? extends SqlNode> args; | ||
} | ||
{ | ||
<DATE> { | ||
s = span(); | ||
qualifiedName = new SqlIdentifier(unquotedIdentifier(), getPos()); | ||
} | ||
args = FunctionParameterList(ExprContext.ACCEPT_SUB_QUERY) { | ||
quantifier = (SqlLiteral) args.get(0); | ||
args.remove(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this line doing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you look at the production for
Here, |
||
return createCall(qualifiedName, s.end(this), funcType, quantifier, args); | ||
} | ||
} | ||
|
||
/** | ||
* Parses BigQuery's built-in DATETIME() function. | ||
*/ | ||
SqlNode DatetimeFunctionCall() : | ||
{ | ||
final SqlFunctionCategory funcType = SqlFunctionCategory.TIMEDATE; | ||
final SqlIdentifier qualifiedName; | ||
final Span s; | ||
final SqlLiteral quantifier; | ||
final List<? extends SqlNode> args; | ||
} | ||
{ | ||
<DATETIME> { | ||
s = span(); | ||
qualifiedName = new SqlIdentifier(unquotedIdentifier(), getPos()); | ||
} | ||
args = FunctionParameterList(ExprContext.ACCEPT_SUB_QUERY) { | ||
quantifier = (SqlLiteral) args.get(0); | ||
args.remove(0); | ||
return createCall(qualifiedName, s.end(this), funcType, quantifier, args); | ||
} | ||
} | ||
|
||
/** | ||
* Parses BigQuery's built-in TIMESTAMP() function. | ||
*/ | ||
SqlNode TimestampFunctionCall() : | ||
{ | ||
final SqlFunctionCategory funcType = SqlFunctionCategory.TIMEDATE; | ||
final SqlIdentifier qualifiedName; | ||
final Span s; | ||
final SqlLiteral quantifier; | ||
final List<? extends SqlNode> args; | ||
} | ||
{ | ||
<TIMESTAMP> { | ||
s = span(); | ||
qualifiedName = new SqlIdentifier(unquotedIdentifier(), getPos()); | ||
} | ||
args = FunctionParameterList(ExprContext.ACCEPT_SUB_QUERY) { | ||
quantifier = (SqlLiteral) args.get(0); | ||
args.remove(0); | ||
return createCall(qualifiedName, s.end(this), funcType, quantifier, args); | ||
} | ||
} | ||
|
||
/** | ||
* Parses BigQuery's built-in TIME() function. | ||
*/ | ||
SqlNode TimeFunctionCall() : | ||
{ | ||
final SqlFunctionCategory funcType = SqlFunctionCategory.TIMEDATE; | ||
final SqlIdentifier qualifiedName; | ||
final Span s; | ||
final SqlLiteral quantifier; | ||
final List<? extends SqlNode> args; | ||
} | ||
{ | ||
<TIME> { | ||
s = span(); | ||
qualifiedName = new SqlIdentifier(unquotedIdentifier(), getPos()); | ||
} | ||
args = FunctionParameterList(ExprContext.ACCEPT_SUB_QUERY) { | ||
quantifier = (SqlLiteral) args.get(0); | ||
args.remove(0); | ||
return createCall(qualifiedName, s.end(this), funcType, quantifier, args); | ||
} | ||
} | ||
|
||
/** Parses a MULTISET constructor */ | ||
SqlNode MultisetConstructor() : | ||
{ | ||
|
@@ -6044,6 +6137,14 @@ SqlNode BuiltinFunctionCall() : | |
<RPAREN> { | ||
return SqlStdOperatorTable.TRIM.createCall(s.end(this), args); | ||
} | ||
| | ||
node = DateFunctionCall() { return node; } | ||
| | ||
node = DatetimeFunctionCall() { return node; } | ||
| | ||
node = TimeFunctionCall() { return node; } | ||
| | ||
node = TimestampFunctionCall() { return node; } | ||
| | ||
node = TimestampAddFunctionCall() { return node; } | ||
| | ||
|
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.
there's a set of DATETIME tests currently disabled around line 650 btw
calcite/babel/src/test/resources/sql/big-query.iq
Line 649 in 6e5b2f2