Skip to content

Commit

Permalink
Add "type_aliases" column in "show migration check algorithms" DistSQ…
Browse files Browse the repository at this point in the history
…L result (#28453)
  • Loading branch information
sandynz authored Sep 18, 2023
1 parent c1095ea commit bc575fd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public final class DataConsistencyCheckAlgorithmInfo {

private final String type;

private final String typeAliases;

private final Collection<DatabaseType> supportedDatabaseTypes;

private final String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
Expand Down Expand Up @@ -203,7 +204,8 @@ public Collection<DataConsistencyCheckAlgorithmInfo> listDataConsistencyCheckAlg
Collection<DataConsistencyCheckAlgorithmInfo> result = new LinkedList<>();
for (TableDataConsistencyChecker each : ShardingSphereServiceLoader.getServiceInstances(TableDataConsistencyChecker.class)) {
SPIDescription description = each.getClass().getAnnotation(SPIDescription.class);
result.add(new DataConsistencyCheckAlgorithmInfo(each.getType(), getSupportedDatabaseTypes(each.getSupportedDatabaseTypes()), null == description ? "" : description.value()));
String typeAliases = each.getTypeAliases().stream().map(Object::toString).collect(Collectors.joining(","));
result.add(new DataConsistencyCheckAlgorithmInfo(each.getType(), typeAliases, getSupportedDatabaseTypes(each.getSupportedDatabaseTypes()), null == description ? "" : description.value()));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public final class ShowMigrationCheckAlgorithmsExecutor implements QueryableRALE
public Collection<LocalDataQueryResultRow> getRows(final ShowMigrationCheckAlgorithmsStatement sqlStatement) {
InventoryIncrementalJobAPI jobAPI = (InventoryIncrementalJobAPI) TypedSPILoader.getService(PipelineJobAPI.class, "MIGRATION");
return jobAPI.listDataConsistencyCheckAlgorithms().stream().map(
each -> new LocalDataQueryResultRow(each.getType(),
each -> new LocalDataQueryResultRow(each.getType(), each.getTypeAliases(),
each.getSupportedDatabaseTypes().stream().map(DatabaseType::getType).collect(Collectors.joining(",")), each.getDescription()))
.collect(Collectors.toList());
}

@Override
public Collection<String> getColumnNames() {
return Arrays.asList("type", "supported_database_types", "description");
return Arrays.asList("type", "type_aliases", "supported_database_types", "description");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class ShowMigrationCheckAlgorithmsExecutorTest {
void assertGetColumnNames() {
ShowMigrationCheckAlgorithmsExecutor executor = new ShowMigrationCheckAlgorithmsExecutor();
Collection<String> columns = executor.getColumnNames();
assertThat(columns.size(), is(3));
assertThat(columns.size(), is(4));
Iterator<String> iterator = columns.iterator();
assertThat(iterator.next(), is("type"));
assertThat(iterator.next(), is("type_aliases"));
assertThat(iterator.next(), is("supported_database_types"));
assertThat(iterator.next(), is("description"));
}
Expand Down

0 comments on commit bc575fd

Please sign in to comment.