Vladimir Steshin created CALCITE-4926:
-----------------------------------------
Summary: 'ORDER BY' misses alias/table of own 'WITH'
Key: CALCITE-4926
URL: https://issues.apache.org/jira/browse/CALCITE-4926
Project: Calcite
Issue Type: Bug
Reporter: Vladimir Steshin
"SELECT * FROM emp ORDER BY (WITH t AS (SELECT 1) SELECT * FROM t)"
fails with:
"Column 'T' not found in any table".
Working similar one:
"WITH t AS (SELECT 1) SELECT * FROM emp ORDER BY (SELECT * FROM t)"
As I understand, SqlValidatorImpl#OrderExpressionExpander (extends
SqlScopedShuttle) hurries to find the alias in the upper, parent query, whole
"select * from ...". But this query and the related namespaces has no such
alias. Probably, it's better to search order-by's namespace first.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)