You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/03/14 02:38:38 UTC

[GitHub] [calcite] julianhyde commented on a change in pull request #1102: [CALCITE-1515] RelBuilder supports creating TableFunctionScan

julianhyde commented on a change in pull request #1102: [CALCITE-1515] RelBuilder supports creating TableFunctionScan
URL: https://github.com/apache/calcite/pull/1102#discussion_r265401998
 
 

 ##########
 File path: core/src/test/java/org/apache/calcite/test/RelBuilderTest.java
 ##########
 @@ -298,6 +298,23 @@
     assertThat(root, hasTree(expected));
   }
 
+  @Test public void testTableFunctionScan() {
+    // Equivalent SQL:
+    //   SELECT *
+    //   FROM TABLE(DEDUP(CURSOR(select * from emp), CURSOR(select * from DEPT), 'NAME'))
+    final RelBuilder builder = RelBuilder.create(config().build());
+    RelNode root = builder.scan("EMP").scan("DEPT")
+        .functionScan(new MockSqlOperatorTable.DedupFunction(),
+            Lists.newArrayList(builder.cursor(0),
+                builder.cursor(1))).build();
+    final String expected = "LogicalTableFunctionScan(invocation="
+        + "[DEDUP(CURSOR($0), CURSOR($1))], "
+        + "rowType=[RecordType(VARCHAR(1024) NAME)])\n"
+        + "  LogicalTableScan(table=[[scott, EMP]])\n"
+        + "  LogicalTableScan(table=[[scott, DEPT]])\n";
+    assertThat(root, hasTree(expected));
+  }
 
 Review comment:
   Add an assert that builder's stack is now empty. (functionScan should have popped both the EMP and DEPT scans, though I suspect it doesn't currently.)
   
   I think the best way to check is to call builder.build() and make sure that it throws. Or perhaps call builder.toString(), and make sure that it is empty.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services