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

Feat: support array_except function #1343

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kazantsev-maksim
Copy link

Which issue does this PR close?

Related to Epic: #1042
array_except: SELECT array_except(array(1, 2, 3), array(1, 3, 5)) => array(2)
DataFusion' s array_except has same behavior with Spark 's array_except function
Spark: https://docs.databricks.com/en/sql/language-manual/functions/array_except.html
DataFusion: https://datafusion.apache.org/user-guide/sql/scalar_functions.html#array-except

Rationale for this change

Defined under Epic: #1042

What changes are included in this PR?

planner.rs: Maps Spark 's array_except function to DataFusion array_except_udf physical expression from Spark physical expression
expr.proto: array_except array_except has been added,
QueryPlanSerde.scala: arrays_except pattern matching case has been added,
CometExpressionSuite.scala: A new UT has been added for array_except function.

How are these changes tested?

A new UT has been added.

@codecov-commenter
Copy link

codecov-commenter commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 39.09%. Comparing base (f09f8af) to head (3abe5c4).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
.../scala/org/apache/comet/serde/QueryPlanSerde.scala 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##               main    #1343       +/-   ##
=============================================
- Coverage     56.12%   39.09%   -17.03%     
- Complexity      976     2065     +1089     
=============================================
  Files           119      260      +141     
  Lines         11743    60257    +48514     
  Branches       2251    12832    +10581     
=============================================
+ Hits           6591    23560    +16969     
- Misses         4012    32216    +28204     
- Partials       1140     4481     +3341     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -818,6 +819,22 @@ impl PhysicalPlanner {
));
Ok(array_join_expr)
}
ExprStruct::ArrayExcept(expr) => {
Copy link
Member

Choose a reason for hiding this comment

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

Because the PR only contains basic tests, could you add a check to enable this expression only if CometConf.COMET_CAST_ALLOW_INCOMPATIBLE is enabled? We can remove this check in a future PR that adds comprehensive tests and demonstrates that we have Spark-compatible behavior for all supported data types.

Copy link
Author

Choose a reason for hiding this comment

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

COMET_CAST_ALLOW_INCOMPATIBLE check has been added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants