Skip to content

Commit d77a02d

Browse files
authored
feat: Add From<Option<T>> trait for Precision enum (#22792)
This commit adds a `From<Option<T>>` trait for `Precision`. Porting from `influxdb` to upstream: https://github.com/influxdata/influxdb/blob/70335b158808881c2f5a9ef27cd4bcbe4944686a/core/datafusion_util/src/lib.rs#L153-L163
1 parent 40a6454 commit d77a02d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎datafusion/common/src/stats.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ impl Precision<ScalarValue> {
318318
}
319319
}
320320

321+
impl<T: Debug + Clone + PartialEq + Eq + PartialOrd> From<Option<T>> for Precision<T> {
322+
fn from(option: Option<T>) -> Self {
323+
option.map_or(Precision::Absent, Precision::Exact)
324+
}
325+
}
326+
321327
impl<T: Debug + Clone + PartialEq + Eq + PartialOrd> Debug for Precision<T> {
322328
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
323329
match self {

0 commit comments

Comments
 (0)