Skip to content

Apache DataFusion SQL Query Engine

Improve ProjectionExpr documentation and comments (#19263)

Andrew Lamb58345f94afd4
diff --git a/datafusion/datasource-parquet/src/opener.rs b/datafusion/datasource-parquet/src/opener.rs
index fb9d27527e..30573ff6e1 100644
--- a/datafusion/datasource-parquet/src/opener.rs
+++ b/datafusion/datasource-parquet/src/opener.rs
@@ -286,8 +286,9 @@ impl FileOpener for ParquetOpener {
// - The table schema as defined by the TableProvider.
// This is what the user sees, what they get when they `SELECT * FROM table`, etc.
// - The logical file schema: this is the table schema minus any hive partition columns and projections.
- // This is what the physicalfile schema is coerced to.
- // - The physical file schema: this is the schema as defined by the parquet file. This is what the parquet file actually contains.
+ // This is what the physical file schema is coerced to.
+ // - The physical file schema: this is the schema that the arrow-rs
+ // parquet reader will actually produce.
let mut physical_file_schema = Arc::clone(reader_metadata.schema());
// The schema loaded from the file may not be the same as the
diff --git a/datafusion/physical-expr/src/projection.rs b/datafusion/physical-expr/src/projection.rs
index ab9015e32f..6f1fd6e945 100644
--- a/datafusion/physical-expr/src/projection.rs
+++ b/datafusion/physical-expr/src/projection.rs
@@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.
+//! [`ProjectionExpr`] and [`ProjectionExprs`] for representing projections.
+
use std::ops::Deref;
use std::sync::Arc;
@@ -35,7 +37,7 @@ use datafusion_physical_expr_common::utils::evaluate_expressions_to_arrays;
use indexmap::IndexMap;
use itertools::Itertools;
-/// A projection expression as used by projection operations.
+/// An expression used by projection operations.
///
/// The expression is evaluated and the result is stored in a column
/// with the name specified by `alias`.
@@ -43,6 +45,8 @@ use itertools::Itertools;
/// For example, the SQL expression `a + b AS sum_ab` would be represented
/// as a `ProjectionExpr` where `expr` is the expression `a + b`
/// and `alias` is the string `sum_ab`.
+///
+/// See [`ProjectionExprs`] for a collection of projection expressions.
#[derive(Debug, Clone)]
pub struct ProjectionExpr {
/// The expression that will be evaluated.
@@ -107,11 +111,14 @@ impl From<ProjectionExpr> for (Arc<dyn PhysicalExpr>, String) {
}
}
-/// A collection of projection expressions.
+/// A collection of [`ProjectionExpr`] instances, representing a complete
+/// projection operation.
+///
+/// Projection operations are used in query plans to select specific columns or
+/// compute new columns based on existing ones.
///
-/// This struct encapsulates multiple `ProjectionExpr` instances,
-/// representing a complete projection operation and provides
-/// methods to manipulate and analyze the projection as a whole.
+/// See [`ProjectionExprs::from_indices`] to select a subset of columns by
+/// indices.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProjectionExprs {
exprs: Vec<ProjectionExpr>,