@Test public void diffRowValues() { Row baseRow = mixRow("key1", "both1", "value1", null); Row deltaRow = mixRow(null, null, null, "neither2"); RowBuilder diff = Row.builder(); TableDiff.diffRowValues(diff, baseRow, deltaRow, new TableMetadata(mixColumns(), "desc")); assertThat( diff.build(), equalTo( Row.of( TableDiff.COL_KEY_PRESENCE, TableDiff.COL_KEY_STATUS_BOTH, TableDiff.baseColumnName("value"), "value1", TableDiff.deltaColumnName("value"), null, TableDiff.baseColumnName("neither"), null, TableDiff.deltaColumnName("neither"), "neither2"))); }
@VisibleForTesting static void diffRowValues( RowBuilder rowBuilder, @Nullable Row baseRow, @Nullable Row deltaRow, TableMetadata inputMetadata) { checkArgument(baseRow != null || deltaRow != null, "Both base and delta rows cannot be null"); checkArgument(rowBuilder != null, "rowBuilder cannot be null"); checkArgument(inputMetadata.getColumnMetadata() != null, "columns cannot be null"); String keyStatus = baseRow == null ? COL_KEY_STATUS_ONLY_DELTA : deltaRow == null ? COL_KEY_STATUS_ONLY_BASE : COL_KEY_STATUS_BOTH; rowBuilder.put(COL_KEY_PRESENCE, keyStatus); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { continue; } Object baseValue = baseRow == null ? null : baseRow.get(cm.getName(), cm.getSchema()); Object deltaValue = deltaRow == null ? null : deltaRow.get(cm.getName(), cm.getSchema()); rowBuilder .put(baseColumnName(cm.getName()), baseValue) .put(deltaColumnName(cm.getName()), deltaValue); } }
TableDiff { @VisibleForTesting static void diffRowValues( RowBuilder rowBuilder, @Nullable Row baseRow, @Nullable Row deltaRow, TableMetadata inputMetadata) { checkArgument(baseRow != null || deltaRow != null, "Both base and delta rows cannot be null"); checkArgument(rowBuilder != null, "rowBuilder cannot be null"); checkArgument(inputMetadata.getColumnMetadata() != null, "columns cannot be null"); String keyStatus = baseRow == null ? COL_KEY_STATUS_ONLY_DELTA : deltaRow == null ? COL_KEY_STATUS_ONLY_BASE : COL_KEY_STATUS_BOTH; rowBuilder.put(COL_KEY_PRESENCE, keyStatus); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { continue; } Object baseValue = baseRow == null ? null : baseRow.get(cm.getName(), cm.getSchema()); Object deltaValue = deltaRow == null ? null : deltaRow.get(cm.getName(), cm.getSchema()); rowBuilder .put(baseColumnName(cm.getName()), baseValue) .put(deltaColumnName(cm.getName()), deltaValue); } } }
TableDiff { @VisibleForTesting static void diffRowValues( RowBuilder rowBuilder, @Nullable Row baseRow, @Nullable Row deltaRow, TableMetadata inputMetadata) { checkArgument(baseRow != null || deltaRow != null, "Both base and delta rows cannot be null"); checkArgument(rowBuilder != null, "rowBuilder cannot be null"); checkArgument(inputMetadata.getColumnMetadata() != null, "columns cannot be null"); String keyStatus = baseRow == null ? COL_KEY_STATUS_ONLY_DELTA : deltaRow == null ? COL_KEY_STATUS_ONLY_BASE : COL_KEY_STATUS_BOTH; rowBuilder.put(COL_KEY_PRESENCE, keyStatus); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { continue; } Object baseValue = baseRow == null ? null : baseRow.get(cm.getName(), cm.getSchema()); Object deltaValue = deltaRow == null ? null : deltaRow.get(cm.getName(), cm.getSchema()); rowBuilder .put(baseColumnName(cm.getName()), baseValue) .put(deltaColumnName(cm.getName()), deltaValue); } } private  TableDiff(); }
TableDiff { @VisibleForTesting static void diffRowValues( RowBuilder rowBuilder, @Nullable Row baseRow, @Nullable Row deltaRow, TableMetadata inputMetadata) { checkArgument(baseRow != null || deltaRow != null, "Both base and delta rows cannot be null"); checkArgument(rowBuilder != null, "rowBuilder cannot be null"); checkArgument(inputMetadata.getColumnMetadata() != null, "columns cannot be null"); String keyStatus = baseRow == null ? COL_KEY_STATUS_ONLY_DELTA : deltaRow == null ? COL_KEY_STATUS_ONLY_BASE : COL_KEY_STATUS_BOTH; rowBuilder.put(COL_KEY_PRESENCE, keyStatus); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { continue; } Object baseValue = baseRow == null ? null : baseRow.get(cm.getName(), cm.getSchema()); Object deltaValue = deltaRow == null ? null : deltaRow.get(cm.getName(), cm.getSchema()); rowBuilder .put(baseColumnName(cm.getName()), baseValue) .put(deltaColumnName(cm.getName()), deltaValue); } } private  TableDiff(); static String baseColumnName(String originalColumnName); static String deltaColumnName(String originalColumnName); static TableMetadata diffMetadata(TableMetadata inputMetadata); static TableAnswerElement diffTables(
      TableAnswerElement baseTable, TableAnswerElement deltaTable, boolean includeOneTableKeys); }
TableDiff { @VisibleForTesting static void diffRowValues( RowBuilder rowBuilder, @Nullable Row baseRow, @Nullable Row deltaRow, TableMetadata inputMetadata) { checkArgument(baseRow != null || deltaRow != null, "Both base and delta rows cannot be null"); checkArgument(rowBuilder != null, "rowBuilder cannot be null"); checkArgument(inputMetadata.getColumnMetadata() != null, "columns cannot be null"); String keyStatus = baseRow == null ? COL_KEY_STATUS_ONLY_DELTA : deltaRow == null ? COL_KEY_STATUS_ONLY_BASE : COL_KEY_STATUS_BOTH; rowBuilder.put(COL_KEY_PRESENCE, keyStatus); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { continue; } Object baseValue = baseRow == null ? null : baseRow.get(cm.getName(), cm.getSchema()); Object deltaValue = deltaRow == null ? null : deltaRow.get(cm.getName(), cm.getSchema()); rowBuilder .put(baseColumnName(cm.getName()), baseValue) .put(deltaColumnName(cm.getName()), deltaValue); } } private  TableDiff(); static String baseColumnName(String originalColumnName); static String deltaColumnName(String originalColumnName); static TableMetadata diffMetadata(TableMetadata inputMetadata); static TableAnswerElement diffTables(
      TableAnswerElement baseTable, TableAnswerElement deltaTable, boolean includeOneTableKeys); static final String COL_BASE_PREFIX; static final String COL_DELTA_PREFIX; static final String COL_KEY_PRESENCE; static final String COL_KEY_PRESENCE_DESC; static final String COL_KEY_STATUS_BOTH; static final String COL_KEY_STATUS_ONLY_BASE; static final String COL_KEY_STATUS_ONLY_DELTA; }