Skip to content

feat: Add From<Option<T>> trait for Precision enum - #22792

Merged
kosiew merged 5 commits into
apache:mainfrom
devanbenz:db/opt-to-precision
Jun 10, 2026
Merged

feat: Add From<Option<T>> trait for Precision enum#22792
kosiew merged 5 commits into
apache:mainfrom
devanbenz:db/opt-to-precision

Conversation

@devanbenz

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added the common Related to common crate label Jun 6, 2026
@devanbenz
devanbenz marked this pull request as ready for review June 8, 2026 15:56

@kosiew kosiew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@devanbenz
Thanks for your contribution. I left one small non-blocking suggestion.

}

impl<T: Debug + Clone + PartialEq + Eq + PartialOrd> From<Option<T>> for Precision<T> {
fn from(option: Option<T>) -> Self {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small readability suggestion: this Option match can be collapsed without changing behavior. This keeps the mapping from Some to Exact and None to Absent pretty direct:

option.map_or(Precision::Absent, Precision::Exact)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, made the changes.

@kosiew
kosiew added this pull request to the merge queue Jun 10, 2026
Merged via the queue into apache:main with commit d77a02d Jun 10, 2026
35 checks passed
AdamGS pushed a commit to AdamGS/arrow-datafusion that referenced this pull request Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants