-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add Extension Type / Metadata support for Scalar UDFs #15646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
39d1a72
9bcd4b5
ea561b0
8daa356
a2d5f9e
a3514de
4e3b7bc
281a83e
03ddfe7
58933df
6924e4e
68f4356
d6af7e3
07b7ec8
caad021
9aa5227
2fab67b
02d6f47
871c382
c439224
d69deee
317ed22
6481b3e
ef6c58c
cddb52a
e4d5846
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -472,7 +472,7 @@ impl DFSchema { | |
| let matches = self.qualified_fields_with_unqualified_name(name); | ||
| match matches.len() { | ||
| 0 => Err(unqualified_field_not_found(name, self)), | ||
| 1 => Ok((matches[0].0, (matches[0].1))), | ||
| 1 => Ok((matches[0].0, matches[0].1)), | ||
| _ => { | ||
| // When `matches` size > 1, it doesn't necessarily mean an `ambiguous name` problem. | ||
| // Because name may generate from Alias/... . It means that it don't own qualifier. | ||
|
|
@@ -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>; | ||
|
||
| } | ||
|
|
||
| // Implement `ExprSchema` for `Arc<DFSchema>` | ||
|
|
@@ -998,24 +1010,15 @@ impl<P: AsRef<DFSchema> + std::fmt::Debug> ExprSchema for P { | |
| fn data_type_and_nullable(&self, col: &Column) -> Result<(&DataType, bool)> { | ||
| self.as_ref().data_type_and_nullable(col) | ||
| } | ||
| } | ||
|
|
||
| impl ExprSchema for DFSchema { | ||
| fn nullable(&self, col: &Column) -> Result<bool> { | ||
| Ok(self.field_from_column(col)?.is_nullable()) | ||
| } | ||
|
|
||
| fn data_type(&self, col: &Column) -> Result<&DataType> { | ||
| Ok(self.field_from_column(col)?.data_type()) | ||
| } | ||
|
|
||
| fn metadata(&self, col: &Column) -> Result<&HashMap<String, String>> { | ||
| Ok(self.field_from_column(col)?.metadata()) | ||
| fn to_field(&self, col: &Column) -> Result<&Field> { | ||
| self.as_ref().to_field(col) | ||
| } | ||
| } | ||
|
|
||
| fn data_type_and_nullable(&self, col: &Column) -> Result<(&DataType, bool)> { | ||
| let field = self.field_from_column(col)?; | ||
| Ok((field.data_type(), field.is_nullable())) | ||
| impl ExprSchema for DFSchema { | ||
| fn to_field(&self, col: &Column) -> Result<&Field> { | ||
| self.field_from_column(col) | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we could (perhaps as a follow on ticket) deprecate all the other methods on
ExprSchemaasto_fieldsupercedes all of them. It would make a good first issue ticketThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#15798