Skip to content

Commit

Permalink
refactor(error): show pretty error in planner test (#13348)
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao authored Nov 10, 2023
1 parent 4c78170 commit e71d94f
Show file tree
Hide file tree
Showing 35 changed files with 330 additions and 311 deletions.
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 @@ -122,7 +122,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
2 changes: 1 addition & 1 deletion e2e_test/ddl/table/generated_columns.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ statement ok
drop source t4;

# create a table with generated column now
statement error failed to bind expression: now()
statement error Failed to bind expression: now()
CREATE TABLE t (v INT, t timestamptz as now()) WITH (
connector = 'datagen',
fields.v.kind = 'sequence',
Expand Down
8 changes: 3 additions & 5 deletions e2e_test/error_ui/main.slt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ select v1 + v2 = v3;
----
db error: ERROR: QueryError

Caused by this error:
1: Bind error: failed to bind expression: v1 + v2 = v3

Caused by:
Item not found: Invalid column: v1
Caused by these errors (recent errors listed first):
1: Failed to bind expression: v1 + v2 = v3
2: Item not found: Invalid column: v1


query error
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 @@ -129,8 +129,17 @@ pub enum ErrorCode {
// `tonic::transport::Error`, `TonicStatusWrapper`, or `RpcError`
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

0 comments on commit e71d94f

Please sign in to comment.