-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make ExpressionHandler::get_evaluator
fallible
#577
base: main
Are you sure you want to change the base?
Changes from 8 commits
c6025aa
468f988
f243d42
8302483
1e03c5f
2588b3e
cb613dc
9f6e617
91bfcd8
7d03266
b4bad36
e7b01b2
6be446d
0b838f0
22f9a3a
51295ea
fa7c9ff
4178d01
d8bc768
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
use std::clone::Clone; | ||
use std::collections::HashSet; | ||
use std::iter; | ||
use std::sync::{Arc, LazyLock}; | ||
|
||
use tracing::debug; | ||
|
@@ -239,29 +238,21 @@ impl LogReplayScanner { | |
pub fn scan_action_iter( | ||
engine: &dyn Engine, | ||
action_iter: impl Iterator<Item = DeltaResult<(Box<dyn EngineData>, bool)>> + 'static, | ||
table_schema: &SchemaRef, | ||
predicate: Option<ExpressionRef>, | ||
) -> Box<dyn Iterator<Item = DeltaResult<ScanData>>> { | ||
let mut log_scanner = LogReplayScanner::new(engine, table_schema, predicate); | ||
match engine.get_expression_handler().get_evaluator( | ||
physical_predicate: Option<(ExpressionRef, SchemaRef)>, | ||
) -> DeltaResult<impl Iterator<Item = DeltaResult<ScanData>>> { | ||
let mut log_scanner = LogReplayScanner::new(engine, physical_predicate); | ||
let add_transform = engine.get_expression_handler().get_evaluator( | ||
get_log_add_schema().clone(), | ||
get_add_transform_expr(), | ||
SCAN_ROW_DATATYPE.clone(), | ||
) { | ||
Ok(add_transform) => Box::new( | ||
action_iter | ||
.map(move |action_res| { | ||
let (batch, is_log_batch) = action_res?; | ||
log_scanner.process_scan_batch( | ||
add_transform.as_ref(), | ||
batch.as_ref(), | ||
is_log_batch, | ||
) | ||
}) | ||
.filter(|res| res.as_ref().map_or(true, |(_, sv)| sv.contains(&true))), | ||
), | ||
Err(e) => Box::new(iter::once(Err(e))), | ||
} | ||
)?; | ||
|
||
Ok(action_iter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: it's very subjective, but in general I find this sort of multi-line, multi-operation let actions = action_iter
...
.filter(...);
Ok(actions) Wrapping a single function call or struct creation isn't so bad, because conceptually only one thing is happening, e.g. this code above is not particularly difficult to read: Ok(Arc::new(DefaultExpressionEvaluator {
...
})) Clippy seems to take a similar stance on monadic chains -- it will almost always force newlines between chained function calls, if more than one of the functions takes args or even if the line gets very long (long before the 100-char line limit). |
||
.map(move |action_res| { | ||
let (batch, is_log_batch) = action_res?; | ||
log_scanner.process_scan_batch(add_transform.as_ref(), batch.as_ref(), is_log_batch) | ||
}) | ||
.filter(|res| res.as_ref().map_or(true, |(_, sv)| sv.contains(&true)))) | ||
} | ||
|
||
#[cfg(test)] | ||
|
@@ -301,7 +292,8 @@ mod tests { | |
&[true, false], | ||
(), | ||
validate_simple, | ||
); | ||
) | ||
.unwrap(); | ||
} | ||
|
||
#[test] | ||
|
@@ -311,6 +303,7 @@ mod tests { | |
&[false, false, true, false], | ||
(), | ||
validate_simple, | ||
); | ||
) | ||
.unwrap(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,6 +253,7 @@ mod tests { | |
&[true, false], | ||
context, | ||
validate_visit, | ||
); | ||
) | ||
.unwrap(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(more below)