Skip to content

Conversation

@rkrishn7
Copy link
Contributor

@rkrishn7 rkrishn7 commented Sep 22, 2025

Which issue does this PR close?

What changes are included in this PR?

  • Renames reassign_predicate_columns to reassign_expr_columns
  • Updates usage

Are these changes tested?

No, there should be no changes in functionality.

Are there any user-facing changes?

  • collect_columns_from_predicate has been marked deprecated

@github-actions github-actions bot added physical-expr Changes to the physical-expr crates datasource Changes to the datasource crate physical-plan Changes to the physical-plan crate labels Sep 22, 2025

/// Return the equals Column-Pairs and Non-equals Column-Pairs
pub fn collect_columns_from_predicate(
fn collect_columns_from_predicate(
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'm just realizing this was pub and not pub(crate) so technically this is an API change

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe you can leave a #deprecated version of the old name (that just calles the new name) as described in https://datafusion.apache.org/contributor-guide/api-health.html#deprecation-guidelines

@alamb alamb added the api change Changes the API exposed to users of the crate label Sep 22, 2025
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Seems like a nice cleanup to me. Thank you for the contribution @rkrishn7


/// Return the equals Column-Pairs and Non-equals Column-Pairs
pub fn collect_columns_from_predicate(
fn collect_columns_from_predicate(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe you can leave a #deprecated version of the old name (that just calles the new name) as described in https://datafusion.apache.org/contributor-guide/api-health.html#deprecation-guidelines

// Ignore any binary expressions that reference non-existent columns in the current schema
// (e.g. due to unnecessary projections being removed)
reassign_expr_columns(Arc::clone(expr), schema)
.ok()
Copy link
Contributor

Choose a reason for hiding this comment

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

is this ok actually required? Does anything fail if we remove it?

It seems suspicious to me (though I see it is how the old code works too)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah reassign_expr_columns returns a Result and we're filter mapping over the list of expressions so need to return an Option.

In this case it's okay to discard the result I think (per the comment)

Comment on lines 256 to 259
let index = match schema.index_of(column.name()) {
Ok(idx) => idx,
Err(_) if ignore_not_found => usize::MAX,
Err(e) => return Err(e.into()),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

You could further simplify this to

Suggested change
let index = match schema.index_of(column.name()) {
Ok(idx) => idx,
Err(_) if ignore_not_found => usize::MAX,
Err(e) => return Err(e.into()),
};
let index = match schema.index_of(column.name())?;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes good catch!

@alamb
Copy link
Contributor

alamb commented Sep 26, 2025

@rkrishn7 are we good to merge this PR ? Or do you plan to address the comments prior to merge?

@rkrishn7
Copy link
Contributor Author

Hey @alamb sorry I've been quite busy this week.

I plan to address your comments either today or tomorrow!

@alamb
Copy link
Contributor

alamb commented Sep 26, 2025

Hey @alamb sorry I've been quite busy this week.

I plan to address your comments either today or tomorrow!

Ok, no problem! We can also do it as a follow on PR too if you prefer

@rkrishn7
Copy link
Contributor Author

@alamb Updated w/ your suggestions!

@rkrishn7 rkrishn7 force-pushed the chore/refactor-reassign-predicate-cols branch from d478598 to 8b0fdcb Compare September 27, 2025 18:56
@alamb alamb added this pull request to the merge queue Sep 28, 2025
@alamb
Copy link
Contributor

alamb commented Sep 28, 2025

Thank you @rkrishn7

Merged via the queue into apache:main with commit a8925f3 Sep 28, 2025
28 checks passed
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 datasource Changes to the datasource crate physical-expr Changes to the physical-expr crates physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor usage of reassign_predicate_columns

2 participants