Skip to content

Commit 58345f9

Browse files
authored
Improve ProjectionExpr documentation and comments (#19263)
## Which issue does this PR close? - related to #19111 ## Rationale for this change While reviewing #19111 from @adriangb I found a few places that the documentation could be improved to give higher level context ## What changes are included in this PR? Update some docs and comments ## Are these changes tested? By cos ## Are there any user-facing changes? Just docs/comments. No functional changes
1 parent bde1608 commit 58345f9

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

datafusion/datasource-parquet/src/opener.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,9 @@ impl FileOpener for ParquetOpener {
286286
// - The table schema as defined by the TableProvider.
287287
// This is what the user sees, what they get when they `SELECT * FROM table`, etc.
288288
// - The logical file schema: this is the table schema minus any hive partition columns and projections.
289-
// This is what the physicalfile schema is coerced to.
290-
// - The physical file schema: this is the schema as defined by the parquet file. This is what the parquet file actually contains.
289+
// This is what the physical file schema is coerced to.
290+
// - The physical file schema: this is the schema that the arrow-rs
291+
// parquet reader will actually produce.
291292
let mut physical_file_schema = Arc::clone(reader_metadata.schema());
292293

293294
// The schema loaded from the file may not be the same as the

datafusion/physical-expr/src/projection.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
//! [`ProjectionExpr`] and [`ProjectionExprs`] for representing projections.
19+
1820
use std::ops::Deref;
1921
use std::sync::Arc;
2022

@@ -35,14 +37,16 @@ use datafusion_physical_expr_common::utils::evaluate_expressions_to_arrays;
3537
use indexmap::IndexMap;
3638
use itertools::Itertools;
3739

38-
/// A projection expression as used by projection operations.
40+
/// An expression used by projection operations.
3941
///
4042
/// The expression is evaluated and the result is stored in a column
4143
/// with the name specified by `alias`.
4244
///
4345
/// For example, the SQL expression `a + b AS sum_ab` would be represented
4446
/// as a `ProjectionExpr` where `expr` is the expression `a + b`
4547
/// and `alias` is the string `sum_ab`.
48+
///
49+
/// See [`ProjectionExprs`] for a collection of projection expressions.
4650
#[derive(Debug, Clone)]
4751
pub struct ProjectionExpr {
4852
/// The expression that will be evaluated.
@@ -107,11 +111,14 @@ impl From<ProjectionExpr> for (Arc<dyn PhysicalExpr>, String) {
107111
}
108112
}
109113

110-
/// A collection of projection expressions.
114+
/// A collection of [`ProjectionExpr`] instances, representing a complete
115+
/// projection operation.
116+
///
117+
/// Projection operations are used in query plans to select specific columns or
118+
/// compute new columns based on existing ones.
111119
///
112-
/// This struct encapsulates multiple `ProjectionExpr` instances,
113-
/// representing a complete projection operation and provides
114-
/// methods to manipulate and analyze the projection as a whole.
120+
/// See [`ProjectionExprs::from_indices`] to select a subset of columns by
121+
/// indices.
115122
#[derive(Debug, Clone, PartialEq, Eq)]
116123
pub struct ProjectionExprs {
117124
exprs: Vec<ProjectionExpr>,

0 commit comments

Comments
 (0)