[
https://issues.apache.org/jira/browse/CALCITE-4472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17268724#comment-17268724
]
Julian Hyde commented on CALCITE-4472:
--------------------------------------
The best way to write test cases for issues like this is to write a negative
validator test for which the SqlNode is the cause of the error. Then make sure
that the error covers the right region of the source SQL text. Here is [an
example where the argument to a call to NOT is of the wrong
type|https://github.com/apache/calcite/blob/f277a2468805999a446e5bcd0ef70aa1e9550562/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java#L279].
> the SqlParserPos in like statement and in limit statement seems wrong
> ---------------------------------------------------------------------
>
> Key: CALCITE-4472
> URL: https://issues.apache.org/jira/browse/CALCITE-4472
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.21.0
> Environment: java8 + idea + maven3
> calcite version: 1.21.0
> Reporter: chener
> Priority: Major
> Labels: Parser
> Attachments: image-2021-01-19-15-54-38-621.png,
> image-2021-01-19-16-00-20-059.png
>
>
> Here are the sqls:
>
> {code:java}
> // like statement
> select id,name from chener where name like 'name'
> //limit statement
> select id,name from chener where name = 'jack' limit 1
> {code}
> than the parser code:
> {code:java}
> // the java code for parser
> SqlParser.Config mysqlConfig = SqlParser.configBuilder()
> .setParserFactory(SqlAlterParserImpl.FACTORY)
> .setLex(Lex.MYSQL)
> .build();
> SqlParser parser = SqlParser.create("", mysqlConfig);
> SqlNode sqlNode = parser.parseQuery(likeSql);
> SqlNode sqlNode1 = parser.parseQuery(limitSql);
> {code}
> the like statement result:
> !image-2021-01-19-15-54-38-621.png!
> You can see that the SqlParserPos of the like statement in where seems
> wrong.If the where statement does not contain the like statement,it works
> allright. And so does the limit stament.
> !image-2021-01-19-16-00-20-059.png!
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)