NobiGo commented on code in PR #4405:
URL: https://github.com/apache/calcite/pull/4405#discussion_r2157844644
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -8772,6 +8772,64 @@ private void checkLiteral2(String expression, String
expected) {
.withOracle(11).ok(expectedVersionLow1);
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5583">[CALCITE-5583]
+ * Rel2Sql will get an error when select * and join is present</a>. */
+ @Test void testSelectStarWithJoinOn() {
+ final String sql = "SELECT * FROM \"DEPT\" t1 "
+ + "LEFT JOIN (SELECT * FROM (SELECT DEPTNO AS c0 FROM \"DEPT\") t "
+ + "INNER JOIN (SELECT DEPTNO AS c0 FROM \"DEPT\") t0 ON t.c0 = t0.c0)
t2 "
+ + "ON t1.DEPTNO = t2.c0";
+ final String expectedPostgres = "SELECT *\n"
+ + "FROM \"SCOTT\".\"DEPT\"\n"
+ + "LEFT JOIN (SELECT \"t\".\"C0\", \"t0\".\"C0\" AS \"C00\"\n"
+ + "FROM (SELECT \"DEPTNO\" AS \"C0\"\n"
+ + "FROM \"SCOTT\".\"DEPT\") AS \"t\"\n"
+ + "INNER JOIN (SELECT \"DEPTNO\" AS \"C0\"\n"
+ + "FROM \"SCOTT\".\"DEPT\") AS \"t0\""
+ + " ON \"t\".\"C0\" = \"t0\".\"C0\") AS \"t1\""
+ + " ON \"DEPT\".\"DEPTNO\" = \"t1\".\"C0\"";
+ sql(sql)
+ .schema(CalciteAssert.SchemaSpec.JDBC_SCOTT)
+ .withPostgresql().ok(expectedPostgres);
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5583">[CALCITE-5583]
+ * Rel2Sql will get an error when select * and join is present</a>. */
+ @Test void testSelectStarWithJoinUsing() {
+ final String sql = "select * from EMP JOIN DEPT USING (DEPTNO)";
+ final String expectedPostgres = ""
+ + "SELECT COALESCE(\"EMP\".\"DEPTNO\", \"DEPT\".\"DEPTNO\") AS
\"DEPTNO\", "
+ + "\"EMP\".\"EMPNO\", \"EMP\".\"ENAME\", \"EMP\".\"JOB\",
\"EMP\".\"MGR\", "
+ + "\"EMP\".\"HIREDATE\", \"EMP\".\"SAL\", \"EMP\".\"COMM\",
\"DEPT\".\"DNAME\", "
+ + "\"DEPT\".\"LOC\"\n"
+ + "FROM \"SCOTT\".\"EMP\"\n"
+ + "INNER JOIN \"SCOTT\".\"DEPT\" "
+ + "ON \"EMP\".\"DEPTNO\" = \"DEPT\".\"DEPTNO\"";
+ sql(sql)
+ .schema(CalciteAssert.SchemaSpec.JDBC_SCOTT)
+ .withPostgresql().ok(expectedPostgres);
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5583">[CALCITE-5583]
+ * Rel2Sql will get an error when select * and join is present</a>. */
+ @Test void testSelectStarWithJoinNatural() {
Review Comment:
This is an invalid test case. Regardless of whether this PR exists or not,
it can still be executed successfully.
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -8772,6 +8772,64 @@ private void checkLiteral2(String expression, String
expected) {
.withOracle(11).ok(expectedVersionLow1);
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5583">[CALCITE-5583]
+ * Rel2Sql will get an error when select * and join is present</a>. */
+ @Test void testSelectStarWithJoinOn() {
+ final String sql = "SELECT * FROM \"DEPT\" t1 "
+ + "LEFT JOIN (SELECT * FROM (SELECT DEPTNO AS c0 FROM \"DEPT\") t "
+ + "INNER JOIN (SELECT DEPTNO AS c0 FROM \"DEPT\") t0 ON t.c0 = t0.c0)
t2 "
+ + "ON t1.DEPTNO = t2.c0";
+ final String expectedPostgres = "SELECT *\n"
+ + "FROM \"SCOTT\".\"DEPT\"\n"
+ + "LEFT JOIN (SELECT \"t\".\"C0\", \"t0\".\"C0\" AS \"C00\"\n"
+ + "FROM (SELECT \"DEPTNO\" AS \"C0\"\n"
+ + "FROM \"SCOTT\".\"DEPT\") AS \"t\"\n"
+ + "INNER JOIN (SELECT \"DEPTNO\" AS \"C0\"\n"
+ + "FROM \"SCOTT\".\"DEPT\") AS \"t0\""
+ + " ON \"t\".\"C0\" = \"t0\".\"C0\") AS \"t1\""
+ + " ON \"DEPT\".\"DEPTNO\" = \"t1\".\"C0\"";
+ sql(sql)
+ .schema(CalciteAssert.SchemaSpec.JDBC_SCOTT)
+ .withPostgresql().ok(expectedPostgres);
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5583">[CALCITE-5583]
+ * Rel2Sql will get an error when select * and join is present</a>. */
+ @Test void testSelectStarWithJoinUsing() {
Review Comment:
This is an invalid test case. Regardless of whether this PR exists or not,
it can still be executed successfully. Unless it is specified exactly what this
test case is testing
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -8772,6 +8772,64 @@ private void checkLiteral2(String expression, String
expected) {
.withOracle(11).ok(expectedVersionLow1);
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-5583">[CALCITE-5583]
+ * Rel2Sql will get an error when select * and join is present</a>. */
+ @Test void testSelectStarWithJoinOn() {
+ final String sql = "SELECT * FROM \"DEPT\" t1 "
Review Comment:
Can this SQL be executed directly in PG?
##########
core/src/main/java/org/apache/calcite/sql/SqlDialect.java:
##########
@@ -797,6 +797,11 @@ public boolean supportBooleanCaseWhen() {
return true;
}
+ /** Returns whether this dialect supports generate 'SELECT *' when duplicate
field names. */
+ public boolean supportGenerateSelectStar() {
Review Comment:
The comment for this method is somewhat ambiguous. From an implementation
perspective, it is not solely controlled by this 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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]