Skip to content

Commit 96a2086

Browse files
authored
Minor: Interval singleton (#15859)
* interval singleron * fmt * impl from
1 parent 40ed90e commit 96a2086

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

datafusion/expr-common/src/interval_arithmetic.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,18 @@ impl Display for Interval {
949949
}
950950
}
951951

952+
impl From<ScalarValue> for Interval {
953+
fn from(value: ScalarValue) -> Self {
954+
Self::new(value.clone(), value)
955+
}
956+
}
957+
958+
impl From<&ScalarValue> for Interval {
959+
fn from(value: &ScalarValue) -> Self {
960+
Self::new(value.to_owned(), value.to_owned())
961+
}
962+
}
963+
952964
/// Applies the given binary operator the `lhs` and `rhs` arguments.
953965
pub fn apply_operator(op: &Operator, lhs: &Interval, rhs: &Interval) -> Result<Interval> {
954966
match *op {

datafusion/physical-expr/src/equivalence/properties/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ fn get_expr_properties(
16001600
} else if let Some(literal) = expr.as_any().downcast_ref::<Literal>() {
16011601
Ok(ExprProperties {
16021602
sort_properties: SortProperties::Singleton,
1603-
range: Interval::try_new(literal.value().clone(), literal.value().clone())?,
1603+
range: literal.value().into(),
16041604
preserves_lex_ordering: true,
16051605
})
16061606
} else {

0 commit comments

Comments
 (0)