chucheng92 commented on code in PR #3459:
URL: https://github.com/apache/calcite/pull/3459#discussion_r1349646120


##########
core/src/main/codegen/templates/Parser.jj:
##########
@@ -4886,14 +4886,21 @@ SqlNode MapConstructor() :
 {
     <MAP> { s = span(); }
     (
-        LOOKAHEAD(1)
-        <LPAREN>
-        // by sub query "MAP (SELECT empno, deptno FROM emp)"
-        e = LeafQueryOrExpr(ExprContext.ACCEPT_QUERY)
-        <RPAREN>
+        (
+            // empty map function call: "map()"
+            LOOKAHEAD(2)
+            <LPAREN> <RPAREN> { args = SqlNodeList.EMPTY; }
+        |
+            args = ParenthesizedQueryOrCommaList(ExprContext.ACCEPT_ALL)
+        )
         {
-            return SqlStdOperatorTable.MAP_QUERY.createCall(
-                s.end(this), e);
+            if (args.size() == 1 && args.get(0).isA(SqlKind.QUERY)) {
+                // MAP query constructor e.g. "MAP (SELECT empno, deptno FROM 
emps)"
+                return SqlStdOperatorTable.MAP_QUERY.createCall(s.end(this), 
args.get(0));
+            } else {
+                // MAP function e.g. "MAP(1, 2)" equivalent to standard 
"MAP[1, 2]"
+                return SqlLibraryOperators.MAP.createCall(s.end(this), 
args.getList());

Review Comment:
   I hope to retain the original parser logic here, because it will be detected 
later on OperandTypeChecker. And here is similar with Array handling. pls see: 
https://github.com/apache/calcite/pull/3141/files



-- 
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