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

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

I reverted my changes for the runtime NamedStruct. I had another idea to solve 
the issue I had with the item operator, where we don't have information at 
runtime to resolve the field offset. I could pass the list of fields: 

[https://github.com/apache/calcite/pull/3295/commits/5e7711d4c0ce862b33eb8ef446ce03a5607da79c#diff-2095e662d66d6c1b2851915fa0d73934c3a847550545396835e02d88a9f5e2daR3349-R3364]

Then at runtime, we can find the offset.

[https://github.com/apache/calcite/pull/3295/commits/5e7711d4c0ce862b33eb8ef446ce03a5607da79c#diff-23301236e7a9c0e772620a2093cce6a979d7703c511f2417973fae0b26ee62b3R3873]

 

Does that make sense?

> 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