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

Rewrite array @> array and array <@ array in sql_expr_to_logical_expr #11155

Merged
merged 4 commits into from
Jun 29, 2024

Conversation

jayzhan211
Copy link
Contributor

Which issue does this PR close?

Part of #8506 #10534

Rationale for this change

Move the rewrite from optimizer to sql crate

I keep the function rewrite trait even it is not used anywhere in datafusion now.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions labels Jun 28, 2024
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@jayzhan211 jayzhan211 marked this pull request as ready for review June 28, 2024 06:03
@alamb alamb mentioned this pull request Jun 28, 2024
6 tasks
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.

Thanks @jayzhan211 -- this looks good to me

Can you remind me why this method is preferrable to the FunctionRewrite idea we previously had?

I feel this PR and changes are related to the one from @samuelcolvin on #11137 -- where the idea is to support SQL syntax with JSON operators without putting the implementation into SQL

@@ -1225,22 +1225,6 @@ fn select_binary_expr_nested() {
quick_test(sql, expected);
}

#[test]
fn select_at_arrow_operator() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add an explain test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it is needed since we don't really care about how it looks in plan.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we can make sure array_has_all is applied 🤔

@alamb
Copy link
Contributor

alamb commented Jun 28, 2024

Here is an alternate idea #11168

@jayzhan211
Copy link
Contributor Author

Thanks @jayzhan211 -- this looks good to me

Can you remind me why this method is preferrable to the FunctionRewrite idea we previously had?

I feel this PR and changes are related to the one from @samuelcolvin on #11137 -- where the idea is to support SQL syntax with JSON operators without putting the implementation into SQL

From your comment here :) #10534 (comment)

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Jun 29, 2024
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@@ -145,36 +145,3 @@ fn compare_op_for_nested(
Ok(BooleanArray::new(values, nulls))
}
}

#[cfg(test)]
mod 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.

forgot to remove in previous PR

@jayzhan211 jayzhan211 merged commit 14d3973 into apache:main Jun 29, 2024
23 checks passed
@jayzhan211 jayzhan211 deleted the at-arrow-rewrite branch June 29, 2024 12:14
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
…expr (apache#11155)

* rewrite at arrow

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* rm useless test

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* add test

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* rm test

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

---------

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
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.

2 participants