[
https://issues.apache.org/jira/browse/CALCITE-4354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17221692#comment-17221692
]
Julian Hyde commented on CALCITE-4354:
--------------------------------------
Makes sense:
* Please update reference.md.
* Is the index 0-based or 1-based?
* Change the JIRA case summary and commit message. Frame it as a feature not a
bug. Explain it in terms of ROW rather than 'synthetic struct type', and give a
simple SQL example.
* Add one or two tests to {{operator.iq}}.
We are also going to want the ITEM operator to apply to record/struct types,
e.g. {{address[2]}} and {{address['ZIPCODE']}}, where {{address}} is a struct
or record type that has fields STREET, ZIPCODE, CITY, STATE. That could be a
different JIRA case.
> 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: 2h 10m
> 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)