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

Guillaume Massé commented on CALCITE-5701:
------------------------------------------

[~julianhyde] 

{quote}
You should not be using SqlFunctions.item. The javadoc says "Implements item on 
an object whose type is not known until runtime". But you know the type is 
STRUCT(k1 VARCHAR, K2 INTEGER). You know that "k1" is item zero of the 
Object[]. You should translate "item" call to a field access. And then none of 
your changes to ItemImplementor will be necessary.
{quote}

Where this translation should take place? Would it be in the validator? I would 
love to get this issue resolve to focus on my next task lambda expressions 
(https://issues.apache.org/jira/browse/CALCITE-3679).

> Add NAMED_STRUCT function (enabled in Spark library)
> ----------------------------------------------------
>
>                 Key: CALCITE-5701
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5701
>             Project: Calcite
>          Issue Type: New Feature
>          Components: core
>            Reporter: Guillaume Massé
>            Priority: Minor
>              Labels: pull-request-available
>
> [https://spark.apache.org/docs/3.4.0/api/sql/index.html#named_struct]
>  
> {code:java}
> spark.sql("""select named_struct("a", 1, "b", 2)""")
> res4: org.apache.spark.sql.DataFrame = [named_struct(a, 1, b, 2): struct<a: 
> int, b: int>]
> Calcite:
> SELECT named_struct('a', 1, 'b", 2);
> type: row(a int not null, b int not null){code}
>  
> It's also possible to be nested:
> {code:java}
> spark.sql("""select named_struct("a", 1, "b", named_struct("c", 2))""")
> res5: org.apache.spark.sql.DataFrame = [named_struct(a, 1, b, named_struct(c, 
> 2)): struct<a: int, b: struct<c: int>>] {code}
> {code:java}
> Calcite:
> SELECT named_struct('a', 1, 'b', named_struct('c', 2));
> type: row(a int not null, b row(c int not null) not null){code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to