Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions datafusion/expr-common/src/interval_arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ impl Interval {
}
}

/// Create a new `Interval` with the same lower and upper bounds.
pub fn try_singleton(value: ScalarValue) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better name for this function would be just "singleton". Functions named try_* imply they are fallible and generally return a Result type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idiomatic possibility would be to implement From<ScalarValue> for Interval.

Copy link
Contributor Author

@jayzhan211 jayzhan211 Apr 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idiomatic possibility would be to implement From for Interval.

Sounds good!

Self::new(value.clone(), value)
}

/// Only for internal usage. Responsible for standardizing booleans and
/// floating-point values, as well as fixing NaNs. It doesn't validate
/// the given bounds for ordering, or verify that they have the same data
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/equivalence/properties/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ fn get_expr_properties(
} else if let Some(literal) = expr.as_any().downcast_ref::<Literal>() {
Ok(ExprProperties {
sort_properties: SortProperties::Singleton,
range: Interval::try_new(literal.value().clone(), literal.value().clone())?,
range: Interval::try_singleton(literal.value().clone()),
preserves_lex_ordering: true,
})
} else {
Expand Down