[
https://issues.apache.org/jira/browse/CALCITE-7791?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18122246#comment-18122246
]
Sean Broeder commented on CALCITE-7791:
---------------------------------------
RELEASE NOTE: UNNEST of an array or multiset of single-field ROW values
preserves the element's field name. select * returns the field name, for
example A in unnest(… row(a integer) array) as d). The alias still names the
column and can be used to qualify the field (d.a). NATURAL JOIN matches on the
field name and USING accepts either the field name or the alias. This applies
to plain UNNEST, WITH ORDINALITY, sub-query operands, and MULTISET.
Conformances that do not expand ROW elements into columns (PRESTO, BIG_QUERY)
are unaffected.
> UNNEST of a single-field ROW array loses the field name when aliased
> --------------------------------------------------------------------
>
> Key: CALCITE-7791
> URL: https://issues.apache.org/jira/browse/CALCITE-7791
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.42.0
> Reporter: Sean Broeder
> Assignee: Sean Broeder
> Priority: Major
> Labels: pull-request-available
>
> AliasNamespace.validateImpl() already handles this ambiguity for table
> functions. For example, SELECT rmp, rmp.i FROM TABLE(ramp(3)) AS rmp works
> because a 1-column result aliased with no column list gets wrapped in
> SingleColumnAliasRelDataType. This was added in CALCITE-5779. However, that
> wrapping only triggers for SqlKind.COLLECTION_TABLE.
> UNNEST hits the same ambiguity and isn't covered.
> SqlUnnestOperator#inferReturnType flattens a single-field ROW array element
> to the top level, producing the same 1-field row shape, but AliasNamespace
> falls through to the plain branch instead and renames that field to the alias
> and discards its real name.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)