Mihai Budiu created CALCITE-7072:
------------------------------------
Summary: Validator should not insert aliases on subexpressions
Key: CALCITE-7072
URL: https://issues.apache.org/jira/browse/CALCITE-7072
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.40.0
Reporter: Mihai Budiu
For the following program
{code:sql}
SELECT CASE WHEN deptno IS NOT NULL THEN empno
ELSE CAST(deptno AS VARCHAR) END AS ID FROM emp
{code}
type coercion may insert an alias for the "empno" expression, producing SQL
such as:
{code:sql}
CASE WHEN `EMP`.`DEPTNO` IS NOT NULL THEN CAST(`EMP`.`EMPNO` AS VARCHAR`) AS
`EMPNO` ELSE ...
{code}
which is clearly incorrect.
This bug was reported by github user rongrong. It was introduced in
[CALCITE-6770]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)