Skip to content

[replay #7532] fix(workflow-operator): MAX aggregation checks the wrong empty-group sentinel - #7

Open
sshiv012 wants to merge 1 commit into
replay/7532-basefrom
replay/7532-head
Open

[replay #7532] fix(workflow-operator): MAX aggregation checks the wrong empty-group sentinel#7
sshiv012 wants to merge 1 commit into
replay/7532-basefrom
replay/7532-head

Conversation

@sshiv012

@sshiv012 sshiv012 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Replay of apache#7532 for CodeRabbit evaluation.

merge-base 5e41efae2650 head c879f75824d7 stratum scala

Synthetic evaluation PR. Do not merge.

  • Fixed maxAgg to detect empty groups with the correct minimum-value sentinel.
  • Added regression tests for empty, all-null, type-maximum, and re-aggregated MAX values across supported types.
Contributing author Lines added Lines removed
Not specified 103 1

…sentinel

Change maxAgg's finaliser in AggregationOperation to test the minValue sentinel it initialises with (it tested maxValue, copied from minAgg), and add regression tests for the empty, all-null, and type-maximum cases across INTEGER, LONG, DOUBLE, and TIMESTAMP.
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

maxAgg now identifies empty results with the type minimum sentinel. Tests cover maximum values, empty and null-only inputs, supported data types, and worker-to-final aggregation.

Changes

MAX aggregation correction

Layer / File(s) Summary
Correct MAX empty-result detection
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/aggregate/AggregationOperation.scala, common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregateOpSpec.scala
maxAgg uses the type minimum sentinel for empty results. Tests cover populated, empty, null-only, and maximum-value inputs for supported types.
Validate partial MAX merging
common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregationOperationSpec.scala
Tests verify that Int.MaxValue survives partial aggregation and that empty partials merge correctly and finalize to null.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: aglinxinyuan

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the MAX aggregation sentinel bug and the workflow-operator fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch replay/7532-head

Comment @coderabbitai help to get the list of available commands.

@sshiv012

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sshiv012

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/aggregate/AggregationOperation.scala`:
- Line 240: In the aggregation logic around the partial result handling, stop
using AttributeTypeUtils.minValue(attributeType) as the empty-group sentinel.
Track a separate “value observed” state alongside the aggregate, preserve and
merge that state through local and worker-to-final aggregation, and return null
only when no non-null value was observed. Add tests covering groups whose values
all equal the type minimum.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 918ed3e1-bc24-4c9e-9c6b-0dd0e68faee3

📥 Commits

Reviewing files that changed from the base of the PR and between 5e41efa and c879f75.

📒 Files selected for processing (3)
  • common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/aggregate/AggregationOperation.scala
  • common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregateOpSpec.scala
  • common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/aggregate/AggregationOperationSpec.scala

if (AttributeTypeUtils.compare(partial1, partial2, attributeType) > 0) partial1
else partial2,
partial => if (partial == AttributeTypeUtils.maxValue(attributeType)) null else partial
partial => if (partial == AttributeTypeUtils.minValue(attributeType)) null else partial

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Do not use minValue as the empty-group marker.

A non-empty group whose maximum equals AttributeTypeUtils.minValue(attributeType) returns null. For example, MAX(Int.MinValue) keeps the initialized partial because the comparison is not greater than zero. Line 240 then treats that valid result as empty.

Store whether a non-null value was observed separately from the aggregate value. Preserve that state during merge. Add local and worker-to-final tests where every value equals the type minimum.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/aggregate/AggregationOperation.scala`
at line 240, In the aggregation logic around the partial result handling, stop
using AttributeTypeUtils.minValue(attributeType) as the empty-group sentinel.
Track a separate “value observed” state alongside the aggregate, preserve and
merge that state through local and worker-to-final aggregation, and return null
only when no non-null value was observed. Add tests covering groups whose values
all equal the type minimum.

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.

2 participants