[ 
https://issues.apache.org/jira/browse/CALCITE-4354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17220919#comment-17220919
 ] 

Alessandro Solimando commented on CALCITE-4354:
-----------------------------------------------

Sorry, I should probably have elaborated a bit more in the ticket description, 
let me summarise the discussion we had around this in CALCITE-4293.

The SQL standard only supports the signature "<ARRAY>[<INTEGER>]", 
"<MAP>[<VALUE>]" is already an extension (the standard does not cover map 
collections), as well as "<ROW[<CHARACTER>]" for struct types stemming from 
UDTs with named fields (supported but not present in the 
"getAllowedSignatures").

It feels natural to me to complement the existing extension to the standard 
with the support for synthetic  struct types for which only a positional access 
of the (unnamed) fields is possible, via the "<ROW[<INTEGER>]" signature.

> 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: 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)

Reply via email to