[
https://issues.apache.org/jira/browse/CALCITE-5701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17741811#comment-17741811
]
Julian Hyde commented on CALCITE-5701:
--------------------------------------
* Add a {{!type}} line to {{spark.iq}} and make sure it prints the {{STRUCT}}
type properly
* {{spark.iq}} should end with {{# End spark.iq}} and newline
* {{class NamedStructFunction}} is odd because it isn't a function. Can you
make it less odd?
* Make the javadoc of {{NAMED_STRUCT}} consistent with other functions in that
class. It doesn't "Create a struct". It is a function that creates a struct.
* In {{SqlKind}}, rename {{STRUCT_CONSTRUCTOR}} to {{NAMED_STRUCT}}. Or maybe
you don't need a {{SqlKind}} value at all, in which case, remove it.
* 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.
* In the messages, the function should be "NAMED_STRUCT" not "named_struct".
> 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)