Skip to content

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
?

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

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

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