Skip to content

Conversation

@CuteChuanChuan
Copy link
Contributor

@CuteChuanChuan CuteChuanChuan commented Jul 15, 2025

Which issue does this PR close?
Part of #2019

Rationale for this change
See #2019 for rationale.

What changes are included in this PR?
Moved comparison expressions to separate file (comparison.scala)

How are these changes tested?
There are no functional changes, so it relies on existing tests.

Details:

  • Add ComparisonBase trait with reusable helper methods
  • Move GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual to CometComparison*
  • Move IsNull, IsNotNull, IsNaN to CometIs* classes
  • Move In expression to CometIn class
  • Update exprSerdeMap to use new comparison classes
  • Remove corresponding case statements from exprToProtoInternal

- Create comparisons.scala following the pattern from math/array expressions.
- Implements CometGreaterThan as proof of concept for issue apache#2019.
@CuteChuanChuan CuteChuanChuan force-pushed the raymond/refactor-expressions-in-QueryPlanSerde branch from 56ddd51 to 202556d Compare July 17, 2025 15:03
- Add ComparisonBase trait with reusable helper methods
- Move GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual to CometComparison*
- Move IsNull, IsNotNull, IsNaN to CometIs* classes
- Move In expression to CometIn class
- Update exprSerdeMap to use new comparison classes
- Remove corresponding case statements from exprToProtoInternal
@CuteChuanChuan CuteChuanChuan changed the title [WIP] chore: refactor Comparison out of QueryPlanSerde Chore: refactor Comparison out of QueryPlanSerde Jul 17, 2025
@CuteChuanChuan CuteChuanChuan marked this pull request as ready for review July 17, 2025 15:16
@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.83%. Comparing base (f09f8af) to head (2b5d058).
⚠️ Report is 343 commits behind head on main.

Files with missing lines Patch % Lines
...ain/scala/org/apache/comet/serde/comparisons.scala 90.58% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2028      +/-   ##
============================================
+ Coverage     56.12%   58.83%   +2.70%     
- Complexity      976     1253     +277     
============================================
  Files           119      138      +19     
  Lines         11743    13198    +1455     
  Branches       2251     2364     +113     
============================================
+ Hits           6591     7765    +1174     
- Misses         4012     4201     +189     
- Partials       1140     1232      +92     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CuteChuanChuan
Copy link
Contributor Author

Hi @andygrove ,

Could you please take a look at this PR and provide some guidance when you have a chance? I've refactored the comparison expressions (GreaterThan, LessThan, IsNull, In, etc.) following the pattern discussed in #2019.

In the meantime, I'll continue working on refactoring the remaining expressions from the list.

Thanks!

@mbutrovich mbutrovich self-requested a review July 23, 2025 14:19
Copy link
Contributor

@mbutrovich mbutrovich left a comment

Choose a reason for hiding this comment

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

Thanks for the first contribution @CuteChuanChuan. First feedback provided below.

- Remove duplicated utility functions (createUnaryExpr, createBinaryExpr, optExprWithInfo)
- Remove empty ComparisonBase trait
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.

Thanks for the contribution @CuteChuanChuan. I think that this PR can be approved once all feedback has been addressed.

- Move in function logic into CometIn.convert
@andygrove
Copy link
Member

@mbutrovich could you re-review?

(builder, binaryExpr) => builder.setBitwiseAnd(binaryExpr))

case In(value, list) =>
in(expr, value, list, inputs, binding, negate = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand now why you brought that in function over to comparisons.scala. It was used here, and in InSet and Not(In).

I think we should handle those two expressions in this PR, and bring in over to comparisons.scala so the logic isn't duplicated in two places.

- Extract shared in function to ComparisonUtils for reuse by In, InSet, and Not(In) expressions
- Move NotIn and InSet to comparisons.scala
- Add CometInSet to exprSerdeMap and keep Not(In) pattern matching for nested structure
Copy link
Contributor

@mbutrovich mbutrovich left a comment

Choose a reason for hiding this comment

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

LTGM, thanks for your patience on this one @CuteChuanChuan!

@mbutrovich mbutrovich merged commit a583db3 into apache:main Aug 5, 2025
91 checks passed
coderfender pushed a commit to coderfender/datafusion-comet that referenced this pull request Dec 13, 2025
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