From c7f52ce3628242e2958b3fda324015b20f69fa5f Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Thu, 2 Jun 2022 15:15:25 -0400 Subject: [PATCH] fix: Return a different error type to distinguish different situations --- read_buffer/src/table.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/read_buffer/src/table.rs b/read_buffer/src/table.rs index 0e30c8da7a..722e8a0640 100644 --- a/read_buffer/src/table.rs +++ b/read_buffer/src/table.rs @@ -28,6 +28,9 @@ pub enum Error { #[snafu(display("unsupported column operation on column \"{}\": {}", column_name, msg))] UnsupportedColumnOperation { msg: String, column_name: String }, + + #[snafu(display("column \"{column_name}\" does not exist"))] + ColumnDoesNotExist { column_name: String }, } pub type Result = std::result::Result; @@ -772,9 +775,8 @@ impl MetaData { } }, None => { - return UnsupportedColumnOperationSnafu { + return ColumnDoesNotExistSnafu { column_name: expr.column().to_owned(), - msg: "column does not exist", } .fail() } @@ -1768,14 +1770,16 @@ west,host-b,100 ); // invalid predicate - assert!(table - .column_names( - &Predicate::new(vec![BinaryExpr::from(("time", ">=", "not a number"))]), - &[], - Selection::All, - dst, - ) - .is_err()); + assert!(matches!( + table + .column_names( + &Predicate::new(vec![BinaryExpr::from(("time", ">=", "not a number"))]), + &[], + Selection::All, + dst, + ), + Err(Error::UnsupportedColumnOperation { column_name, .. }) if column_name == "time", + )); } #[test]