Repository navigation
fix(diffy): compare Long fields exactly in AvroDiffy - #942
Open
pcbeingused33 wants to merge 1 commit into
Open
pcbeingused33 wants to merge 1 commit into
pcbeingused33 wants to merge 1 commit into
Conversation
Longs were converted to Double before the equality check, so values that differ only above 2^53 were reported as identical. Compare two Longs exactly; the delta still goes through numericDelta. Other numeric types keep the Double comparison.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AvroDiffyconverted numeric fields toDoublebefore checking equality.Longvalues above 2^53 lose precision in that conversion, so two records whose ids differ only past that point (for example9007199254740992and9007199254740993) were reported as identical and BigDiffy hid the change.Compare two
Longs exactly instead. The delta is still computed through the overridablenumericDeltahook, so it stays aDouble(it can be 0.0 for two distinct Longs that round to the same Double, but the difference is now reported). Int, Float and Double keep the existing Double comparison (including NaN semantics), and a test covers that.Testing and validation
New
AvroDiffyTestcase "detect differences between Longs above 2^53": fails on current master (the diff is empty), passes with the fix and reports the difference (NumericDelta(0.0), since the Doubles round equal). A second test checks that Double fields keep the existing comparison (NaN case).AvroDiffyTestpasses (10 tests).sbt "ratatoolDiffy/testOnly com.spotify.ratatool.diffy.AvroDiffyTest"on JDK 17, Scala 2.12.21.AI assistance was used to prepare this change and its tests.