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



##########
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:
       I think you will need to extend the fixture.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to