[
https://issues.apache.org/jira/browse/IGNITE-7785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16378534#comment-16378534
]
Alexander Paschenko commented on IGNITE-7785:
---------------------------------------------
[~pvinokurov],
Initial query is a bit weird as long as it has union of a table with itself.
In absence of {{UNION ALL}} clause, that subquery
{{(select id from company union all select id from company)}}
should give same result as single {{SELECT id FROM Company}}, and thus in
initial case that UNION is redundant - if you remove UNION, query works.
However, if you add ALL to UNION, query works - however, in this case UNION has
duplicates just like it should.
I will also have a look at second query.
> SQL query with COUNT and UNION in sub-query produces JdbcSQLException
> ---------------------------------------------------------------------
>
> Key: IGNITE-7785
> URL: https://issues.apache.org/jira/browse/IGNITE-7785
> Project: Ignite
> Issue Type: Bug
> Components: sql
> Affects Versions: 2.1, 2.3
> Reporter: Pavel Vinokurov
> Priority: Major
>
> SQL initial script:
> CREATE TABLE Person(id INTEGER PRIMARY KEY, company_id INTEGER);
> CREATE TABLE Company(id INTEGER PRIMARY KEY, name VARCHAR);
> INSERT INTO Person(id,company_id) VALUES (1, 1), (2, 2), (3, 3);
> INSERT INTO Company(id,name) VALUES (1,'n1'), (2,'n2'), (3,'n3');
> SQL Query:
> SELECT count(1) FROM person p
> LEFT JOIN (select id from company union select id from company) as c on
> c.id=p.company_id
> JDBC Exception:
> Caused by: org.h2.jdbc.JdbcSQLException: Column "P__Z0.COMPANY_ID" must be in
> the GROUP BY list; SQL statement:
> SELECT
> P__Z0.COMPANY_ID __C0_0,
> COUNT(1) __C0_1
> FROM PUBLIC.PERSON P__Z0 [90016-195]
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)