ILuffZhe commented on code in PR #4130:
URL: https://github.com/apache/calcite/pull/4130#discussion_r1908049361


##########
core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java:
##########
@@ -127,15 +127,15 @@ class JdbcAdapterTest {
             + "      JdbcFilter(condition=[<($0, 10)])\n"
             + "        JdbcTableScan(table=[[foodmart, store]])\n"
             + "  JdbcToEnumerableConverter\n"
-            + "    JdbcProject(EXPR$0=[CAST($1):VARCHAR(30)])\n"
+            + "    JdbcProject(ENAME=[CAST($1):VARCHAR(30)])\n"
             + "      JdbcFilter(condition=[>(CAST($0):INTEGER NOT NULL, 
10)])\n"
             + "        JdbcTableScan(table=[[SCOTT, EMP]])")
         .runs()
         .enable(CalciteAssert.DB == CalciteAssert.DatabaseInstance.HSQLDB)
         .planHasSql("SELECT \"store_name\"\n"
                 + "FROM \"foodmart\".\"store\"\n"
                 + "WHERE \"store_id\" < 10")
-        .planHasSql("SELECT CAST(\"ENAME\" AS VARCHAR(30))\n"
+        .planHasSql("SELECT CAST(\"ENAME\" AS VARCHAR(30)) AS \"ENAME\"\n"

Review Comment:
   What if there are duplicate `ENAME` in this case? Will the 2nd `ENAME` be 
`ENAME0`?



##########
core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java:
##########
@@ -257,6 +257,15 @@ public static void checkActualAndReferenceFiles() {
     sql(sql).ok();
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6770";>[CALCITE-6770]
+   * Preserve column names when casts are inserted in projects</a>. */
+  @Test void testCastNames() {
+    final String sql = "SELECT * FROM (SELECT empno, 'x' AS X FROM emp) "
+        + "UNION ALL (SELECT empno, 'xx' AS X from EMP)";

Review Comment:
   from `emp`?



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