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

support ANY() op #11849

Merged
merged 7 commits into from
Aug 8, 2024
Merged

support ANY() op #11849

merged 7 commits into from
Aug 8, 2024

Conversation

samuelcolvin
Copy link
Contributor

Which issue does this PR close?

Half of #6602 - the overwhelmingly common half.

Rationale for this change

Trying to support as much postgreSQL syntax as possible, ANY() queries are fairly common.

What changes are included in this PR?

  • Support the ANY() operator, as in 'needle'=ANY(haystack)
  • Rename the arguments to array_has to be less confusing
  • tests for ANY()
  • Some tweaks to test setup to support the above test

Are these changes tested?

Yes, I can add more if you want.

Are there any user-facing changes?

Common queries with ANY() should now work

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions labels Aug 6, 2024
@samuelcolvin samuelcolvin changed the title support ANY() op support ANY() op Aug 6, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @samuelcolvin -- this looks quite good to me

The only thing I think it needs is a .slt level test

Can you please add one?

Here are the instructions: https://github.com/apache/datafusion/tree/main/datafusion/sqllogictest

Ideally you should be able to extend one of the existing test files in https://github.com/apache/datafusion/tree/main/datafusion/sqllogictest/test_files

Maybe somewhere in

## array_has/array_has_all/array_has_any
query BB
select array_has([], null),
array_has([1, 2, 3], null);
----
false false
?

datafusion/functions-nested/src/array_has.rs Show resolved Hide resolved
datafusion/sql/src/expr/mod.rs Outdated Show resolved Hide resolved
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Aug 7, 2024
Copy link
Contributor Author

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

I think this is ready.

@@ -102,7 +102,7 @@ impl ExprPlanner for NestedFunctionPlanner {

fn plan_make_map(&self, args: Vec<Expr>) -> Result<PlannerResult<Vec<Expr>>> {
if args.len() % 2 != 0 {
return exec_err!("make_map requires an even number of arguments");
return plan_err!("make_map requires an even number of arguments");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

drive-by change, since this is a "plan" method I assume a "plan error" is more appropriate?

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @samuelcolvin -- looks great to me

@alamb alamb merged commit 2521043 into apache:main Aug 8, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions sql SQL Planner sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants