[
https://issues.apache.org/jira/browse/CALCITE-7343?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mihai Budiu resolved CALCITE-7343.
----------------------------------
Fix Version/s: 1.42.0
Resolution: Fixed
Fixed in
[https://github.com/apache/calcite/commit/607126846b12348beae54bbcbb7d1f8ea4a44a0d]
Thank you for the bug report [~nobigo]
Thank you for the fix [~krooswu]
Thank you for the review [~jensen]
> RelToSqlConverter generate wrong sql when scalar correlated sub-query in
> Project
> --------------------------------------------------------------------------------
>
> Key: CALCITE-7343
> URL: https://issues.apache.org/jira/browse/CALCITE-7343
> Project: Calcite
> Issue Type: Bug
> Reporter: xiong duan
> Assignee: krooswu
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.42.0
>
>
> The unit test in RelToSqlConverterTest:
> {code:java}
> @Test void testProjectScalarSubquery() {
> final String sql = "SELECT \"EMPNO\", (SELECT COUNT(*) AS \"c\"\n" +
> "FROM \"EMP\"\n" +
> "WHERE \"MGR\" < \"t\".\"MGR\") AS \"$f1\"\n" +
> "FROM \"EMP\" as \"t\"\n" +
> "WHERE \"SAL\" > 10";
> final String expected = "SELECT \"EMPNO\", (SELECT COUNT(*) AS \"c\"\n" +
> "FROM \"SCOTT\".\"EMP\"\n" +
> "WHERE \"MGR\" < \"t\".\"MGR\") AS \"$f1\"\n" +
> "FROM \"SCOTT\".\"EMP\"\n" +
> "WHERE CAST(\"SAL\" AS DECIMAL(12, 2)) > 10.00";
> sql(sql)
> .schema(CalciteAssert.SchemaSpec.JDBC_SCOTT)
> .withCalcite()
> .ok(expected);
> } {code}
> The expected Sql should be:
> {code:java}
> final String expected = "SELECT \"EMPNO\", (SELECT COUNT(*) AS \"c\"\n" +
> "FROM \"SCOTT\".\"EMP\"\n" +
> "WHERE \"MGR\" < \"t\".\"MGR\") AS \"$f1\"\n" +
> "FROM \"SCOTT\".\"EMP\" as \"t\"\n" +
> "WHERE CAST(\"SAL\" AS DECIMAL(12, 2)) > 10.00"; {code}
> "SCOTT"."EMP" should have the alias t.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)