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

Ruben Q L commented on CALCITE-4999:
------------------------------------

[~dmsysolyatin] you can find some draft versions of the standard in Wikipedia: 
https://en.wikipedia.org/wiki/SQL#SQL_standards_documents

I have checked the standard (relevant parts: <array value constructor> and 
<array value constructor by query>); and it would seem that, indeed, Calcite is 
not following it:

{noformat}
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.
{noformat}


> `least restrictive` type inference does not work when one operand is scalar 
> and another is row with one field
> -------------------------------------------------------------------------------------------------------------
>
>                 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
>
> I faced with a issue that the following query:
> {code:java}
> SELECT ARRAY_CONCAT(ARRAY['1', '2'], array(select 'toast.' || x from 
> unnest(ARRAY['1','2']) x)) {code}
> didn't work, because of:
> {code:java}
> java.lang.IllegalArgumentException: Cannot infer return type for 
> ARRAY_CONCAT; operand types: [CHAR(1) ARRAY, RecordType(CHAR(7) EXPR$0) 
> ARRAY]{code}
> `least restrictive` type inference does not work when one operand is scalar 
> and another is row with one field



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to