The ‘obvious’ semantics: Two array expressions are comparable iff their element types are comparable. They would compare equal iff they have the same length and all their elements are pairwise equal.
If the validator doesn’t do that it is most likely because no one got around to it. If the SQL standard and/or other leading databases have different semantics, let’s talk about it. > On Dec 17, 2024, at 3:01 PM, Mihai Budiu <[email protected]> wrote: > > I see there is issue https://issues.apache.org/jira/browse/CALCITE-3796 still > open, about allowing comparisons on arrays. > > I have a related question: today the validator seems to accept comparisons > between any kinds of arrays. > > For example, the validator rejects this comparison (taken from > SqlValidatorTest): > > expr("^x'a4'=1^") > .fails("(?s).*Cannot apply '=' to arguments of type '<BINARY.1.> = > <INTEGER>'.*"); > > But happily accepts this comparison: > > expr("array[x'e4'] <> array[1]") > .ok(); > > This seems to me somewhat inconsistent. I think the validator should either > > 1. > Require array element types to be identical for comparisons > 2. > At least require element types to be comparable > > I was trying to give a solution to > https://issues.apache.org/jira/browse/CALCITE-6735 Type coercion for > comparisons does not coerce generic types (ROW, ARRAY, etc), but I actually > don't know what the solution should be for arrays (and maps, multisets, etc) > given this state of affairs for the validator. > > Mihai >
