beyond1920 commented on code in PR #2844:
URL: https://github.com/apache/calcite/pull/2844#discussion_r913086886


##########
core/src/main/codegen/templates/Parser.jj:
##########
@@ -1653,6 +1657,108 @@ SqlNode NamedRoutineCall(
     }
 }
 
+/**
+ * Table parameter of a table function.
+ * The input table with set semantics may be partitioned/ordered on one or 
more columns.
+ */
+SqlNode TableArg() :
+{
+    final Span s;
+    SqlNode tableRef;
+    SqlNodeList partitionList = SqlNodeList.EMPTY;
+    SqlNodeList orderList = SqlNodeList.EMPTY;
+}
+{
+    { s = span(); }
+    tableRef = ExplicitTable(getPos())
+    [
+        <PARTITION> <BY>
+        partitionList = SimpleIdentifierOrList()
+    ]
+    [
+        orderList = OrderByInTableParam()
+    ]
+    {
+        if (partitionList.isEmpty() && orderList.isEmpty()) {
+          return tableRef;
+        } else {
+          return SqlStdOperatorTable.SET_SEMANTICS_TABLE.createCall(
+              s.pos(), tableRef, partitionList, orderList);
+        }
+    }
+}
+
+SqlNode PartitionedQueryOrQueryOrExpr(ExprContext exprContext) :
+{
+    SqlNode e;
+}
+{
+    e = OrderedQueryOrExpr(exprContext)
+    e = PartitionedByAndOrderBy(e)
+
+    { return e; }
+}
+
+SqlNode PartitionedByAndOrderBy(SqlNode e):
+{
+    final Span s;
+    SqlNodeList partitionList = SqlNodeList.EMPTY;
+    SqlNodeList orderList = SqlNodeList.EMPTY;
+}

Review Comment:
   The code could not be reused here because partition by clause and order by 
clause are different  from the partition by clause and order by clause in some 
other contexts. 
   Test cases could cover these cases.
   Based on the SQL standard, Order by clause of Polymorphic table function is 
different from other order by clause.
   The list of order keys must be parenthesized if more than one column is 
listed.
   Similarly, PARTITION BY clause with a list of zero or more columns. The list 
can always be enclosed in parentheses. If there is only one partitioning 
column, then the parentheses are optional.



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