Skip to content

Commit 7a265e7

Browse files
def-patrickwwbutler
authored andcommitted
SLT: Improve error message on mismatch from inconsistent view (MaterializeInc#35080)
Inspired by https://materializeinc.slack.com/archives/C08ACQNGSQK/p1771493850878619 Old error message: ``` SELECT ARRAY[NULL::BIGINT[], ARRAY[1::BIGINT, 2::BIGINT]]; InconsistentViewOutcome:test/sqllogictest/arrays.slt:1467 expected from query: Success actually from indexed view: PlanFailure { error: db error Caused by: ERROR: Evaluation error: number of array elements (1) does not match declared cardinality (0) Stack backtrace: 0: <anyhow::Error as core::convert::From<tokio_postgres::error::Error>>::from at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/anyhow-1.0.101/src/backtrace.rs:27:14 1: <tokio_postgres::error::Error as core::convert::Into<anyhow::Error>>::into at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:778:9 2: <anyhow::kind::Trait>::new::<tokio_postgres::error::Error> at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/anyhow-1.0.101/src/kind.rs:95:15 3: <mz_sqllogictest::runner::RunnerInner>::execute_query::{closure#0} at ./src/sqllogictest/src/runner.rs:1580:40 4: <mz_sqllogictest::runner::RunnerInner>::execute_view::{closure#0} at ./src/sqllogictest/src/runner.rs:1761:18 5: <mz_sqllogictest::runner::RunnerInner>::run_query::{closure#0} at ./src/sqllogictest/src/runner.rs:1805:34 6: <mz_sqllogictest::runner::RunnerInner>::run_record::{closure#0} at ./src/sqllogictest/src/runner.rs:1385:22 7: <mz_sqllogictest::runner::Runner>::run_record::{closure#0} at ./src/sqllogictest/src/runner.rs:793:18 8: mz_sqllogictest::runner::run_string::{closure#0} at ./src/sqllogictest/src/runner.rs:2124:14 9: mz_sqllogictest::runner::run_file::{closure#0} at ./src/sqllogictest/src/runner.rs:2175:83 10: sqllogictest::main::{closure#0} at ./src/sqllogictest/src/bin/sqllogictest.rs:231:71 11: <core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>> as core::future::future::Future>::poll at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:133:9 12: <tracing::instrument::Instrumented<core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>>> as core::future::future::Future>::poll at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.44/src/instrument.rs:321:15 13: <tokio::runtime::park::CachedParkThread>::block_on::<tracing::instrument::Instrumented<core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>>>>::{closure#0} at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/park.rs:285:71 14: tokio::task::coop::with_budget::<core::task::poll::Poll<std::process::ExitCode>, <tokio::runtime::park::CachedParkThread>::block_on<tracing::instrument::Instrumented<core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>>>>::{closure#0}> at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:167:5 15: tokio::task::coop::budget::<core::task::poll::Poll<std::process::ExitCode>, <tokio::runtime::park::CachedParkThread>::block_on<tracing::instrument::Instrumented<core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>>>>::{closure#0}> at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/task/coop/mod.rs:133:5 16: <tokio::runtime::park::CachedParkThread>::block_on::<tracing::instrument::Instrumented<core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>>>> at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/park.rs:285:31 17: <tokio::runtime::context::blocking::BlockingRegionGuard>::block_on::<tracing::instrument::Instrumented<core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>>>> at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/blocking.rs:66:14 18: <tokio::runtime::scheduler::multi_thread::MultiThread>::block_on::<tracing::instrument::Instrumented<core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>>>>::{closure#0} at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/multi_thread/mod.rs:87:22 19: tokio::runtime::context::runtime::enter_runtime::<<tokio::runtime::scheduler::multi_thread::MultiThread>::block_on<tracing::instrument::Instrumented<core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>>>>::{closure#0}, std::process::ExitCode> at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/context/runtime.rs:65:16 20: <tokio::runtime::scheduler::multi_thread::MultiThread>::block_on::<tracing::instrument::Instrumented<core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>>>> at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/scheduler/multi_thread/mod.rs:86:9 21: <tokio::runtime::runtime::Runtime>::block_on_inner::<core::pin::Pin<alloc::boxed::Box<sqllogictest::main::{closure#0}>>> at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:370:50 22: <tokio::runtime::runtime::Runtime>::block_on::<sqllogictest::main::{closure#0}> at /home/deen/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.48.0/src/runtime/runtime.rs:340:18 23: sqllogictest::main at ./src/sqllogictest/src/bin/sqllogictest.rs:313:15 24: <fn() -> std::process::ExitCode as core::ops::function::FnOnce<()>>::call_once at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5 25: std::sys::backtrace::__rust_begin_short_backtrace::<fn() -> std::process::ExitCode, std::process::ExitCode> at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:166:18 26: std::rt::lang_start::<std::process::ExitCode>::{closure#0} at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:206:18 27: <&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe as core::ops::function::FnOnce<()>>::call_once at /rustc/842bd5be253e17831e318fdbd9d01d716557cc75/library/core/src/ops/function.rs:287:21 28: std::panicking::catch_unwind::do_call::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32> at /rustc/842bd5be253e17831e318fdbd9d01d716557cc75/library/std/src/panicking.rs:581:40 29: std::panicking::catch_unwind::<i32, &dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe> at /rustc/842bd5be253e17831e318fdbd9d01d716557cc75/library/std/src/panicking.rs:544:19 30: std::panic::catch_unwind::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32> at /rustc/842bd5be253e17831e318fdbd9d01d716557cc75/library/std/src/panic.rs:359:14 31: std::rt::lang_start_internal::{closure#0} at /rustc/842bd5be253e17831e318fdbd9d01d716557cc75/library/std/src/rt.rs:175:24 32: std::panicking::catch_unwind::do_call::<std::rt::lang_start_internal::{closure#0}, isize> at /rustc/842bd5be253e17831e318fdbd9d01d716557cc75/library/std/src/panicking.rs:581:40 33: std::panicking::catch_unwind::<isize, std::rt::lang_start_internal::{closure#0}> at /rustc/842bd5be253e17831e318fdbd9d01d716557cc75/library/std/src/panicking.rs:544:19 34: std::panic::catch_unwind::<std::rt::lang_start_internal::{closure#0}, isize> at /rustc/842bd5be253e17831e318fdbd9d01d716557cc75/library/std/src/panic.rs:359:14 35: std::rt::lang_start_internal at /rustc/842bd5be253e17831e318fdbd9d01d716557cc75/library/std/src/rt.rs:171:5 36: std::rt::lang_start::<std::process::ExitCode> at /home/deen/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:205:5 37: main 38: __libc_start_call_main at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16 39: __libc_start_main_impl at ./csu/../csu/libc-start.c:360:3 40: _start, location: Location { file: "test/sqllogictest/arrays.slt", line: 1467 } } ``` New error message: ``` SELECT ARRAY[NULL::BIGINT[], ARRAY[1::BIGINT, 2::BIGINT]]; InconsistentViewOutcome:test/sqllogictest/arrays.slt:1467 expected from query: Success actually from indexed view: PlanFailure:test/sqllogictest/arrays.slt:1467: error does not match expected pattern: expected: /db error: ERROR: number of array elements \(1\) does not match declared cardinality \(0\)/ actual: db error: ERROR: Evaluation error: number of array elements (1) does not match declared cardinality (0) ```
1 parent 543c7e9 commit 7a265e7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/sqllogictest/src/runner.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ impl fmt::Display for Outcome<'_> {
305305
location,
306306
} => write!(
307307
f,
308-
"InconsistentViewOutcome:{}{}expected from query: {:?}{}actually from indexed view: {:?}{}",
309-
location, INDENT, query_outcome, INDENT, view_outcome, INDENT
308+
"InconsistentViewOutcome:{}{}expected from query: {}{}actually from indexed view: {}",
309+
location, INDENT, query_outcome, INDENT, view_outcome
310310
),
311311
Bail { cause, location } => write!(f, "Bail:{} {}", location, cause),
312312
Warning { cause, location } => write!(f, "Warning:{} {}", location, cause),
@@ -1577,7 +1577,11 @@ impl<'a> RunnerInner<'a> {
15771577
Ok(Outcome::Success)
15781578
} else {
15791579
Ok(Outcome::PlanFailure {
1580-
error: anyhow!(error),
1580+
error: anyhow!(
1581+
"error does not match expected pattern:\n expected: /{}/\n actual: {}",
1582+
expected_error,
1583+
error_string
1584+
),
15811585
location,
15821586
})
15831587
}
@@ -1702,7 +1706,11 @@ impl<'a> RunnerInner<'a> {
17021706
Some(Outcome::Success)
17031707
} else {
17041708
Some(Outcome::PlanFailure {
1705-
error: view_error.into(),
1709+
error: anyhow!(
1710+
"error does not match expected pattern:\n expected: /{}/\n actual: {}",
1711+
expected_error,
1712+
view_error.to_string_with_causes()
1713+
),
17061714
location: location.clone(),
17071715
})
17081716
}

0 commit comments

Comments
 (0)