Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve PhysicalExpr and Column documentation #12457

Merged
merged 2 commits into from
Sep 14, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Sep 13, 2024

Which issue does this PR close?

Part of #4028

Rationale for this change

While working with @itsjunetime on #12135

I noticed that the description / documentation of PhysicalExpr was not as clear as it could be:

  1. It didn't really talk about the use of column indexes vs names
  2. The trait itself was not well documented
  3. The Column epr was also not as well documented as it could be

What changes are included in this PR?

Improve the documentation so this is clearer

Are these changes tested?

By docs CI

Are there any user-facing changes?

No functional changes, only documentation

@github-actions github-actions bot added the physical-expr Physical Expressions label Sep 13, 2024
@@ -31,8 +31,27 @@ use datafusion_expr_common::columnar_value::ColumnarValue;
use datafusion_expr_common::interval_arithmetic::Interval;
use datafusion_expr_common::sort_properties::ExprProperties;

/// See [create_physical_expr](https://docs.rs/datafusion/latest/datafusion/physical_expr/fn.create_physical_expr.html)
/// for examples of creating `PhysicalExpr` from `Expr`
/// [`PhysicalExpr`]s represent expressions such as `A + 1` or `CAST(c1 AS int)`.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was strange there was no explanation of what a PhysicalExpr was on the trait, so let's fix that (moved the docs from create_physical_expr and revamped it a bit)

@@ -33,32 +33,67 @@ use datafusion_expr::ColumnarValue;
use crate::physical_expr::{down_cast_any_ref, PhysicalExpr};

/// Represents the column at a given index in a RecordBatch
///
/// This is a physical expression that represents a column at a given index in a
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point that physical exprs are always in terms of indexes wasn't as clear as I think it could be so I tried to improve that

Copy link
Contributor

@appletreeisyellow appletreeisyellow left a comment

Choose a reason for hiding this comment

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

Thank you for the doc improvement @alamb! I did found myself digging into doc to find how to create PhysicalExpr from Expr. This improvement will make such kind of process faster. Thank you!

datafusion/physical-expr/src/expressions/column.rs Outdated Show resolved Hide resolved
datafusion/physical-expr/src/expressions/column.rs Outdated Show resolved Hide resolved
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.

thanks, that really helps!

Copy link
Contributor

@jayzhan211 jayzhan211 left a comment

Choose a reason for hiding this comment

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

👍

@comphead comphead merged commit befac37 into apache:main Sep 14, 2024
24 checks passed
@alamb
Copy link
Contributor Author

alamb commented Sep 15, 2024

Thanks for the reviews and merge @jayzhan211 and @comphead

@alamb alamb deleted the alamb/physical_expr_docs branch September 15, 2024 13:46
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants