-
Notifications
You must be signed in to change notification settings - Fork 1.9k
information_schema: use return_field_from_args for scalar UDFs #19911
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
af19e72
0e173f7
176d742
c6bd252
832d524
4cf4c9f
fd3623e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| use datafusion_common::internal_err; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this import down, it's causing the license CI check to fail |
||
|
|
||
| use std::any::Any; | ||
| use std::num::NonZeroI64; | ||
|
|
@@ -223,13 +224,12 @@ impl ScalarUDFImpl for DateTruncFunc { | |
| &self.signature | ||
| } | ||
|
|
||
| // keep return_type implementation for information schema generation | ||
| fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> { | ||
| if arg_types[1].is_null() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to move this logic into
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, this comment was resolved without any action taken. |
||
| Ok(Timestamp(Nanosecond, None)) | ||
| } else { | ||
| Ok(arg_types[1].clone()) | ||
| } | ||
| fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> { | ||
| // This UDF implements `return_field_from_args` and should use that | ||
| // for return type (including nullability) decisions. Returning an | ||
| // internal error here makes misuse visible and matches other UDFs | ||
| // that implement `return_field_from_args` directly. | ||
Phaneendra293 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| internal_err!("return_field_from_args should be used instead") | ||
| } | ||
|
|
||
| fn return_field_from_args(&self, args: ReturnFieldArgs) -> Result<FieldRef> { | ||
|
|
||
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.
Personally I'd remove these comments; we don't need this much info, and some of the info here can be misleading. For example it mentions using the
return_field_from_argsAPI allows nullability & value-based return type decisions, which is true, but not here; here we always set nullability as true and set the scalar values as None, so they don't actually play a factor here.This is a simple change which I don't think needs an explicit explanation, same for below.
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.
Please refrain from resolving a conversation if no action has been taken nor any comment left to explain why action was not taken.