wnob commented on code in PR #3023:
URL: https://github.com/apache/calcite/pull/3023#discussion_r1074027016


##########
core/src/main/codegen/templates/Parser.jj:
##########
@@ -4609,15 +4610,116 @@ SqlLiteral DateTimeLiteral() :
     }
 |
     <DATE> { s = span(); } p = SimpleStringLiteral() {
-      return SqlParserUtil.parseDateLiteral(p, s.end(this));
+      return SqlLiteral.createUnknown("DATE", p, s.end(this));
+    }
+|
+    <DATETIME> { s = span(); } p = SimpleStringLiteral() {
+        return SqlLiteral.createUnknown("DATETIME", p, s.end(this));
     }
 |
     <TIME> { s = span(); } p = SimpleStringLiteral() {
-        return SqlParserUtil.parseTimeLiteral(p, s.end(this));
+      return SqlLiteral.createUnknown("TIME", p, s.end(this));
     }
 |
+    LOOKAHEAD(2)
     <TIMESTAMP> { s = span(); } p = SimpleStringLiteral() {
-        return SqlParserUtil.parseTimestampLiteral(p, s.end(this));
+        return SqlLiteral.createUnknown("TIMESTAMP", p, s.end(this));
+    }
+|
+    <TIMESTAMP> { s = span(); } <WITH> <LOCAL> <TIME> <ZONE> p = 
SimpleStringLiteral() {
+        return SqlLiteral.createUnknown("TIMESTAMP WITH LOCAL TIME ZONE", p, 
s.end(this));
+    }
+}
+
+/**
+ * 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);

Review Comment:
   If you look at the production for `FunctionParameterList()` you'll see it 
start like this:
   ```
   {
       <LPAREN>
       (
           qualifier = AllOrDistinct() { list.add(qualifier); }
       |
           { list.add(null); }
       )
       ...
   ```
   Here, `list` is the return value (`args` here in `DateFunctionCall()`). So 
the first argument is always either `null`, or either `ALL` or `DISTINCT`, 
since some functions can take those qualifiers. Here, it should always be 
`null`, although I suppose this means the parser would silently accept 
something like `DATE(DISTINCT 2023, 01, 18)`, which it probably shouldn't.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to