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

Julian Hyde commented on CALCITE-6508:
--------------------------------------

{quote}you wouldn't happen to remember why subqueries were excluded?
{quote}
Subqueries introduce problems with commas. E.g.
{code:java}
ARRAY [
  SELECT deptno FROM emp GROUP BY deptno, job,
  3,
  5
]
{code}
When you are looking at a parenthesized expression it's difficult to tell 
whether it's going to be a query:
{code:java}
ARRAY [
  (((1 + 2) * 3) + 4),
  ((SELECT deptno FROM dept1
     UNION
    SELECT deptno FROM dept2)
   EXCEPT
   SELECT deptno FROM emp)
]
{code}
I agree we probably we should allow a scalar subquery (i.e. query enclosed in 
parentheses, that returns 0 or 1 rows) as an item in ARRAY. It's just hard to 
avoid ambiguous grammar.

> Parse error when using scalar sub-query as operand to Array constructor 
> function
> --------------------------------------------------------------------------------
>
>                 Key: CALCITE-6508
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6508
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Ian Bertolacci
>            Assignee: Ian Bertolacci
>            Priority: Major
>              Labels: pull-request-available
>
> Using a scalar subquery in the {{`ARRAY[ ... ]`}} function throws "parse 
> failed: Query expression encountered in illegal context"
> (Calcite version 1.36)
> For example:
> {code:sql}
> select ARRAY[ (select 1) ]
> select ARRAY[ (select max(x) from table) ]
> {code}
> Is this something that can be configured or easily altered?



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

Reply via email to