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

[SPARK-46581][CORE] Update comment on isZero in AccumulatorV2 #44583

Closed

Conversation

davintjong-db
Copy link
Contributor

@davintjong-db davintjong-db commented Jan 3, 2024

What changes were proposed in this pull request?

Two changes:

  • Update comment on AccumulatorV2's isZero to reflect what it actually does.
  • Update variable name in SQLMetrics to defaultValidValue to reflect this

Why are the changes needed?

AccumulatorV2's isZero doesn't do what the comment implies - it actually checks if the accumulator hasn't been updated.

The comment implies that for a LongAccumulator, for example, a value of 0 would cause isZero to be true. But if we were to add(0), then the value would still be 0 but isZero would return false.

Changing the name of zeroValue to defaultValidValue to avoid confusion since isZero doesn't use zeroValue in SQLMetric.

Thanks @arvindsaik for pointing this out.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing tests.

Was this patch authored or co-authored using generative AI tooling?

No.

This reverts commit be532ac.
This reverts commit ff99cb2.
@davintjong-db davintjong-db changed the title [WIP][SPARK-46581][CORE] Rename isZero to isUpdated in AccumulatorV2 [WIP][SPARK-46581][CORE] Update comment on isZero in AccumulatorV2 Jan 4, 2024
@davintjong-db davintjong-db changed the title [WIP][SPARK-46581][CORE] Update comment on isZero in AccumulatorV2 [SPARK-46581][CORE] Update comment on isZero in AccumulatorV2 Jan 4, 2024
Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

LG but cc @cloud-fan

* Returns if this accumulator is zero value or not. e.g. for a counter accumulator, 0 is zero
* value; for a list accumulator, Nil is zero value.
* Returns false if this accumulator has been updated. Note that this can be true even when
* the value is a zero value, if the accumulator was updated with a zero value.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the previous comment is fine. Each accumulator can define the semantic of zero value by its own.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair, reverted

@cloud-fan
Copy link
Contributor

The failed pyspark failure is unrelated, merging to master!

@cloud-fan cloud-fan closed this in 40078a4 Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants