You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Benchao Li (Jira)" <ji...@apache.org> on 2023/04/21 09:09:00 UTC
[jira] [Commented] (CALCITE-5667) Unexpected result with aggregate inside subquery
[ https://issues.apache.org/jira/browse/CALCITE-5667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17714898#comment-17714898 ]
Benchao Li commented on CALCITE-5667:
-------------------------------------
Scalar sub-query should be evaluated for each record, current behavior seems correct to me. Could you elaberate a little more why you think it should return only 3, e.g., what databases have this behavior?
> Unexpected result with aggregate inside subquery
> ------------------------------------------------
>
> Key: CALCITE-5667
> URL: https://issues.apache.org/jira/browse/CALCITE-5667
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.34.0
> Reporter: Evgeny Stanilovsky
> Priority: Major
>
>
> {noformat}
> CREATE TABLE TBL1(ID INT PRIMARY KEY, VAL int);
> insert into TBL1 values (1, 1), (2, 2);
> select (select(sum(VAL))) from TBL1; <-- await 3 as a result
> {noformat}
>
> but obtain :
>
> {noformat}
> 1
> 2
> {noformat}
> appropriate Quidem test for _blank.iq_
> {noformat}
> select (select(sum(I))) from bar;{noformat}
> explain shows :
> {noformat}
> EnumerableCalc(expr#0..2=[{inputs}], EXPR$0=[$t2])
> EnumerableCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}])
> EnumerableTableScan(table=[[BLANK, BAR]])
> EnumerableAggregate(group=[{}], EXPR$0=[SUM($0)])
> EnumerableCalc(expr#0=[{inputs}], expr#1=[$cor0], expr#2=[$t1.I], $f0=[$t2])
> EnumerableValues(tuples=[[{ 0 }]]){noformat}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)