Alessandro Solimando created CALCITE-7483:
---------------------------------------------
Summary: 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
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.
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)