Skip to content
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

Fix NULL["field"] for expr_API #10655

Merged
merged 1 commit into from
May 25, 2024
Merged

Fix NULL["field"] for expr_API #10655

merged 1 commit into from
May 25, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented May 24, 2024

Which issue does this PR close?

Closes #10654

Rationale for this change

This used to work (and we used it in IOx when we were programatically creating expressions):

lit(ScalarValue::Null).field("foo")

Now it returns an error:

The expression to get an indexed field is only valid for List, Struct, or Map types, got Null

What changes are included in this PR?

Support NULL["field"

Are these changes tested?

Yes, new unit tests are added

Are there any user-facing changes?

Fix regression

@github-actions github-actions bot added the core Core DataFusion crate label May 24, 2024
@alamb alamb changed the title Fix Support field access for literal Null Fix NULL["field"] for expr_API May 24, 2024
@alamb alamb marked this pull request as ready for review May 24, 2024 19:30
@@ -106,6 +106,9 @@ impl ScalarUDFImpl for GetFieldFunc {
};
let access_schema = GetFieldAccessSchema::NamedStructField { name: name.clone() };
let arg_dt = args[0].get_type(schema)?;
if arg_dt.is_null() {
return Ok(DataType::Null);
}
access_schema
Copy link
Contributor

@jayzhan211 jayzhan211 May 25, 2024

Choose a reason for hiding this comment

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

I quickly fixed it before noticing that there was already a PR

I think we can remove GetFieldAccessSchema, get_accessed_field. 6cb45b5

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 @jayzhan211

I agree the change in 6cb45b5 to inline things looks nice -- shall we make another PR?

@alamb
Copy link
Contributor Author

alamb commented May 25, 2024

Thank you for the speedy review @jayzhan211

@alamb alamb merged commit 0f994af into apache:main May 25, 2024
24 checks passed
jayzhan211 pushed a commit to jayzhan211/datafusion that referenced this pull request May 26, 2024
appletreeisyellow pushed a commit to influxdata/arrow-datafusion that referenced this pull request May 28, 2024
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
2 participants