private static <X> void assertEqualStatistics(
      ColumnStatisticsData expected, ColumnStatisticsData computed, Class<X> clazz) {
    try {
      final Object computedStats = computed.getFieldValue(computed.getSetField());
      final Object expectedStats = expected.getFieldValue(computed.getSetField());
      final boolean computedHasHistograms = (boolean) clazz.getMethod("isSetHistogram").invoke(computedStats);
      final boolean expectedHasHistograms = (boolean) clazz.getMethod("isSetHistogram").invoke(expectedStats);

      if (computedHasHistograms && expectedHasHistograms) {
        // KLL data sketches serialization depends on the insertion order, we can only safely compare their string
        // representation, we replace the serialized version and restore it back after comparison to not alter the input
        byte[] expectedHistogram = (byte[]) clazz.getMethod("getHistogram").invoke(expectedStats);
        byte[] computedHistogram = (byte[]) clazz.getMethod("getHistogram").invoke(computedStats);

        Assert.assertEquals(KllUtils.deserializeKll(expectedHistogram).toString(),
            KllUtils.deserializeKll(computedHistogram).toString());

        clazz.getMethod("setHistogram", byte[].class).invoke(expectedStats, computedHistogram);
        Assert.assertEquals(expected, computed);
        clazz.getMethod("setHistogram", byte[].class).invoke(expectedStats, expectedHistogram);
      } else {
        Assert.assertEquals(expected, computed);
      }
    } catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e){
      throw new RuntimeException("Reflection error", e);
    }
  }
Checks if expected and computed statistics data are equal.
@param expected expected statistics data
@param computed computed statistics data
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/StatisticsTestUtils.java