[ 
https://issues.apache.org/jira/browse/CALCITE-5814?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18047698#comment-18047698
 ] 

Mihai Budiu edited comment on CALCITE-5814 at 12/26/25 6:28 PM:
----------------------------------------------------------------

Unfortunately Calcite does not prescribe a semantics for MAP, so we don't 
really know what kind of object is built by the MAP constructor. As pointed 
out, there are multiple possible interpretations with regards to equality, 
ordering, and duplicate keys. In the enumerable convention maps are implemented 
as LinkedHashMap, so the order of insertion matters. In our own compiler maps 
are BTreeMap Rust objects, which use sorted keys. Other implementations are 
possible. There is a choice what happens when keys in a constructor are 
duplicated. So I am afraid that the hands of the opimizer are tied to some 
degree: it can only make decisions based on predicates that would be true for 
all reasonable MAP implementations.

The situation may be simpler for ARRAY and MULTISET, whose meaning has fewer 
possible interpretations.


was (Author: JIRAUSER295926):
Unfortunately Calcite does not prescribe a semantics for MAP, so we don't 
really know what kind of object is built by the MAP constructor. As pointed 
out, there are multiple possible interpretations with regards to equality, 
ordering, and duplicate keys. In the enumerable convention maps are implemented 
as LinkedHashMap, so the order of insertion matters. In our own compiler maps 
are BTreeMap Rust objects, which are use sorted keys. Other implementations are 
possible. So I am afraid that the hands of the opimizer are tied to some 
degree: it can only make decisions based on predicates that would be true for 
all reasonable MAP implementations.

The situation may be simpler for ARRAY and MULTISET, whose meaning has fewer 
possible interpretations.

> Simplify 'a = MAP[1,2] AND a = MAP[2,3]' to 'FALSE'
> ---------------------------------------------------
>
>                 Key: CALCITE-5814
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5814
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.34.0
>            Reporter: Runkang He
>            Assignee: Runkang He
>            Priority: Major
>
> Currently the following expression with const map literal is not simplified 
> to FALSE:
> {code:sql}
> a = MAP[1,2] AND a = MAP[2,3]
> {code}
> Since the map type is an extension to the SQL standard, it's not clear 
> whether it is comparable or not. If comparable, it would be nice to simplify 
> above expression to FALSE.
> Welcome to discuss or provide some information.
> Note that this Jira is inspired from discussion of 
> [CALCITE-5733|https://issues.apache.org/jira/browse/CALCITE-5733].



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to