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

[BugFix] Fix Expr::open crash when evaluate const throw exception #52752

Merged
merged 1 commit into from
Nov 11, 2024
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
6 changes: 5 additions & 1 deletion be/src/exprs/expr_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ Status ExprContext::open(RuntimeState* state) {
// original's fragment state and only need to have thread-local state initialized.
FunctionContext::FunctionStateScope scope =
_is_clone ? FunctionContext::THREAD_LOCAL : FunctionContext::FRAGMENT_LOCAL;
return _root->open(state, this, scope);
try {
return _root->open(state, this, scope);
} catch (std::runtime_error& e) {
return Status::RuntimeError(fmt::format("Expr evaluate meet error: {}", e.what()));
}
}

Status ExprContext::open(std::vector<ExprContext*> evals, RuntimeState* state) {
Expand Down
12 changes: 12 additions & 0 deletions test/sql/test_exception/R/test_number_overflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- name: test_number_overflow
set sql_mode="ERROR_IF_OVERFLOW";
-- result:
-- !result
select cast(abs(1234567890123456789) as decimal(4,3));
-- result:
[REGEX].*Expr evaluate meet error: The type cast from other types to decimal overflows.*
-- !result
select 1 in (cast(abs(1234567890123456789) as decimal(4,3)), cast(abs(1234567890123456789) as decimal(4,3)));
-- result:
[REGEX].*Expr evaluate meet error: The type cast from other types to decimal overflows.*
-- !result
7 changes: 7 additions & 0 deletions test/sql/test_exception/T/test_number_overflow
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- name: test_number_overflow
set sql_mode="ERROR_IF_OVERFLOW";

-- exception in evaluate
select cast(abs(1234567890123456789) as decimal(4,3));
-- exception in open
select 1 in (cast(abs(1234567890123456789) as decimal(4,3)), cast(abs(1234567890123456789) as decimal(4,3)));
Loading