Skip to content

Use return_field_from_args in information schema and date_trunc#20079

Merged
Jefffrey merged 4 commits intoapache:mainfrom
AndreaBozzo:ab/ret-type-args
Feb 2, 2026
Merged

Use return_field_from_args in information schema and date_trunc#20079
Jefffrey merged 4 commits intoapache:mainfrom
AndreaBozzo:ab/ret-type-args

Conversation

@AndreaBozzo
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Some UDFs/UDAFs implement return_field_from_args / return_field instead of return_type. The information schema was calling return_type directly, which fails for those functions. The default implementation of return_field_from_args already delegates to return_type, so switching to the newer API works for all functions.

What changes are included in this PR?

  • information_schema.rs: get_udf_args_and_return_types now calls return_field_from_args instead of return_type; get_udaf_args_and_return_types now calls return_field instead of return_type. Removed stale comments referencing the old API.
  • date_trunc.rs: return_type now returns internal_err, and return_field_from_args is self-contained (no longer delegates to return_type), following the same pattern as other UDFs like named_struct and map_from_arrays (ref: fix: derive custom nullability for spark map_from_arrays #19275).

Are these changes tested?

Covered by existing information_schema sqllogictests and datafusion-functions unit tests.

Are there any user-facing changes?

No.

@github-actions github-actions bot added catalog Related to the catalog crate functions Changes to functions implementation labels Jan 30, 2026
@AndreaBozzo AndreaBozzo marked this pull request as ready for review January 30, 2026 18:15
.into_iter()
.map(|arg_types| {
// only handle the function which implemented [`ScalarUDFImpl::return_type`] method
let arg_fields: Vec<FieldRef> = arg_types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting that we omitted window functions before 🤔

And somehow this fix doesn't affect any existing tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good morning!

If i'm allowed, this could use a dedicated test/tests, at the same time i wanted to keep It lean for reviewers.

If any follow up Is needed, please consider me for it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR is fine to merge as is, but I wouldn't be opposed to adding some SLT tests for that case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, i opened #20090 to track this as it might be a good newcomer task also

Thanks again for your review @Jefffrey

}

// keep return_type implementation for information schema generation
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks this should avoid internal_error, good catch

@Jefffrey Jefffrey added this pull request to the merge queue Feb 2, 2026
@Jefffrey
Copy link
Contributor

Jefffrey commented Feb 2, 2026

Thanks @AndreaBozzo & @martin-g

Merged via the queue into apache:main with commit 1a0c2e0 Feb 2, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

catalog Related to the catalog crate functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Information schema should use return_field_from_args

3 participants