timsaucer commented on code in PR #15646:
URL: https://github.com/apache/datafusion/pull/15646#discussion_r2059245151
##########
datafusion/physical-expr-common/src/physical_expr.rs:
##########
@@ -71,11 +71,23 @@ pub trait PhysicalExpr: Send + Sync + Display + Debug +
DynEq + DynHash {
/// downcast to a specific implementation.
fn as_any(&self) -> &dyn Any;
/// Get the data type of this expression, given the schema of the input
- fn data_type(&self, input_schema: &Schema) -> Result<DataType>;
+ fn data_type(&self, input_schema: &Schema) -> Result<DataType> {
+ Ok(self.return_field(input_schema)?.data_type().to_owned())
+ }
/// Determine whether this expression is nullable, given the schema of the
input
- fn nullable(&self, input_schema: &Schema) -> Result<bool>;
+ fn nullable(&self, input_schema: &Schema) -> Result<bool> {
+ Ok(self.return_field(input_schema)?.is_nullable())
+ }
/// Evaluate an expression against a RecordBatch
fn evaluate(&self, batch: &RecordBatch) -> Result<ColumnarValue>;
+ /// The output field associated with this expression
+ fn return_field(&self, input_schema: &Schema) -> Result<Field> {
+ Ok(Field::new(
+ format!("{self}"),
Review Comment:
I believe the place it is computed is here and then used later down in the
same function.
https://github.com/apache/datafusion/blob/e4d5846dddefed5bf6934acc63da7f4bd4644868/datafusion/expr/src/expr_schema.rs#L375
--
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]