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

[Enhance](Nereids)when both Nereids and old parsers report errors, prompt error messages for the Nereids #28580

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected void handleQuery(MysqlCommand mysqlCommand, String originStmt) {
.setSqlHash(ctx.getSqlHash());

List<StatementBase> stmts = null;

Exception nereidsParseException = null;
// Nereids do not support prepare and execute now, so forbid prepare command, only process query command
if (mysqlCommand == MysqlCommand.COM_QUERY && ctx.getSessionVariable().isEnableNereidsPlanner()) {
try {
Expand All @@ -195,6 +195,7 @@ protected void handleQuery(MysqlCommand mysqlCommand, String originStmt) {
// TODO: We should catch all exception here until we support all query syntax.
LOG.debug("Nereids parse sql failed. Reason: {}. Statement: \"{}\".",
e.getMessage(), convertedStmt);
nereidsParseException = e;
}
}

Expand All @@ -203,6 +204,12 @@ protected void handleQuery(MysqlCommand mysqlCommand, String originStmt) {
try {
stmts = parse(convertedStmt);
} catch (Throwable throwable) {
// if NereidsParser and oldParser both failed,
// prove is a new feature implemented only on the nereids,
// so an error message for the new nereids is thrown
if (nereidsParseException != null) {
throwable = nereidsParseException;
}
// Parse sql failed, audit it and return
handleQueryException(throwable, convertedStmt, null, null);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ suite("test_current_timestamp") {
DISTRIBUTED BY HASH(id)
PROPERTIES("replication_num" = "1");
"""
exception "errCode = 2, detailMessage = Internal Error, maybe syntax error or this is a bug: column's default value current_timestamp precision must be between 0 and 6"
exception "between 0 and 6"
}

// user case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ suite("test_bitmap_int") {

test {
sql """SELECT case id_bitmap when 1 then 1 else 0 FROM test_bitmap;"""
exception "errCode"
exception "ParseException"
}

qt_sql64_4 """SELECT id_bitmap FROM test_bitmap WHERE id_bitmap is null LIMIT 20;"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ suite("test_nestedtypes_insert_into_select", "p0") {

test {
sql "insert into ast values ('text' , [named_struct('a',1,'b','home'),named_struct('a',2,'b','work')]);"
exception "errCode = 2, detailMessage = Sql parser can't convert the result to array, please check your sql."
exception "ParseException"
}
}
2 changes: 1 addition & 1 deletion regression-test/suites/demo_p0/test_action.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ suite("test_action") {
test {
sql "abcdefg"
// check exception message contains
exception "errCode = 2, detailMessage = Syntax error"
exception "ParseException"
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@ suite("nereids_update_on_current_timestamp") {
k int,
`update_time` datetime(6) default current_timestamp(4) on update current_timestamp(3)) replace,
) AGGREGATE KEY(k) DISTRIBUTED BY HASH(k) BUCKETS 1 properties("replication_num" = "1");"""
exception "Syntax error"
exception "ParseException"
}
}
2 changes: 1 addition & 1 deletion regression-test/suites/query_p0/join/test_join2.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ suite("test_join2", "query,p0,arrow_flight_sql") {
FROM ${TBname1} NATURAL JOIN ${TBname2}
ORDER BY 1,2,3,4,5,6;
"""
exception "errCode = 2, detailMessage = natural join is not supported, please use inner join instead."
exception "ParseException"
}

qt_join4 """
Expand Down
Loading