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

Danny Chen commented on CALCITE-3973:
-------------------------------------

Thanks [~alexbaden] for reporting this ~

You are right, in SqlSelectOperator, the leftPrec and rightPrec should both be 
hard code to 0 [1], after fixing that, please also add a test case in 
SqlParserTest#testQueryHint.

[1] 
https://github.com/apache/calcite/blob/d1aae57fad71bf10942d4c53b339363537927c29/core/src/main/java/org/apache/calcite/sql/SqlSelectOperator.java#L150

> Writing SQL hints to a string results in SQL that cannot be parsed 
> -------------------------------------------------------------------
>
>                 Key: CALCITE-3973
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3973
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Alex Baden
>            Priority: Minor
>
> When using the new SQL hints feature:
>  
> {code:java}
> select /*+ cpu */ x from test limit 2;
> {code}
> If one calls to SqlString() on the node:
>  
>  
> {code:java}
> node.toSqlString(CalciteSqlDialect.DEFAULT).toString()
> {code}
>  
> We get:
>  
> {code:java}
> 'SELECT /*+ ("cpu") */ "x" FROM "test" FETCH NEXT 2 ROWS ONLY'
> {code}
> {{which is not valid SQL for a hint. It looks like the precedence options 
> need to be modified when writing out the hint in SqlSelectOperator.unparse}}
>  
> We do some rewriting of the sql statement and then re-parse it, so this is 
> preventing us from using hints. I am happy to submit a patch if I am headed 
> in the right direction with the description above. 
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to