The problem is that you are making the language ambiguous. To get your desired 
behavior you probably need the lexical analyzer less eager. That’s a hard thing 
to do, because you probably need to adjust its behavior based on the syntactic 
context - whether the parser thinks that it is parsing the name of a type. 

Every java parser has to solve the same problem, so you should see how they 
solve it. 

I question whether we want SQL to look like Java. This includes whether we use 
< and > for parameterized types, and whether we include every possible operator 
such as >> and &&. 

Julian

> On Oct 12, 2023, at 02:13, Hongyu Guo <guohongyu...@gmail.com> wrote:
> 
> Hi devs,
> 
> I want to add some new bitwise operators to Babel parser, specifically the
> left shift "<<" and the right shift ">>".
> 
> To do this, I add `"< BITWISE_RIGHT_SHIFT: \">>\" >"`
> to binaryOperatorsTokens in babel/src/main/codegen/config.fmpp and a new
> SqlBinaryOperator to
> core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java,
> similar to what  was done in CALCITE-4980[1].
> 
> But I have noticed this change causes an error when using SQL like `select
> cast(a as map<varchar multiset, map<int, int>>)`. This is because the SQL
> contains `>>` string, I want to know how to avoid this awkward error.
> Thanks.
> 
> [1] https://issues.apache.org/jira/browse/CALCITE-4980
> 
> Best,
> hongyu guo

Reply via email to