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

Nan Deng commented on CALCITE-2917:
-----------------------------------

Thank you Mr. Hyde for the prompt reply. I do see parser.switchTo() 
Quoting.DOUBLE_QUOTE upon initialization. However, when it starts to 
[parseQuery()|https://github.com/VoltDB/calcite/blob/6f52b9477c215f2df5ae0192baf20e55ab04c291/core/src/main/java/org/apache/calcite/sql/parser/SqlParser.java#L150],
 what happened is it will ReInit() its lex state back to the default setting, 
which, in this case, is square bracket. The code below is machine generated 
after compilation:

This is in SqlDdlParserImpl:
{code:java}
public void ReInit(java.io.InputStream stream) {
   ReInit(stream, null);
}
public void ReInit(java.io.InputStream stream, String encoding) {
  try { jj_input_stream.ReInit(stream, encoding, 1, 1); } 
catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
  token_source.ReInit(jj_input_stream);
  token = new Token();
  jj_ntk = -1;
  jj_gen = 0;
  for (int i = 0; i < 5; i++) jj_la1[i] = -1;
  for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
}
{code}
This is in SqlDdlParserImplTokenManager:
{code:java}
public void ReInit(SimpleCharStream stream)
{
   jjmatchedPos = jjnewStateCnt = 0;
   curLexState = defaultLexState;
   input_stream = stream;
   ReInitRounds();
}
{code}
So basically parser will override its quote setting upon initialization and 
make it default. It should be a quick fix to solve by swapping Bracket and 
DoubleQuote's position and mark DQ as default. However, I am not sure if it can 
be done by changing the parser.jj code only. Could you please give some hint on 
this. Thank you again for your time.

> Calcite should use double quote as default identifier delimiter
> ---------------------------------------------------------------
>
>                 Key: CALCITE-2917
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2917
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.17.0, 1.18.0
>            Reporter: Nan Deng
>            Priority: Major
>
> From CALCITE-1217 I found this statement:
> {code:java}
> (Calcite) Its default identifier quoting character is double-quote.
> {code}
>  this is not consistent with what's been said in 
> [Parser.jj|https://github.com/apache/calcite/blob/50012d221d6e9a5e42a957ab0723e0f706b25be3/core/src/main/codegen/templates/Parser.jj#L6976]
>  which defines bracket as the default identifier delimiter:
>  
>  It should be one or another.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to