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 14 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

All modified and coverable lines are covered by tests ✅

Project coverage is 57.49%. Comparing base (f09f8af) to head (1f5782f).
Report is 24 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1343      +/-   ##
============================================
+ Coverage     56.12%   57.49%   +1.36%     
- Complexity      976      978       +2     
============================================
  Files           119      121       +2     
  Lines         11743    11944     +201     
  Branches       2251     2254       +3     
============================================
+ Hits           6591     6867     +276     
+ Misses         4012     3919      -93     
- Partials       1140     1158      +18     

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

Kazantsev Maksim added 3 commits January 28, 2025 19:53
# 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
Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

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

Kazantsev Maksim added 5 commits January 30, 2025 19:23
# Conflicts:
#	spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
#	spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala
Copy link
Member

@andygrove andygrove left a 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"))
Copy link
Contributor

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?

Copy link
Author

Choose a reason for hiding this comment

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

You are right, it is necessary to add the condition is not null, thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

I saw you added WHERE _2 IS NOT NULL but not sure how it helps... _2 = _3 will be always true is it intentional?

Copy link
Author

Choose a reason for hiding this comment

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

This is a test case for deduplication checking.

Copy link
Contributor

@kazuyukitanimura kazuyukitanimura left a comment

Choose a reason for hiding this comment

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

pending ci

@kazuyukitanimura
Copy link
Contributor

Looks there are some format issues need to be fixed @kazantsev-maksim otherwise I think it is good to go

@kazantsev-maksim
Copy link
Author

Thanks @kazuyukitanimura. I've fixed the formatting in the native module

@kazuyukitanimura
Copy link
Contributor

@kazantsev-maksim it seems there are test failures

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.

4 participants