[
https://issues.apache.org/jira/browse/CALCITE-7602?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18088425#comment-18088425
]
Mihai Budiu commented on CALCITE-7602:
--------------------------------------
Actually the CAST trick won't work, at the time the expansion is made the types
are not yet inferred.
Maybe what is needed is a ROW constructor which allows one to specify field
names.
> ROW(*) loses column names
> -------------------------
>
> Key: CALCITE-7602
> URL: https://issues.apache.org/jira/browse/CALCITE-7602
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.42.0
> Reporter: Mihai Budiu
> Priority: Minor
>
> The newly-introduced ROW( * ) and ROW(* EXCLUDE(cols)) constructors create a
> new ROW-valued column. However, the newly introduced ROW does not preserve
> the columns of the original table as field names.
> {code:java}
> SELECT R.deptno FROM (SELECT ROW(*) AS R FROM emp); {code}
> will produce an error:
> {code:java}
> Column R.deptno not found {code}
> The column names could be preserved by generating a CAST to an appropriate
> ROW type, by rewriting the inner expression as:
> {code:java}
> SELECT CAST(ROW(*) AS ROW(...columns of emp...)) AS R {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)