You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2023/05/15 19:29:00 UTC

[jira] [Commented] (CALCITE-5701) Implement Apache Spark named_struct

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

Julian Hyde commented on CALCITE-5701:
--------------------------------------

Your examples are in Spark SQL embedded in Scala. In your description, can you add the examples in Calcite's SQL and type system? I believe that in standard SQL, {{ROW}} would be the equivalent of Spark SQL's {{struct}} type.

In your example, are {{"a"}} and {"b"}} identifiers, or are they character literals? If they are character literals, would we also allow non-constant character expressions, and if so, how would we deal with the fact that the type can vary at run time?

> Implement Apache Spark named_struct
> -----------------------------------
>
>                 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
>
> [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>]{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}



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