In my opinion we should support the ‘|’ operator but not in the core SQL parser 
by default. Either support it in babel or enable it with flags in the core 
parser.

Rationale: MySQL in its early days seemed to have a wacky mission to make SQL 
look like C. 0 and 1 for true and false, the |, ^, &&, || operators, etc. The 
‘||’ operator is particularly damaging, because it prevents them from using it 
for string concatenation as practically everyone else does. I strongly believe 
that we should not let this wackiness leak into Calcite’s core SQL.

徐仁和, please log a JIRA case to support ‘|’ and post the URL to this thread.

We should definitely add functions for bitwise operations. Because they have 
function syntax they don’t require parser changes, and are therefore easier to 
turn on and off.

Someone should review the PRs for the cases listed. It’s embarrassing that we 
let these languish.

Julian



> On Apr 1, 2022, at 5:50 AM, 徐仁和 <[email protected]> wrote:
> 
> Hi all
> I am using CALCITE as a mysql-proxy in my project.
> Some user want use mysql's bit functions[1], but I found CALCITE didn't
> support to parse these token.
> For example:
> 
>> select 1 | 2 as c1;
> 
> 
> Exception:
> Caused by: java.lang.RuntimeException:
> org.apache.calcite.sql.parser.SqlParseException: Encountered "|" at line 1,
> column 10.
> Was expecting one of:
>    <EOF>
>    "ORDER" ...
>    "LIMIT" ...
>    "OFFSET" ...
>    "FETCH" ...
>    "UNION" ...
>    "INTERSECT" ...
> 
> ------------------
> 
> I remember that some jiras[2][3][4][5][6] have been about this problem, and
> how are they doing?
> 
>   1. https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html
>   2. https://issues.apache.org/jira/browse/CALCITE-3782
>   3. https://issues.apache.org/jira/browse/CALCITE-3732
>   4. https://issues.apache.org/jira/browse/CALCITE-3779
>   5. https://issues.apache.org/jira/browse/CALCITE-3592
>   6. https://issues.apache.org/jira/browse/CALCITE-3697
> 
> 
> Thanks & Regards

Reply via email to