You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by 徐仁和 <xu...@gmail.com> on 2022/04/01 12:50:08 UTC

Calcite's parser didn't support bitwise's operator

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

Re: Calcite's parser didn't support bitwise's operator

Posted by 徐仁和 <xu...@gmail.com>.
Hi Julian

I am really sorry for the late reply.


I did some research, most sql engines support bitwise operator, and there
are some differences.

Please see the JIRA(https://issues.apache.org/jira/browse/CALCITE-5087)


And, it's dependent on previous related issues.[1][2][3][4][5]


1. https://issues.apache.org/jira/browse/CALCITE-3782

2. https://issues.apache.org/jira/browse/CALCITE-3732

3. https://issues.apache.org/jira/browse/CALCITE-3779

4. https://issues.apache.org/jira/browse/CALCITE-3592

5. https://issues.apache.org/jira/browse/CALCITE-3697

Julian Hyde <jh...@gmail.com> 于2022年4月2日周六 03:42写道:

> 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, 徐仁和 <xu...@gmail.com> 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
>
>

Re: Calcite's parser didn't support bitwise's operator

Posted by Julian Hyde <jh...@gmail.com>.
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, 徐仁和 <xu...@gmail.com> 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