Skip to content

Commit

Permalink
refactor: func choose api&use Error not EvalError
Browse files Browse the repository at this point in the history
  • Loading branch information
discord9 committed Apr 8, 2024
1 parent 097a037 commit 13581ca
Show file tree
Hide file tree
Showing 15 changed files with 760 additions and 280 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

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

13 changes: 13 additions & 0 deletions src/flow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ common-error.workspace = true
common-macro.workspace = true
common-telemetry.workspace = true
common-time.workspace = true
datafusion-substrait.workspace = true
datatypes.workspace = true
enum_dispatch = "0.3"
hydroflow = "0.5.0"
Expand All @@ -23,8 +24,20 @@ serde.workspace = true
servers.workspace = true
smallvec.workspace = true
snafu.workspace = true
strum.workspace = true
tokio.workspace = true
tonic.workspace = true

[dependencies.substrait_proto]
package = "substrait"
version = "0.17"

[dev-dependencies]
catalog.workspace = true
common-catalog.workspace = true
prost.workspace = true
query.workspace = true
serde_json = "1.0"
session.workspace = true
substrait.workspace = true
table.workspace = true
23 changes: 22 additions & 1 deletion src/flow/src/adapter/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ pub enum Error {

#[snafu(display("No protobuf type for value: {value}"))]
NoProtoType { value: Value, location: Location },

#[snafu(display("Not implement in flow: {reason}"))]
NotImplemented { reason: String, location: Location },

#[snafu(display("Flow plan error: {reason}"))]
Plan { reason: String, location: Location },

#[snafu(display("Unsupported temporal filter: {reason}"))]
UnsupportedTemporalFilter { reason: String, location: Location },

#[snafu(display("Datatypes error: {source} with extra message: {extra}"))]
Datatypes {
source: datatypes::Error,
extra: String,
location: Location,
},
}

pub type Result<T> = std::result::Result<T, Error>;
Expand All @@ -64,8 +80,13 @@ impl ErrorExt for Error {
Self::Eval { .. } | &Self::JoinTask { .. } => StatusCode::Internal,
&Self::TableAlreadyExist { .. } => StatusCode::TableAlreadyExists,
Self::TableNotFound { .. } => StatusCode::TableNotFound,
&Self::InvalidQuery { .. } => StatusCode::PlanQuery,
&Self::InvalidQuery { .. } | &Self::Plan { .. } | &Self::Datatypes { .. } => {
StatusCode::PlanQuery
}
Self::NoProtoType { .. } => StatusCode::Unexpected,
&Self::NotImplemented { .. } | Self::UnsupportedTemporalFilter { .. } => {
StatusCode::Unsupported
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/flow/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod id;
mod linear;
mod relation;
mod scalar;
mod signature;

pub(crate) use error::{EvalError, InvalidArgumentSnafu, OptimizeSnafu};
pub(crate) use func::{BinaryFunc, UnaryFunc, UnmaterializableFunc, VariadicFunc};
Expand Down
3 changes: 0 additions & 3 deletions src/flow/src/expr/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ pub enum EvalError {
#[snafu(display("Optimize error: {reason}"))]
Optimize { reason: String, location: Location },

#[snafu(display("Unsupported temporal filter: {reason}"))]
UnsupportedTemporalFilter { reason: String, location: Location },

#[snafu(display("Overflowed during evaluation"))]
Overflow { location: Location },
}
Loading

0 comments on commit 13581ca

Please sign in to comment.