### Question:
DateColumnStatsMerger extends ColumnStatsMerger { @Override public void merge(ColumnStatisticsObj aggregateColStats, ColumnStatisticsObj newColStats) { LOG.debug("Merging statistics: [aggregateColStats:{}, newColStats: {}]", aggregateColStats, newColStats); DateColumnStatsDataInspector aggregateData = dateInspectorFromStats(aggregateColStats); DateColumnStatsDataInspector newData = dateInspectorFromStats(newColStats); setLowValue(aggregateData, newData); setHighValue(aggregateData, newData); aggregateData.setNumNulls(aggregateData.getNumNulls() + newData.getNumNulls()); if (aggregateData.getNdvEstimator() == null || newData.getNdvEstimator() == null) { aggregateData.setNumDVs(Math.max(aggregateData.getNumDVs(), newData.getNumDVs())); } else { NumDistinctValueEstimator oldEst = aggregateData.getNdvEstimator(); NumDistinctValueEstimator newEst = newData.getNdvEstimator(); final long ndv; if (oldEst.canMerge(newEst)) { oldEst.mergeEstimators(newEst); ndv = oldEst.estimateNumDistinctValues(); aggregateData.setNdvEstimator(oldEst); } else { ndv = Math.max(aggregateData.getNumDVs(), newData.getNumDVs()); } LOG.debug("Use bitvector to merge column {}'s ndvs of {} and {} to be {}", aggregateColStats.getColName(), aggregateData.getNumDVs(), newData.getNumDVs(), ndv); aggregateData.setNumDVs(ndv); } aggregateColStats.getStatsData().setDateStats(aggregateData); }  @Override void merge(ColumnStatisticsObj aggregateColStats, ColumnStatisticsObj newColStats); void setLowValue(DateColumnStatsDataInspector aggregateData, DateColumnStatsDataInspector newData); void setHighValue(DateColumnStatsDataInspector aggregateData, DateColumnStatsDataInspector newData);  }### Answer:
@Test public void testMergeNullMinMaxValues() { ColumnStatisticsObj old = new ColumnStatisticsObj(); createData(old, null, null); merger.merge(old, old); Assert.assertNull(old.getStatsData().getDateStats().getLowValue()); Assert.assertNull(old.getStatsData().getDateStats().getHighValue()); }
@Test public void testMergeNulls() { ColumnStatisticsObj oldObj = new ColumnStatisticsObj(); createData(oldObj, null, null); ColumnStatisticsObj newObj; newObj = new ColumnStatisticsObj(); createData(newObj, null, null); merger.merge(oldObj, newObj); Assert.assertEquals(null, oldObj.getStatsData().getDateStats().getLowValue()); Assert.assertEquals(null, oldObj.getStatsData().getDateStats().getHighValue()); newObj = new ColumnStatisticsObj(); createData(newObj, DATE_1, DATE_3); merger.merge(oldObj, newObj); newObj = new ColumnStatisticsObj(); createData(newObj, null, null); merger.merge(oldObj, newObj); Assert.assertEquals(DATE_1, oldObj.getStatsData().getDateStats().getLowValue()); Assert.assertEquals(DATE_3, oldObj.getStatsData().getDateStats().getHighValue()); }
@Test public void testMergeNonNullAndNullLowerValuesNewIsNull() { ColumnStatisticsObj oldObj = new ColumnStatisticsObj(); createData(oldObj, DATE_2, DATE_2); ColumnStatisticsObj newObj; newObj = new ColumnStatisticsObj(); createData(newObj, DATE_3, DATE_3); merger.merge(oldObj, newObj); newObj = new ColumnStatisticsObj(); createData(newObj, DATE_1, DATE_1); merger.merge(oldObj, newObj); Assert.assertEquals(DATE_1, oldObj.getStatsData().getDateStats().getLowValue()); Assert.assertEquals(DATE_3, oldObj.getStatsData().getDateStats().getHighValue()); }