From e3feb2a8f6df0da3debb55b6d49553696a23b3e2 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Wed, 23 Aug 2023 13:05:36 +0200 Subject: [PATCH 1/2] Add key order sensitivity to map comparator --- DIFF.md | 2 +- .../spark/diff/DiffComparators.scala | 2 +- .../diff/comparator/MapDiffComparator.scala | 15 ++++---- .../spark/diff/DiffComparatorSuite.scala | 34 ++++++++++--------- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/DIFF.md b/DIFF.md index 1c03a0f6..e4ecae4c 100644 --- a/DIFF.md +++ b/DIFF.md @@ -306,7 +306,7 @@ The following alternative comparators are provided: |`DiffComparators.epsilon(epsilon)`|Two values are equal when they are at most `epsilon` apart.

The comparator can be configured to use `epsilon` as an absolute (`.asAbsolute()`) threshold, or as relative (`.asRelative()`) to the larger value. Further, the threshold itself can be considered equal (`.asInclusive()`) or not equal (`.asExclusive()`):| |`DiffComparators.string()`|Two `StringType` values are compared while ignoring white space differences. For this comparison, sequences of whitespaces are collapesed into single whitespaces, leading and trailing whitespaces are removed. With `DiffComparators.string(false)`, string values are compared with the default comparator.| |`DiffComparators.duration(duration)`|Two `DateType` or `TimestampType` values are equal when they are at most `duration` apart. That duration is an instance of `java.time.Duration`.

The comparator can be configured to consider `duration` as equal (`.asInclusive()`) or not equal (`.asExclusive()`):