The ‘@@‘ prefix is not standard SQL, and Calcite does not support it.

Can you do some research to find out how MySQL handles it. Is it considered to 
be part of the variable name? Or is it a prefix (like $ in bash) that means 
‘what comes next is a variable’? In other words, does the parser say there is a 
reference to a variable called '@@character_set_server’ or a variable called 
‘character_set_server’? And is ‘@‘ a legal part of a variable name?

Also, is it handled by the core SQL parser or by a preprocessor?

Julian


> On Mar 22, 2022, at 2:17 AM, Adolfo Ochagavía <[email protected]> wrote:
> 
> Hi there,
> 
> I am writing a MySQL-compatible server that talks the MySQL protocol. Some 
> clients are sending special queries to autoconfigure themselves, like "SELECT 
> @@character_set_server". I would like to use calcite to parse such queries, 
> but parsing fails with an exception, seemingly related to the usage of "@@" 
> in variable names. Is this unsupported or am I doing something wrong?
> 
> The code:
>> var config = SqlParser.Config.DEFAULT.withLex(Lex.MYSQL);
>> var parser = SqlParser.create("SELECT @@character_set_server", config);
>> var parsed = parser.parseQuery();
> 
> The exception: org.apache.calcite.sql.parser.SqlParseException: Lexical error 
> at line 1, column 9.  Encountered: "@" (64), after : ""
> 
> Any help is appreciated!
> Adolfo

Reply via email to