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

parser sql of MySQL create or alter table with partition occur exception #1668

Open
krihy opened this issue Nov 17, 2022 · 1 comment
Open

Comments

@krihy
Copy link

krihy commented Nov 17, 2022

Hi:
when use JSqlParser to parse sql then occur exception

Test create table ddl with range partition code like blew:

@test
public void test_CreateTablePartition() throws JSQLParserException {
String sqlString = "CREATE TABLE t1 (\n"
+ " id INT,\n"
+ " year_col INT\n"
+ ")\n"
+ "PARTITION BY RANGE (year_col) (\n"
+ " PARTITION p0 VALUES LESS THAN (1991),\n"
+ " PARTITION p1 VALUES LESS THAN (1995),\n"
+ " PARTITION p2 VALUES LESS THAN (1999)\n"
+ ");";
Statement statement = CCJSqlParserUtil.parse(sqlString);
}

Exception like blew:

Caused by: java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "RANGE" "RANGE"
at line 5, column 14.

Was expecting one of:

";"
"AS"
"DISABLE"
"ENABLE"
"LIKE"
<EOF>

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)
... 74 more

Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "RANGE" "RANGE"
at line 5, column 14.

Was expecting one of:

";"
"AS"
"DISABLE"
"ENABLE"
"LIKE"
<EOF>

at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:33398)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:33231)
at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:167)
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(FutureTask.java:266)
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:750)

=======================================================

Test alter table ddl with range partition code like blew:

@test
public void test_alterTablePartition() throws JSQLParserException {

    String sqlString = "ALTER TABLE t1 ADD PARTITION (PARTITION p3 VALUES LESS THAN (2002))";
      Statement statement = CCJSqlParserUtil.parse(sqlString);
}

`
Exception blew:

Caused by: java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 1, column 30.

Was expecting:

"COMMENT"

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)
... 74 more

Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 1, column 30.

@manticore-projects
Copy link
Contributor

Greetings.

PARTITION is not supported/implemented for both CREATE TABLE and ALTER TABLE statements.
Please either send a PR or sponsor an implementation, when you are interested in this feature.

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

No branches or pull requests

2 participants