Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Jun 22, 2024

Which issue does this PR close?

Part of #10505

Rationale for this change

We made an API to find column references without copying strings in #10948 and we should use it more.

What changes are included in this PR?

  1. Update some more of the code to use the Expr::column_refs API introduced in Add Expr::column_refs to find column references without copying #10948 to avoid copying

Are these changes tested?

Covered by existing CI

Are there any user-facing changes?

No (though perhaps slightly faster planning)

@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules core Core DataFusion crate labels Jun 22, 2024
Some(expr) => {
// Extract columns from filter expression and saved in a HashSet
let cols = expr.to_columns()?;
let cols = expr.column_refs();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this saves copying all the Columns (which have owned strings in them)

/// Returns true if all columns in col_refs are in `schema_cols`
///
/// Note: can't use `HashSet::intersect` here because they have different types.
pub(crate) fn has_all_refs(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can rename it to better reflect if all columns in col_refs are in schema_cols` ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in d4346f3

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

lgtm thanks @alamb

@comphead comphead merged commit 3051d19 into apache:main Jun 23, 2024
@alamb alamb deleted the alamb/less_to_column2 branch June 24, 2024 22:28
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
…che#11067)

* Migrate code from `Expr::to_columns`  to `Expr::column_refs`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants