@Test public void diffMetadata() { List<ColumnMetadata> inputColumns = mixColumns(); TableMetadata expectedMetadata = new TableMetadata( ImmutableList.of( colKey, new ColumnMetadata("both", Schema.STRING, "both", true, false), colKeyStatus, new ColumnMetadata( TableDiff.baseColumnName("value"), Schema.STRING, "value", false, false), new ColumnMetadata( TableDiff.deltaColumnName("value"), Schema.STRING, "value", false, false), new ColumnMetadata( TableDiff.baseColumnName("neither"), Schema.STRING, "neither", false, false), new ColumnMetadata( TableDiff.deltaColumnName("neither"), Schema.STRING, "neither", false, false)), "[key, both]"); assertThat( TableDiff.diffMetadata(new TableMetadata(inputColumns, "desc")), equalTo(expectedMetadata)); }
public static TableMetadata diffMetadata(TableMetadata inputMetadata) { ImmutableList.Builder<ColumnMetadata> diffColumnMetatadata = ImmutableList.builder(); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { diffColumnMetatadata.add( new ColumnMetadata(cm.getName(), cm.getSchema(), cm.getDescription(), true, false)); } } String dhintText = "[" + diffColumnMetatadata.build().stream() .map(ColumnMetadata::getName) .collect(Collectors.joining(", ")) + "]"; diffColumnMetatadata.add( new ColumnMetadata(COL_KEY_PRESENCE, Schema.STRING, COL_KEY_PRESENCE_DESC, false, true)); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { continue; } diffColumnMetatadata.add( new ColumnMetadata( baseColumnName(cm.getName()), cm.getSchema(), cm.getDescription(), false, false), new ColumnMetadata( deltaColumnName(cm.getName()), cm.getSchema(), cm.getDescription(), false, false)); } return new TableMetadata(diffColumnMetatadata.build(), dhintText); }
TableDiff { public static TableMetadata diffMetadata(TableMetadata inputMetadata) { ImmutableList.Builder<ColumnMetadata> diffColumnMetatadata = ImmutableList.builder(); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { diffColumnMetatadata.add( new ColumnMetadata(cm.getName(), cm.getSchema(), cm.getDescription(), true, false)); } } String dhintText = "[" + diffColumnMetatadata.build().stream() .map(ColumnMetadata::getName) .collect(Collectors.joining(", ")) + "]"; diffColumnMetatadata.add( new ColumnMetadata(COL_KEY_PRESENCE, Schema.STRING, COL_KEY_PRESENCE_DESC, false, true)); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { continue; } diffColumnMetatadata.add( new ColumnMetadata( baseColumnName(cm.getName()), cm.getSchema(), cm.getDescription(), false, false), new ColumnMetadata( deltaColumnName(cm.getName()), cm.getSchema(), cm.getDescription(), false, false)); } return new TableMetadata(diffColumnMetatadata.build(), dhintText); } }
TableDiff { public static TableMetadata diffMetadata(TableMetadata inputMetadata) { ImmutableList.Builder<ColumnMetadata> diffColumnMetatadata = ImmutableList.builder(); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { diffColumnMetatadata.add( new ColumnMetadata(cm.getName(), cm.getSchema(), cm.getDescription(), true, false)); } } String dhintText = "[" + diffColumnMetatadata.build().stream() .map(ColumnMetadata::getName) .collect(Collectors.joining(", ")) + "]"; diffColumnMetatadata.add( new ColumnMetadata(COL_KEY_PRESENCE, Schema.STRING, COL_KEY_PRESENCE_DESC, false, true)); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { continue; } diffColumnMetatadata.add( new ColumnMetadata( baseColumnName(cm.getName()), cm.getSchema(), cm.getDescription(), false, false), new ColumnMetadata( deltaColumnName(cm.getName()), cm.getSchema(), cm.getDescription(), false, false)); } return new TableMetadata(diffColumnMetatadata.build(), dhintText); } private  TableDiff(); }
TableDiff { public static TableMetadata diffMetadata(TableMetadata inputMetadata) { ImmutableList.Builder<ColumnMetadata> diffColumnMetatadata = ImmutableList.builder(); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { diffColumnMetatadata.add( new ColumnMetadata(cm.getName(), cm.getSchema(), cm.getDescription(), true, false)); } } String dhintText = "[" + diffColumnMetatadata.build().stream() .map(ColumnMetadata::getName) .collect(Collectors.joining(", ")) + "]"; diffColumnMetatadata.add( new ColumnMetadata(COL_KEY_PRESENCE, Schema.STRING, COL_KEY_PRESENCE_DESC, false, true)); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { continue; } diffColumnMetatadata.add( new ColumnMetadata( baseColumnName(cm.getName()), cm.getSchema(), cm.getDescription(), false, false), new ColumnMetadata( deltaColumnName(cm.getName()), cm.getSchema(), cm.getDescription(), false, false)); } return new TableMetadata(diffColumnMetatadata.build(), dhintText); } 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 { public static TableMetadata diffMetadata(TableMetadata inputMetadata) { ImmutableList.Builder<ColumnMetadata> diffColumnMetatadata = ImmutableList.builder(); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { diffColumnMetatadata.add( new ColumnMetadata(cm.getName(), cm.getSchema(), cm.getDescription(), true, false)); } } String dhintText = "[" + diffColumnMetatadata.build().stream() .map(ColumnMetadata::getName) .collect(Collectors.joining(", ")) + "]"; diffColumnMetatadata.add( new ColumnMetadata(COL_KEY_PRESENCE, Schema.STRING, COL_KEY_PRESENCE_DESC, false, true)); for (ColumnMetadata cm : inputMetadata.getColumnMetadata()) { if (cm.getIsKey()) { continue; } diffColumnMetatadata.add( new ColumnMetadata( baseColumnName(cm.getName()), cm.getSchema(), cm.getDescription(), false, false), new ColumnMetadata( deltaColumnName(cm.getName()), cm.getSchema(), cm.getDescription(), false, false)); } return new TableMetadata(diffColumnMetatadata.build(), dhintText); } 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; }