appletreeisyellow commented on code in PR #12457:
URL: https://github.com/apache/datafusion/pull/12457#discussion_r1759315034
##########
datafusion/physical-expr/src/expressions/column.rs:
##########
@@ -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
+/// arrow [`Schema`] / [`RecordBatch`].
+///
+/// Unlike the [logical `Expr::Column`], this expression is always resolved by
schema index,
+/// even though it does have a name. This is because the physical plan is
always
+/// resolved to a specific schema and there is no concept of "relation"
+///
+/// # Example:
+/// If the schema is `a`, `b`, `c` the `Column` for `b` would be represented
by
+/// index 1, since `b` is the second colum in the schema.
+///
+/// ```
+/// # use datafusion_physical_expr::expressions::Column;
+/// # use arrow::datatypes::{DataType, Field, Schema};
+/// // Schema with columns a, b, c
+/// let schema = Schema::new(vec![
+/// Field::new("a", DataType::Int32, false),
+/// Field::new("b", DataType::Int32, false),
+/// Field::new("c", DataType::Int32, false),
+/// ]);
+///
+/// // reference to column b is index 1
+/// let column_b = Column::new_with_schema("b", &schema).unwrap();
+/// assert_eq!(column_b.index(), 1);
+///
+/// // reference to column c is index 2
+/// let column_c = Column::new_with_schema("c", &schema).unwrap();
+/// assert_eq!(column_c.index(), 2);
+/// ```
+/// [logical `Expr::Column`]:
https://docs.rs/datafusion/latest/datafusion/logical_expr/enum.Expr.html#variant.Column
#[derive(Debug, Hash, PartialEq, Eq, Clone)]
pub struct Column {
+ /// THe name of the column (used for debugging and display purposes)
Review Comment:
```suggestion
/// The name of the column (used for debugging and display purposes)
```
##########
datafusion/physical-expr/src/expressions/column.rs:
##########
@@ -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
Review Comment:
```suggestion
/// This is a physical expression that represents a column at a given index
in an
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]