Skip to content

Add support for nested types to nullif.#21764

Open
tabac wants to merge 1 commit intoapache:mainfrom
tabac:nullif-nested-types
Open

Add support for nested types to nullif.#21764
tabac wants to merge 1 commit intoapache:mainfrom
tabac:nullif-nested-types

Conversation

@tabac
Copy link
Copy Markdown
Contributor

@tabac tabac commented Apr 21, 2026

Which issue does this PR close?

Rationale for this change

Add support for nested types to the nullif UDF.

Are these changes tested?

Unit tests included.

Are there any user-facing changes?

No changes to the function's signature.

@github-actions github-actions Bot added the functions Changes to functions implementation label Apr 21, 2026
Comment on lines +292 to +304
let expected = [
"+--------------+",
"| result |",
"+--------------+",
"| |",
"| {a: 2, b: 2} |",
"| |",
"+--------------+",
];

assert_batches_eq!(expected, &[batch]);

Ok(())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd try to be consistent with the other tests in this file and, rather than asserting a string representation of the record batches, I'd try to perform assertions of the returned ArrayRefs.

If you think it's strictly necessary to perform assertions over pretty-printed string representations, this project typically uses insta for managing them.

datafusion-expr = { workspace = true }
datafusion-expr-common = { workspace = true }
datafusion-macros = { workspace = true }
datafusion-physical-expr-common = { workspace = true }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤔 I don't see a problem in introducing this coupling point here, but I'll double check if this is fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be fine. Other function-* crates in this project are already depending on this module, for example:
https://github.com/apache/datafusion/blob/branch-53/datafusion/functions-nested/Cargo.toml#L59-L59

Comment on lines +263 to +264
#[test]
fn nullif_struct() -> Result<()> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add a new test comparing a nested array VS a non-nested array? I imagine the result of comparing both should return false, but I'm not sure if right now that would happen, as we might hit this line here:

https://github.com/apache/datafusion/blob/branch-53/datafusion/physical-expr-common/src/datum.rs#L145-L145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants