[
https://issues.apache.org/jira/browse/CALCITE-4999?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17526265#comment-17526265
]
Dmitry Sysolyatin edited comment on CALCITE-4999 at 4/22/22 8:29 AM:
---------------------------------------------------------------------
[~julianhyde] I have removed whitespace changes from
[testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java|https://github.com/apache/calcite/pull/2712/files#diff-fdd0c725fc7c6fd56965f59b1d51e4c7a9b5b5be27da2e54b8b8273dc980cd64]
.
??Is it necessary to change {{SqlTypeName}} to {{SqlKind}} in the {{Collect}}
constructor???
Collect and EnumerableCollect should know if an input is a subquery or not.
Because we apply the logic described above only for array or multiset with
subquery. I haven't found better solution than to replace SqlTypeName with
SqlKind
was (Author: dmsysolyatin):
[~julianhyde] I have removed whitespace changes from
[testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java|https://github.com/apache/calcite/pull/2712/files#diff-fdd0c725fc7c6fd56965f59b1d51e4c7a9b5b5be27da2e54b8b8273dc980cd64]
.
??Is it necessary to change {{SqlTypeName}} to {{SqlKind}} in the {{Collect}}
constructor???
Collect and EnumerableCollect should know if an input is a subquery or not.
Because we apply the logic described above only for array or multiset with
subquery
> ARRAY function should return an array of scalars if subquery returns 1 column
> -----------------------------------------------------------------------------
>
> Key: CALCITE-4999
> URL: https://issues.apache.org/jira/browse/CALCITE-4999
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Dmitry Sysolyatin
> Assignee: Dmitry Sysolyatin
> Priority: Major
> Labels: pull-request-available
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> At the moment `array` function returns [RecordType ARRAY] if subquery is
> passed like an argument.
> {code:java}
> SELECT array(select 'toast.' || x from unnest(ARRAY['1','2']) x){code}
> But Sql standard says:
> {code:java}
> 6.38 <array value constructor>
> Function
> Specify construction of an array.
> Format
> <array value constructor> ::=
> <array value constructor by enumeration>
> | <array value constructor by query>
> [...]
> <array value constructor by query> ::=
> ARRAY <table subquery>
> Syntax Rules
> [...]
> 3) If <array value constructor by query> is specified, then
> a) The <query expression> QE simply contained in the <table subquery> shall
> be of degree 1 (one). Let ET be the declared type of the column in the result
> of <query expression>.
> b) The declared type of the <array value constructor by query> is array with
> element type ET and maximum cardinality equal to the implementation-defined
> maximum cardinality IMDC for such array types.
> {code}
> Proposed solution is to return an array of scalars (e.g. INTEGER ARRAY) when
> the query returns 1 column, and continue to return an array of ROW when the
> query has 2 or more columns. And do the same for MULTISET.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)