-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add evaluate_demo
and range_analysis_demo
to Expr examples
#8377
Changes from 1 commit
b6f5dce
5fc0bdd
b5deaee
6f902f9
8ff8300
65bc287
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 |
---|---|---|
|
@@ -72,8 +72,12 @@ impl AnalysisContext { | |
} | ||
} | ||
|
||
/// Represents the boundaries of the resulting value from a physical expression, | ||
/// if it were to be an expression, if it were to be evaluated. | ||
/// Represents the boundaries (e.g. min and max values) of a particular column | ||
/// | ||
/// This is used range analysis of expressions, to determine if the expression | ||
/// limits the value of particular columns (e.g. analyzing an expression such as | ||
/// `time < 50` would result in a boundary interval for `time` having a max | ||
/// value of `50`). | ||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct ExprBoundaries { | ||
pub column: Column, | ||
|
@@ -111,6 +115,22 @@ impl ExprBoundaries { | |
distinct_count: col_stats.distinct_count.clone(), | ||
}) | ||
} | ||
|
||
/// Create `ExprBoundaries` that represent no known bounds for all the columns `schema` | ||
pub fn try_new_unknown(schema: &Schema) -> Result<Vec<Self>> { | ||
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. This was added to make the demo easier to write (I ported it from IOx downstream) 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. Might unbounded be more obvious a name than unknown? 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.
I agree -- will change. |
||
schema | ||
.fields() | ||
.iter() | ||
.enumerate() | ||
.map(|(i, field)| { | ||
Ok(Self { | ||
column: Column::new(field.name(), i), | ||
interval: Interval::make_unbounded(field.data_type())?, | ||
distinct_count: Precision::Absent, | ||
}) | ||
}) | ||
.collect() | ||
} | ||
} | ||
|
||
/// Attempts to refine column boundaries and compute a selectivity value. | ||
|
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.
This is a really powerful feature of DataFusion and I don't think it is widely understood yet