fix: Return a different error type to distinguish different situations
parent
a4f51d99f6
commit
c7f52ce362
|
@ -28,6 +28,9 @@ pub enum Error {
|
||||||
|
|
||||||
#[snafu(display("unsupported column operation on column \"{}\": {}", column_name, msg))]
|
#[snafu(display("unsupported column operation on column \"{}\": {}", column_name, msg))]
|
||||||
UnsupportedColumnOperation { msg: String, column_name: String },
|
UnsupportedColumnOperation { msg: String, column_name: String },
|
||||||
|
|
||||||
|
#[snafu(display("column \"{column_name}\" does not exist"))]
|
||||||
|
ColumnDoesNotExist { column_name: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
||||||
|
@ -772,9 +775,8 @@ impl MetaData {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
return UnsupportedColumnOperationSnafu {
|
return ColumnDoesNotExistSnafu {
|
||||||
column_name: expr.column().to_owned(),
|
column_name: expr.column().to_owned(),
|
||||||
msg: "column does not exist",
|
|
||||||
}
|
}
|
||||||
.fail()
|
.fail()
|
||||||
}
|
}
|
||||||
|
@ -1768,14 +1770,16 @@ west,host-b,100
|
||||||
);
|
);
|
||||||
|
|
||||||
// invalid predicate
|
// invalid predicate
|
||||||
assert!(table
|
assert!(matches!(
|
||||||
|
table
|
||||||
.column_names(
|
.column_names(
|
||||||
&Predicate::new(vec![BinaryExpr::from(("time", ">=", "not a number"))]),
|
&Predicate::new(vec![BinaryExpr::from(("time", ">=", "not a number"))]),
|
||||||
&[],
|
&[],
|
||||||
Selection::All,
|
Selection::All,
|
||||||
dst,
|
dst,
|
||||||
)
|
),
|
||||||
.is_err());
|
Err(Error::UnsupportedColumnOperation { column_name, .. }) if column_name == "time",
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue