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 2021/07/01 19:50:19 UTC

[GitHub] [calcite] vlsi commented on a change in pull request #2435: [CALCITE-4642] Use TypeSystem from Config in Planner

vlsi commented on a change in pull request #2435:
URL: https://github.com/apache/calcite/pull/2435#discussion_r662551297



##########
File path: core/src/test/java/org/apache/calcite/tools/PlannerTest.java
##########
@@ -1525,4 +1527,67 @@ private void checkView(String sql, Matcher<String> matcher)
     final RelRoot root = planner.rel(validate);
     assertThat(toString(root.rel), matcher);
   }
+
+  /** Test case for <a href="https://issues.apache.org/jira/browse/CALCITE-4642">[CALCITE-4642]
+   * Checks that custom type systems can be registered in a planner by
+   * comparing options for converting unions of chars.</a>.
+   */
+  @Test void testCustomTypeSystem() throws Exception {
+    final String sql = "select Case when DEPTNO <> 30 then 'hi' else 'world' end from dept";
+    final String expectedVarying = "LogicalProject("
+        + "EXPR$0=["
+        + "CASE(<>($0, 30),"
+        + " 'hi':VARCHAR(5), "
+        + "'world':VARCHAR(5))])\n"
+        + "  LogicalValues("
+        + "tuples=[[{ 10, 'Sales' },"
+        + " { 20, 'Marketing' },"
+        + " { 30, 'Engineering' },"
+        + " { 40, 'Empty' }]])\n";
+    final String expectedDefault = "LogicalProject("
+        + "EXPR$0=["
+        + "CASE(<>($0, 30),"
+        + " 'hi   ', "
+        + "'world')])\n"
+        + "  LogicalValues("
+        + "tuples=[[{ 10, 'Sales      ' },"
+        + " { 20, 'Marketing  ' },"
+        + " { 30, 'Engineering' },"
+        + " { 40, 'Empty      ' }]])\n";

Review comment:
       ```suggestion
       final String expectedDefault = ""
           + "LogicalProject(EXPR$0=[CASE(<>($0, 30), 'hi   ', 'world')])\n"
           + "  LogicalValues(tuples=[[{ 10, 'Sales      ' }, { 20, 'Marketing  ' }, { 30, 'Engineering' }, { 40, 'Empty      ' }]])\n";
   ```

##########
File path: core/src/test/java/org/apache/calcite/tools/PlannerTest.java
##########
@@ -1525,4 +1527,67 @@ private void checkView(String sql, Matcher<String> matcher)
     final RelRoot root = planner.rel(validate);
     assertThat(toString(root.rel), matcher);
   }
+
+  /** Test case for <a href="https://issues.apache.org/jira/browse/CALCITE-4642">[CALCITE-4642]
+   * Checks that custom type systems can be registered in a planner by
+   * comparing options for converting unions of chars.</a>.
+   */
+  @Test void testCustomTypeSystem() throws Exception {
+    final String sql = "select Case when DEPTNO <> 30 then 'hi' else 'world' end from dept";
+    final String expectedVarying = "LogicalProject("
+        + "EXPR$0=["
+        + "CASE(<>($0, 30),"
+        + " 'hi':VARCHAR(5), "
+        + "'world':VARCHAR(5))])\n"
+        + "  LogicalValues("
+        + "tuples=[[{ 10, 'Sales' },"
+        + " { 20, 'Marketing' },"
+        + " { 30, 'Engineering' },"
+        + " { 40, 'Empty' }]])\n";

Review comment:
       ```suggestion
       final String expectedVarying = ""
           + "LogicalProject(EXPR$0=[CASE(<>($0, 30), 'hi':VARCHAR(5), 'world':VARCHAR(5))])\n"
           + "  LogicalValues(tuples=[[{ 10, 'Sales' }, { 20, 'Marketing' }, { 30, 'Engineering' }, { 40, 'Empty' }]])\n";
   ```




-- 
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-unsubscribe@calcite.apache.org

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