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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to