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 2020/01/20 09:07:57 UTC

[GitHub] [calcite] vlsi commented on a change in pull request #1593: [CALCITE-3513] Unify TableFunction implementor's NullPolicy and its behavior

vlsi commented on a change in pull request #1593: [CALCITE-3513] Unify TableFunction implementor's NullPolicy and its behavior
URL: https://github.com/apache/calcite/pull/1593#discussion_r368433347
 
 

 ##########
 File path: core/src/test/java/org/apache/calcite/test/TableFunctionTest.java
 ##########
 @@ -487,6 +487,47 @@ private Connection getConnectionWithMultiplyFunction() throws SQLException {
       assertThat(CalciteAssert.toString(resultSet), equalTo(expected));
     }
   }
+
+  /**
+   * Test of a table function that produces null.
+   */
+  @Test public void testNullContentTableFunction() throws SQLException {
+    try (Connection connection = DriverManager.getConnection("jdbc:calcite:")) {
+      CalciteConnection calciteConnection =
+          connection.unwrap(CalciteConnection.class);
+      SchemaPlus rootSchema = calciteConnection.getRootSchema();
+      SchemaPlus schema = rootSchema.add("s", new AbstractSchema());
+      final TableFunction table =
+          TableFunctionImpl.create(Smalls.NULL_PRODUCED_METHOD);
+      schema.add("generate", table);
+
+      final String sql1 = "select *\n"
+          + "from table(\"s\".\"generate\"(1, 2))";
+      ResultSet resultSet = connection.createStatement().executeQuery(sql1);
+      final String expected1 = "S=abcde\n"
+          + "S=xyz\n"
+          + "S=generate(x=1, y=2)\n";
+      assertThat(CalciteAssert.toString(resultSet), equalTo(expected1));
+
+      final String sql2 = "select *\n"
+          + "from table(\"s\".\"generate\"(1, 1))";
+      resultSet = connection.createStatement().executeQuery(sql2);
+      final String expected2 =  "S=abcde\n"
+          + "S=xyz\n"
+          + "S=null\n";
+      assertThat(CalciteAssert.toString(resultSet), equalTo(expected2));
+
+      final String sql3 = "select *\n"
 
 Review comment:
   @DonnyZone , can you please document that? (or even factor that to its own test method)

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