You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "Soumyadeep-github (via GitHub)" <gi...@apache.org> on 2026/06/18 19:57:53 UTC
[PR] [CALCITE-2901] Preserve scalar RexSubQuery type with copyType [calcite]
Soumyadeep-github opened a new pull request, #5027:
URL: https://github.com/apache/calcite/pull/5027
JIRA: [CALCITE-2901](https://issues.apache.org/jira/browse/CALCITE-2901)
## Changes Proposed
- Scalar sub-queries now take the type of the one column inside the sub-query (copyType). We stopped forcing that type to always allow null after that.
- The SQL checker and RECORD_TO_SCALAR use the same idea so types stay in sync end to end.
- After sub-queries are turned into joins, some fields can be null from the join even when the checker said “not null”. The code adds casts in a few places so the plan matches what the checker expects (sub-query remove rule, sql-to-rel, one aggregate rule).
- Tests were updated: core diff tests, decorrelator string plans, Quidem scalar / sub-query, validator/coercion/table-function checks, rel-to-SQL for one MySQL-style case, operator tests in testkit, and two TPC-H plan checks in plus.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-2901] Preserve scalar RexSubQuery type with copyType [calcite]
Posted by "iwanttobepowerful (via GitHub)" <gi...@apache.org>.
iwanttobepowerful commented on code in PR #5027:
URL: https://github.com/apache/calcite/pull/5027#discussion_r3452731760
##########
core/src/test/resources/sql/scalar.iq:
##########
@@ -140,10 +140,10 @@ select deptno, (select empno from "scott".emp where 1 = 0) as x from "scott".dep
+--------+---+
| DEPTNO | X |
+--------+---+
-| 10 | |
-| 20 | |
-| 30 | |
-| 40 | |
+| 10 | 0 |
+| 20 | 0 |
+| 30 | 0 |
+| 40 | 0 |
Review Comment:
also wrong
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-2901] Preserve scalar RexSubQuery type with copyType [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5027:
URL: https://github.com/apache/calcite/pull/5027#issuecomment-4745876352
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5027) **Quality Gate passed**
Issues
 [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5027&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5027&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5027&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [92.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5027&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5027&metric=new_duplicated_lines_density&view=list)
<!-- sqra-placement-anchor -->
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5027)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-2901] Preserve scalar RexSubQuery type with copyType [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #5027:
URL: https://github.com/apache/calcite/pull/5027#discussion_r3438842959
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -6617,31 +6617,31 @@ private void checkLiteral2(String expression, String expected) {
+ "UNION ALL\n"
+ "SELECT NULL) END AS `$f0`\n"
+ "FROM `foodmart`.`product`) AS `t0` ON TRUE\n"
- + "WHERE `product`.`net_weight` > CAST(`t0`.`$f0` AS DOUBLE)";
+ + "WHERE `product`.`net_weight` > CAST(CAST(`t0`.`$f0` AS SIGNED) AS DOUBLE)";
Review Comment:
Is this case necessary?
If not, can you avoid inserting it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-2901] Preserve scalar RexSubQuery type with copyType [calcite]
Posted by "Soumyadeep-github (via GitHub)" <gi...@apache.org>.
Soumyadeep-github commented on code in PR #5027:
URL: https://github.com/apache/calcite/pull/5027#discussion_r3441149354
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -6617,31 +6617,31 @@ private void checkLiteral2(String expression, String expected) {
+ "UNION ALL\n"
+ "SELECT NULL) END AS `$f0`\n"
+ "FROM `foodmart`.`product`) AS `t0` ON TRUE\n"
- + "WHERE `product`.`net_weight` > CAST(`t0`.`$f0` AS DOUBLE)";
+ + "WHERE `product`.`net_weight` > CAST(CAST(`t0`.`$f0` AS SIGNED) AS DOUBLE)";
Review Comment:
Thanks for taking the time to review my changes! Agreed that we should not rely on later cast cleanup. I’ll go through the changed casts and drop any that aren’t needed for correctness.
For the `CAST(CAST($f0 AS …) AS DOUBLE)` case in RelToSqlConverterTest: I’ll trace where each cast is introduced and try to simplify to a single cast (or align types earlier) if semantics stay the same; if two steps are still required I’ll note why in a short comment or reply here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-2901] Preserve scalar RexSubQuery type with copyType [calcite]
Posted by "iwanttobepowerful (via GitHub)" <gi...@apache.org>.
iwanttobepowerful commented on code in PR #5027:
URL: https://github.com/apache/calcite/pull/5027#discussion_r3452726253
##########
core/src/test/resources/sql/scalar.iq:
##########
@@ -77,7 +77,7 @@ select deptno, (select count(*) from "scott".emp where deptno = dept.deptno grou
| 10 | 3 |
| 20 | 5 |
| 30 | 6 |
-| 40 | |
+| 40 | 0 |
Review Comment:
wrong result
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-2901] Preserve scalar RexSubQuery type with copyType [calcite]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #5027:
URL: https://github.com/apache/calcite/pull/5027#issuecomment-5054433274
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@calcite.apache.org list. Thank you for your contributions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org