Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] JSQLParser Version : 4.6,RDBMS : Clickhouse, Parsing a query with table alias and final keyword fails #1770

Closed
shjlzjq opened this issue Apr 23, 2023 · 0 comments · Fixed by #1778

Comments

@shjlzjq
Copy link

shjlzjq commented Apr 23, 2023

Failing SQL Feature:

  • The final keyword is not recognized when using table alias. if I remove the alias, the parse is ok

SQL Example:

  • Simplified Query Example, focusing on the failing feature
    Statement parse = CCJSqlParserUtil.parse("SELECT column FROM table_name AS tn FINAL");

Exception:

    Exception in thread "main" java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:64)
Caused by: net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "FINAL" <S_IDENTIFIER>
    at line 1, column 37.

Was expecting one of:

    "CONNECT"
    "EMIT"
    "GROUP"
    "HAVING"
    "PIVOT"
    "START"
    "WINDOW"
    <EOF>
    <ST_SEMICOLON>

	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:263)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:81)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:47)
	at com.summit.Test.main(Test.java:119)
	... 5 more
Caused by: java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "FINAL" <S_IDENTIFIER>
    at line 1, column 37.

Was expecting one of:

    "CONNECT"
    "EMIT"
    "GROUP"
    "HAVING"
    "PIVOT"
    "START"
    "WINDOW"
    <EOF>
    <ST_SEMICOLON>

	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:206)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:258)
	... 8 more
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "FINAL" <S_IDENTIFIER>
    at line 1, column 37.

Was expecting one of:

    "CONNECT"
    "EMIT"
    "GROUP"
    "HAVING"
    "PIVOT"
    "START"
    "WINDOW"
    <EOF>
    <ST_SEMICOLON>

	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:38866)
	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:38696)
	at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:306)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil$1.call(CCJSqlParserUtil.java:253)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil$1.call(CCJSqlParserUtil.java:250)
	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
	at java.util.concurrent.FutureTask.run(FutureTask.java)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Software Information:

  • JSQLParser Version : 4.6
  • Database:Clickhouse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant