timsaucer commented on code in PR #15646: URL: https://github.com/apache/datafusion/pull/15646#discussion_r2052891382
########## datafusion/common/src/dfschema.rs: ########## @@ -969,16 +969,28 @@ impl Display for DFSchema { /// widely used in the DataFusion codebase. pub trait ExprSchema: std::fmt::Debug { /// Is this column reference nullable? - fn nullable(&self, col: &Column) -> Result<bool>; + fn nullable(&self, col: &Column) -> Result<bool> { + Ok(self.to_field(col)?.is_nullable()) + } /// What is the datatype of this column? - fn data_type(&self, col: &Column) -> Result<&DataType>; + fn data_type(&self, col: &Column) -> Result<&DataType> { + Ok(self.to_field(col)?.data_type()) + } /// Returns the column's optional metadata. - fn metadata(&self, col: &Column) -> Result<&HashMap<String, String>>; + fn metadata(&self, col: &Column) -> Result<&HashMap<String, String>> { + Ok(self.to_field(col)?.metadata()) + } /// Return the column's datatype and nullability - fn data_type_and_nullable(&self, col: &Column) -> Result<(&DataType, bool)>; + fn data_type_and_nullable(&self, col: &Column) -> Result<(&DataType, bool)> { + let field = self.to_field(col)?; + Ok((field.data_type(), field.is_nullable())) + } + + // Return the column's field + fn to_field(&self, col: &Column) -> Result<&Field>; Review Comment: I changed this to `field_from_column` to be consistent with the rest of the API on this struct. If we used `field` then we would keep running into places where it conflicts with `field()` that takes the column index. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org