You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2021/11/29 04:24:00 UTC
[jira] [Comment Edited] (CALCITE-4906) Wrong result for scalar subquery (single value aggregation) from empty input
[ https://issues.apache.org/jira/browse/CALCITE-4906?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17450183#comment-17450183 ]
Julian Hyde edited comment on CALCITE-4906 at 11/29/21, 4:23 AM:
-----------------------------------------------------------------
Looks good; a few improvements:
* in scalar.iq, please add a case with a correlated scalar sub-query;
* for future reference, the commit message should be the same as the bug summary, not a description of how you fixed the bug;
* please add a test in {{SqlToRelConverterTest}} with a scalar sub-query and "withExpand(false)"; it might not reproduce this exact problem, but it may prevent future regressions.
As always, please add commits; don't squash or rebase.
was (Author: julianhyde):
Looks good; a few improvements:
* in scalar.iq, please add a case with a correlated scalar sub-query;
* for future reference, the commit message should be the same as the bug summary, not a description of how you fixed the bug;
* please add a test in {{SqlToRelConverterTest}} with a scalar sub-query and "withExpand(false)"; it might not reproduce this exact problem, but it may prevent future regressions.
As always, please add commits; don't squash or rebase.
> Wrong result for scalar subquery (single value aggregation) from empty input
> ----------------------------------------------------------------------------
>
> Key: CALCITE-4906
> URL: https://issues.apache.org/jira/browse/CALCITE-4906
> Project: Calcite
> Issue Type: Bug
> Reporter: Aleksey Plekhanov
> Assignee: Aleksey Plekhanov
> Priority: Major
>
> Scalar subqueries from the empty input return non-nullable type and in some cases it leads to wrong results. For example:
> {noformat}
> SELECT (SELECT 1 FROM (SELECT NULL) WHERE 1 = 0)
> {noformat}
> Returns {{0}}, but expected {{NULL}} according to the SQL standard:
> {noformat}
> Let SS be a <scalar subquery>.
> Case:
> a) If the cardinality of SS is greater than 1 (one), then an exception condition is raised: cardinality violation.
> b) If the cardinality of SS is 0 (zero), then the value of the <scalar subquery> is the null value.
> c) Otherwise, let C be the column of <query expression> simply contained in SS. The value of SS is the value of C in the unique row of the result of the <scalar subquery>.
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)