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 2022/03/29 19:30:52 UTC

[GitHub] [calcite] julianhyde commented on a change in pull request #2757: [CALCITE-4401] SqlJoin toString throws RuntimeException

julianhyde commented on a change in pull request #2757:
URL: https://github.com/apache/calcite/pull/2757#discussion_r837840272



##########
File path: core/src/test/java/org/apache/calcite/sql/test/SqlPrettyWriterTest.java
##########
@@ -438,6 +441,30 @@ private SqlPrettyWriterFixture tableDotStar() {
         .check();
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-4401">[CALCITE-4401]
+   * SqlJoin toString throws RuntimeException</a>. */
+  @Test void testJoinClauseToString() throws SqlParseException {
+    final String sql = "SELECT t.region_name, t0.o_totalprice\n"
+        + "FROM (SELECT c_custkey, region_name\n"
+        + "FROM tpch.out_tpch_vw__customer) AS t\n"
+        + "INNER JOIN (SELECT o_custkey, o_totalprice\n"
+        + "FROM tpch.out_tpch_vw__orders) AS t0 ON t.c_custkey = t0.o_custkey";
+
+    final SqlNode node = SqlParser.create(sql).parseQuery();
+    final SqlSelect select = (SqlSelect) node;
+    final SqlJoin join = (SqlJoin) select.getFrom();
+
+    final String expectedJoinString = "SELECT *\r\n"
+        + "FROM (SELECT `C_CUSTKEY`, `REGION_NAME`\r\n"
+        + "FROM `TPCH`.`OUT_TPCH_VW__CUSTOMER`) AS `T`\r\n"
+        + "INNER JOIN (SELECT `O_CUSTKEY`, `O_TOTALPRICE`\r\n"
+        + "FROM `TPCH`.`OUT_TPCH_VW__ORDERS`) AS `T0` ON `T`.`C_CUSTKEY` = `T0`.`O_CUSTKEY`";
+
+    assert join != null;
+    Assertions.assertEquals(join.toString(), expectedJoinString);
+  }
+

Review comment:
       Please use the fixture, to be consistent with other methods in this test.




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