xiedeyantu commented on code in PR #4730:
URL: https://github.com/apache/calcite/pull/4730#discussion_r2670363736
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCollect.java:
##########
@@ -109,15 +109,21 @@ public static Collect create(RelNode input, RelDataType
rowType) {
RelDataType childRecordType =
result.physType.getRowType().getFieldList().get(0).getType();
if (!SqlTypeUtil.sameNamedType(collectionComponentType,
childRecordType)) {
- // In the internal representation of multisets , every element must be
a record. In case the
- // result above is a scalar type we have to wrap it around a physical
type capable of
- // representing records. For this reason the following conversion is
necessary.
+ // In the internal representation of multisets, every element must be
a record.
+ // In case the result above is a scalar type we have to wrap it around
a
+ // physical type capable of representing records.
+ // For ARRAY type with a single field, we use SCALAR format to avoid
Review Comment:
1 = ANY(array[1,2,3]) works because it typically performs a direct scalar
comparison (e.g., Integer vs Integer) without involving complex
row-to-collection wrapping.
In contrast, array[1,2,3] = ANY(array[1,2,3], array[4,2,3]) treats the right
side as a collection of rows. EnumerableCollect wrapped each row (already an
array) into an Object[]. This caused a comparison mismatch: Array vs.
Object[]{Array}, which returned
false.
Using SCALAR format for Array inputs prevents this unnecessary Object[]
wrapping, allowing a correct Array vs. Array comparison.
--
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]