Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Oct 31, 2024

Which issue does this PR close?

Related to

Rationale for this change

While reviewing #13128 I noticed that the code got a bit more complicated because Expr::volatile returns Result<bool> and thus the calling code needs now to pass up Results

However, Expr::volatile is actually infallible (never returns an error) so let's mark it as such to keep the code simpler

This is also consistent with other Expr methods such as Expr::any_column_refs

What changes are included in this PR?

  1. Minor: Expr::volatile infallible

Are these changes tested?

By existing CI

Are there any user-facing changes?

  • The signature of Expr::volatile has changed

@alamb alamb added the api change Changes the API exposed to users of the crate label Oct 31, 2024
@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules labels Oct 31, 2024
Copy link
Contributor

@peter-toth peter-toth left a comment

Choose a reason for hiding this comment

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

LGTM, this looks like the same idea as #13128 (comment)

Copy link
Contributor

@eejbyfeldt eejbyfeldt left a comment

Choose a reason for hiding this comment

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

LGTM!

///
/// See [`Volatility`] for more information.
pub fn is_volatile(&self) -> bool {
self.exists(|expr| Ok(expr.is_volatile_node())).unwrap()
Copy link
Member

Choose a reason for hiding this comment

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

Add code comment why unwrap is safe here.

btw maybe we can have exists variant which doesn't throw?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add the comment in a follow on PR The non fallable exists variant is an interesting idea -- maybe we can file a follow on issue for it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Follow on PR: #13217

@alamb
Copy link
Contributor Author

alamb commented Nov 1, 2024

Thanks @findepi @peter-toth @jonahgao and @eejbyfeldt for the review -- I am going to merge this PR as it logically conflicts with #13128 so I can rebase that PR

@alamb alamb merged commit a34e237 into apache:main Nov 1, 2024
@alamb alamb deleted the alamb/volatile_is_infallible branch November 1, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api change Changes the API exposed to users of the crate logical-expr Logical plan and expressions optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants