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

Julian Hyde commented on CALCITE-4471:
--------------------------------------

I don't think it's useful to attach PNGs with the code that you think is wrong. 
First, PNGs are not searchable. Second, the PR will indicate which code is at 
fault.

It's better that the title and description of the case simply states the 
problem, as seen by the user - in this case, that SQL is unparsed incorrectly 
in Spark dialect.

The fix looks reasonably OK. (I'm not sure whether I would make it a boolean, 
because other dialects might fail to implement Sql99 in other ways - I might 
just override the unparseCall method in Spark dialect.) But I would not test 
unparsing in SqlParserTest (which after all is about parsing). Test unparsing 
in RelToSqlConverterTest. Then unparsing do not have to be in the same dialect 
as parsing.

> "SqlBetweenOperator" should support writing optional "ASYMMETRIC" or 
> "SYMMETRIC" flag in "unparse" method
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4471
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4471
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.26.0
>         Environment: jvm: open-jdk8
>            Reporter: yanjing.wang
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: image-2021-01-18-15-51-40-245.png, 
> image-2021-01-18-15-57-02-994.png, image-2021-01-18-15-57-22-436.png
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> when i unparse the following sql 
>  
> {code:java}
> String sql = "select concat(a.id,'-',b.id) , a.name from xxx.bb where dt 
> between '2020-10-04' AND '2020-10-09' limit 2";
> {code}
> i got the result
>  
> {code:java}
> SELECT `CONCAT`(`A`.`ID`, '-', `B`.`ID`), `A`.`NAME` FROM `XXX`.`BB` WHERE 
> `DS` BETWEEN ASYMMETRIC '2020-10-04' AND '2020-10-09' LIMIT 2
> {code}
> the "ASYMMETRIC" keyword is not supported in spark dialect. and the 
> "parser.jj" file defines optional "ASYMMETRIC" and "SYMMETRIC" keyword.
> !image-2021-01-18-15-51-40-245.png!
> but "SqlBetweenOperator" writes the "flag" in hard code way.
> !image-2021-01-18-15-57-02-994.png!
> !image-2021-01-18-15-57-22-436.png!
> the parse and unparse should keep the same syntax process.
> my code is as follows
>  
> {code:java}
> String sql = "select concat(a.id,'-',b.id) , a.name from xxx.bb where dt 
> between '2020-10-04' AND '2020-10-09' limit 2";  
> SqlParser sqlParser = SqlParser.create(sql, configBuilder); try { SqlNode 
> sqlNode = sqlParser.parseQuery(); SqlString sqlString = 
> sqlNode.toSqlString(SPARK); System.out.println(sqlString); } catch 
> (SqlParseException e) { e.printStackTrace(); }
> {code}
>  
>  
>  
>  



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

Reply via email to