-
Notifications
You must be signed in to change notification settings - Fork 176
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1343 +/- ##
============================================
+ Coverage 56.12% 57.45% +1.32%
Complexity 976 976
============================================
Files 119 121 +2
Lines 11743 11931 +188
Branches 2251 2254 +3
============================================
+ Hits 6591 6855 +264
+ Misses 4012 3917 -95
- Partials 1140 1159 +19 ☔ View full report in Codecov by Sentry. |
# Conflicts: # native/core/src/execution/planner.rs # native/proto/src/proto/expr.proto # spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala # spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kazantsev-maksim
# Conflicts: # spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala # spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @kazantsev-maksim
sql("SELECT array_except(array(_2, _3, _4), array(_3, _4)) from t1")) | ||
checkSparkAnswerAndOperator(sql("SELECT array_except(array(_18), array(_19)) from t1")) | ||
checkSparkAnswerAndOperator(spark.sql( | ||
"SELECT array_except((CASE WHEN _2 = _3 THEN array(_2, _3, _4) END), array(_4)) FROM t1")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_2 = _3
would be always true?
@@ -126,6 +126,21 @@ object CometArraysOverlap extends CometExpressionSerde with IncompatExpr { | |||
} | |||
} | |||
|
|||
object CometArrayExcept extends CometExpressionSerde with CometExprShim { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for using CometExprShim
?
Also not sure how ready this is regarding Spark compatibility although it seems the test coverage is good. Adding IncompatExpr
might be an option.
@@ -2387,6 +2387,8 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim | |||
case _: ArrayIntersect => convert(CometArrayIntersect) | |||
case _: ArrayJoin => convert(CometArrayJoin) | |||
case _: ArraysOverlap => convert(CometArraysOverlap) | |||
case _ if expr.prettyName == "array_except" => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is ArrayExcept
available only for newer version?
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.