[ 
https://issues.apache.org/jira/browse/CALCITE-7483?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated CALCITE-7483:
------------------------------------
    Labels: pull-request-available  (was: )

> RelToSqlConverter generates SELECT * despite supportGenerateSelectStar
> ----------------------------------------------------------------------
>
>                 Key: CALCITE-7483
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7483
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.41.0
>            Reporter: Alessandro Solimando
>            Assignee: Alessandro Solimando
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.42.0
>
>
> _SqlDialect.supportGenerateSelectStar(RelNode)_ is only checked inside 
> {_}RelToSqlConverter.visit(Project){_}, ignored anywhere else, so _SELECT *_ 
> can still be produced in the output SQL.
> The flag was introduced in CALCITE-5583 but its scope was limited to the 
> _visit(Project)_ path, and it currently only set for 
> {_}PostgresqlSqlDialect{_}, but only for joins with duplicate field names. 
> There won't be any change for Postgres, the proposed change is for custom 
> dialects trying to prevent _SELECT *_ generation more broadly.
> This is a minimal reproducer for {_}RelToSqlConverterTest{_}:
> {code:java}
> @Test void testNoSelectStarWithFilterOnly() {
>     final SqlDialect noStarDialect =
>         new PostgresqlSqlDialect(PostgresqlSqlDialect.DEFAULT_CONTEXT) {
>           @Override public boolean supportGenerateSelectStar(RelNode relNode) 
> {
>             return false;
>           }
>         };
>     final Function<RelBuilder, RelNode> relFn = b -> b
>         .scan("EMP")
>         .filter(b.equals(b.field("DEPTNO"), b.literal(10)))
>         .build();
>     final String expected = "SELECT \"EMPNO\", \"ENAME\", \"JOB\", \"MGR\","
>         + " \"HIREDATE\", \"SAL\", \"COMM\", \"DEPTNO\"\n"
>         + "FROM \"scott\".\"EMP\"\n"
>         + "WHERE \"DEPTNO\" = 10";
>     relFn(relFn).dialect(noStarDialect).ok(expected);
>   }{code}
> Current Output:
> {noformat}
> SELECT * FROM "scott"."EMP" WHERE "DEPTNO" = 10{noformat}
> Expected Output:
> {noformat}
> SELECT "EMPNO", "ENAME", "JOB", "MGR", "HIREDATE", "SAL", "COMM", "DEPTNO" 
> FROM "scott"."EMP" WHERE "DEPTNO" = 10{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to