[
https://issues.apache.org/jira/browse/CALCITE-4354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17221365#comment-17221365
]
Stamatis Zampetakis commented on CALCITE-4354:
----------------------------------------------
I think the change makes sense. I left some small comments in the PR. Other
than that it would be nice to update the description of the case with some SQL
examples of what is not working now and what will be working after the change.
> ITEM operator does not support synthetic struct type
> ----------------------------------------------------
>
> Key: CALCITE-4354
> URL: https://issues.apache.org/jira/browse/CALCITE-4354
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.27.0
> Reporter: Alessandro Solimando
> Assignee: Alessandro Solimando
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 1h 50m
> Remaining Estimate: 0h
>
> The current implementation of the "ITEM" operator only supports struct/row
> type when this type if based on a class with named fields (that is, a
> non-synthetic type).
> For those non-synthetic struct types, the "ITEM" operator can be used to
> access named fields via a "string"-typed argument
> ([SqlItemOperator#96|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/fun/SqlItemOperator.java#L96]).
> The type checker accepts to apply "ITEM" on "ANY" type
> ([SqlItemOperator#49|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/fun/SqlItemOperator.java#L49]),
> and the operand checker only accepts "string"-based values
> ([SqlItemOperator.java#105|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/fun/SqlItemOperator.java#L105]).
> [SqlValidatorTest.java#L11933|https://github.com/apache/calcite/blob/master/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java#L11933]
> is an example of application of the "ITEM" operator over a struct with named
> fields.
> However, the “getAllowedSignatures” method
> ([SqlItemOperator.java#116|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/fun/SqlItemOperator.java#L116])
> does not reflect this, and asserts a signature as follows:
> "<ARRAY>[<INTEGER>]" or "<MAP>[<VALUE>]".
> "ITEM" operator could be enriched with the support of synthetic struct/row
> type, with a positional access to the fields with a signature
> "<ROW>[<INTEGER>]".
--
This message was sent by Atlassian Jira
(v8.3.4#803005)