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

Benchao Li commented on CALCITE-5334:
-------------------------------------

There are several operators which also have the precedence of 30, such as 
{{<}}, {{>}}, {{<=}}, {{>=}}, {{=}}, those operators are supposed to have 
smaller precedence than {{OVERLAPS}}/{{LIKE}} as the doc says.  

I searched the precedence in several databases, they are very different, take 
{{=}} and {{IN}} as an example:
1. {{=}} is higher than {{IN}} in sqlserver: 
https://learn.microsoft.com/en-us/sql/t-sql/language-elements/operator-precedence-transact-sql?view=sql-server-ver16
2. {{=}} equals {{IN}} in oracle: 
http://www.java2s.com/example/oracle-book/operator-precedence.html and mysql: 
https://dev.mysql.com/doc/refman/8.0/en/operator-precedence.html
3. {{=}} is smaller than {{IN}} in postgrelsql: 
https://www.postgresql.org/docs/7.2/sql-precedence.html

As it varies so much in different dialects, maybe this is not a big problem 
cause users may only care about the the precedence for very few, such as: 
comparison, logical, mathematical operators.

> The precedence for CONTAINS/OVERLAPS is inconsistent with doc
> -------------------------------------------------------------
>
>                 Key: CALCITE-5334
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5334
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.32.0
>            Reporter: Benchao Li
>            Assignee: Benchao Li
>            Priority: Major
>
> In the document, we says that {{CONTAINS}}/{{OVERLAPS}}'s precedence is the 
> same as {{IN}}/{{LIKE}} etc. 
> https://github.com/apache/calcite/blob/2c30a56158cdd351d35725006bc1f76bb6aac75b/site/_docs/reference.md?plain=1#L1216
> However, the actual precedence for {{IN}}/{{LIKE}} is 32, and 
> {{CONTAINS}}/{{OVERLAPS}} is 30.
> Hence the below SQL will fail due to this:
> {code:sql}
> select (date '2020-01-01', date '2020-12-31') contains (date 
> '2020-11-01',date '2020-12-01') in (true, true);
> {code}



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

Reply via email to