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

refactor(error): show pretty error in planner test #13348

Merged
merged 10 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ arrow-buffer = "48"
arrow-flight = "48"
arrow-select = "48"
arrow-ord = "48"
thiserror-ext = "0.0.5"
thiserror-ext = "0.0.6"
tikv-jemalloc-ctl = { git = "https://github.com/risingwavelabs/jemallocator.git", rev = "64a2d9" }
tikv-jemallocator = { git = "https://github.com/risingwavelabs/jemallocator.git", features = [
"profiling",
Expand Down
2 changes: 1 addition & 1 deletion e2e_test/batch/duckdb/cte/test_cte.test.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ SELECT 1 UNION ALL (WITH cte AS (SELECT 42) SELECT * FROM cte);

# test CTE with nested aliases in where clause
# Note: postgres doesn't support this: column "alias1" does not exist
query error failed to bind expression: alias1
query error Failed to bind expression: alias1
with cte (a) as (
select 1
)
Expand Down
9 changes: 9 additions & 0 deletions src/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,17 @@ pub enum ErrorCode {
#[backtrace]
BoxedError,
),
// TODO: use a new type for bind error
#[error("Bind error: {0}")]
BindError(String),
// TODO: only keep this one
#[error("Failed to bind expression: {expr}: {error}")]
BindErrorRoot {
expr: String,
#[source]
#[backtrace]
error: BoxedError,
},
#[error("Catalog error: {0}")]
CatalogError(
#[source]
Expand Down
1 change: 1 addition & 0 deletions src/frontend/planner_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ risingwave_sqlparser = { workspace = true }
serde = { version = "1", features = ["derive"] }
serde_with = "3"
serde_yaml = "0.9"
thiserror-ext = { workspace = true }
tokio = { version = "0.2", package = "madsim-tokio", features = [
"rt",
"rt-multi-thread",
Expand Down
21 changes: 11 additions & 10 deletions src/frontend/planner_test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use risingwave_sqlparser::ast::{
};
use risingwave_sqlparser::parser::Parser;
use serde::{Deserialize, Serialize};
use thiserror_ext::AsReport;

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Hash, Eq)]
#[serde(deny_unknown_fields, rename_all = "snake_case")]
Expand Down Expand Up @@ -578,7 +579,7 @@ impl TestCase {
match binder.bind(stmt.clone()) {
Ok(bound) => bound,
Err(err) => {
ret.binder_error = Some(err.to_string());
ret.binder_error = Some(err.to_report_string_pretty());
return Ok(ret);
}
}
Expand All @@ -594,7 +595,7 @@ impl TestCase {
logical_plan
}
Err(err) => {
ret.planner_error = Some(err.to_string());
ret.planner_error = Some(err.to_report_string_pretty());
return Ok(ret);
}
};
Expand All @@ -608,7 +609,7 @@ impl TestCase {
match logical_plan.gen_optimized_logical_plan_for_batch() {
Ok(optimized_logical_plan_for_batch) => optimized_logical_plan_for_batch,
Err(err) => {
ret.optimizer_error = Some(err.to_string());
ret.optimizer_error = Some(err.to_report_string_pretty());
return Ok(ret);
}
};
Expand All @@ -632,7 +633,7 @@ impl TestCase {
match logical_plan.gen_optimized_logical_plan_for_stream() {
Ok(optimized_logical_plan_for_stream) => optimized_logical_plan_for_stream,
Err(err) => {
ret.optimizer_error = Some(err.to_string());
ret.optimizer_error = Some(err.to_report_string_pretty());
return Ok(ret);
}
};
Expand All @@ -659,12 +660,12 @@ impl TestCase {
Ok(batch_plan) => match logical_plan.gen_batch_distributed_plan(batch_plan) {
Ok(batch_plan) => batch_plan,
Err(err) => {
ret.batch_error = Some(err.to_string());
ret.batch_error = Some(err.to_report_string_pretty());
break 'batch;
}
},
Err(err) => {
ret.batch_error = Some(err.to_string());
ret.batch_error = Some(err.to_report_string_pretty());
break 'batch;
}
};
Expand All @@ -691,12 +692,12 @@ impl TestCase {
Ok(batch_plan) => match logical_plan.gen_batch_local_plan(batch_plan) {
Ok(batch_plan) => batch_plan,
Err(err) => {
ret.batch_error = Some(err.to_string());
ret.batch_error = Some(err.to_report_string_pretty());
break 'local_batch;
}
},
Err(err) => {
ret.batch_error = Some(err.to_string());
ret.batch_error = Some(err.to_report_string_pretty());
break 'local_batch;
}
};
Expand Down Expand Up @@ -759,7 +760,7 @@ impl TestCase {
) {
Ok((stream_plan, _)) => stream_plan,
Err(err) => {
*ret_error_str = Some(err.to_string());
*ret_error_str = Some(err.to_report_string_pretty());
continue;
}
};
Expand Down Expand Up @@ -799,7 +800,7 @@ impl TestCase {
break 'sink;
}
Err(err) => {
ret.sink_error = Some(err.to_string());
ret.sink_error = Some(err.to_report_string_pretty());
break 'sink;
}
}
Expand Down
Loading
Loading