You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "vlsi (via GitHub)" <gi...@apache.org> on 2026/10/11 20:46:10 UTC

[PR] [CALCITE-7847] Implicit coercion casts MULTISET operands of a comparison to ARRAY, and loses the nullability of ROW operands [calcite]

vlsi opened a new pull request, #5321:
URL: https://github.com/apache/calcite/pull/5321

   ## Jira Link
   
   [CALCITE-7847](https://issues.apache.org/jira/browse/CALCITE-7847)
   
   ## Changes Proposed
   
   `AbstractTypeCoercion#commonTypeForBinaryComparison` built the common type of two MULTISET operands with `createArrayType`, so `multiset[deptno] = multiset[cast(deptno as decimal(5, 2))]` was converted to a comparison of two `CAST`s to `DECIMAL(12, 2) NOT NULL ARRAY NOT NULL`. The ROW branch returned a NOT NULL struct even when one operand was nullable, while the other branches return a nullable type in that case.
   
   The MULTISET branch now builds a MULTISET, and the ROW result is nullable when either operand is nullable. Making a struct nullable also makes its fields nullable, which is how `createTypeWithNullability` builds a nullable record elsewhere.
   
   The ROW part has no SQL-level test: the validator and `SqlToRelConverter` apply each operand's own nullability to the cast target, so the defect shows only to callers that use the result directly, such as a custom `TypeCoercion`.
   
   Tests: `TypeCoercionTest#testComparisonCommonTypeOfRowIsNullableIfEitherIs`, `TypeCoercionTest#testComparisonCommonTypeOfMultisetIsMultiset` and `SqlToRelConverterTest#testMultisetComparisonCoercion` are new and each fails without the fix; the ARRAY rows in the MULTISET test are controls that pass either way. `comparisonCommonType` now prints `getFullTypeString()`, since `toString()` omits nullability and the ROW failure printed the same type twice. `./gradlew :core:test` passes.
   
   Not in this change: `multiset[1, 2] = multiset[2, 1]` evaluates to `false` with or without this fix, because the runtime compares MULTISET values in element order.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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-7847] Implicit coercion casts MULTISET operands of a comparison to ARRAY, and loses the nullability of ROW operands [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #5321:
URL: https://github.com/apache/calcite/pull/5321


-- 
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-7847] Implicit coercion casts MULTISET operands of a comparison to ARRAY, and loses the nullability of ROW operands [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5321:
URL: https://github.com/apache/calcite/pull/5321#issuecomment-6113964937

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5321) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5321&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5321&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5321&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5321&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5321&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5321)
   
   


-- 
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