Skip to content

Commit

Permalink
Add SQLStatement parameter on DistSQLQueryExecutor.getColumnNames() (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Feb 11, 2024
1 parent 734c188 commit 538373b
Show file tree
Hide file tree
Showing 61 changed files with 66 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class ShowBroadcastTableRuleExecutor implements DistSQLQueryExecuto
private BroadcastRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowBroadcastTableRulesStatement sqlStatement) {
return Collections.singleton("broadcast_table");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final class ShowEncryptRuleExecutor implements DistSQLQueryExecutor<ShowE
private EncryptRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowEncryptRulesStatement sqlStatement) {
return Arrays.asList("table", "logic_column", "cipher_column",
"assisted_query_column", "like_query_column", "encryptor_type", "encryptor_props", "assisted_query_type", "assisted_query_props", "like_query_type", "like_query_props");
}
Expand Down Expand Up @@ -76,18 +76,14 @@ private Collection<LocalDataQueryResultRow> buildColumnData(final EncryptTableRu
each.getLikeQuery().map(EncryptColumnItemRuleConfiguration::getName).orElse(""),
encryptorAlgorithmConfig.getType(),
PropertiesConverter.convert(encryptorAlgorithmConfig.getProps()),
null == assistedQueryEncryptorAlgorithmConfig ? nullToEmptyString(null) : assistedQueryEncryptorAlgorithmConfig.getType(),
null == assistedQueryEncryptorAlgorithmConfig ? nullToEmptyString(null) : PropertiesConverter.convert(assistedQueryEncryptorAlgorithmConfig.getProps()),
null == likeQueryEncryptorAlgorithmConfig ? nullToEmptyString(null) : likeQueryEncryptorAlgorithmConfig.getType(),
null == likeQueryEncryptorAlgorithmConfig ? nullToEmptyString(null) : PropertiesConverter.convert(likeQueryEncryptorAlgorithmConfig.getProps()))));
null == assistedQueryEncryptorAlgorithmConfig ? "" : assistedQueryEncryptorAlgorithmConfig.getType(),
null == assistedQueryEncryptorAlgorithmConfig ? "" : PropertiesConverter.convert(assistedQueryEncryptorAlgorithmConfig.getProps()),
null == likeQueryEncryptorAlgorithmConfig ? "" : likeQueryEncryptorAlgorithmConfig.getType(),
null == likeQueryEncryptorAlgorithmConfig ? "" : PropertiesConverter.convert(likeQueryEncryptorAlgorithmConfig.getProps()))));
}
return result;
}

private Object nullToEmptyString(final Object obj) {
return null == obj ? "" : obj;
}

@Override
public Class<EncryptRule> getRuleClass() {
return EncryptRule.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class ShowMaskRuleExecutor implements DistSQLQueryExecutor<ShowMask
private MaskRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowMaskRulesStatement sqlStatement) {
return Arrays.asList("table", "column", "algorithm_type", "algorithm_props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public final class ShowReadwriteSplittingRuleExecutor implements DistSQLQueryExe
private ReadwriteSplittingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowReadwriteSplittingRulesStatement sqlStatement) {
return Arrays.asList("name", "write_storage_unit_name", "read_storage_unit_names", "transactional_read_query_strategy", "load_balancer_type", "load_balancer_props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public final class ShowStatusFromReadwriteSplittingRulesExecutor implements Dist
private ShardingSphereDatabase database;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowStatusFromReadwriteSplittingRulesStatement sqlStatement) {
return Arrays.asList("storage_unit", "status");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class ShowDefaultShadowAlgorithmExecutor implements DistSQLQueryExe
private ShadowRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowDefaultShadowAlgorithmStatement sqlStatement) {
return Arrays.asList("shadow_algorithm_name", "type", "props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class ShowShadowAlgorithmsExecutor implements DistSQLQueryExecutor<
private ShadowRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShadowAlgorithmsStatement sqlStatement) {
return Arrays.asList("shadow_algorithm_name", "type", "props", "is_default");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final class ShowShadowRuleExecutor implements DistSQLQueryExecutor<ShowSh
private ShadowRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShadowRulesStatement sqlStatement) {
return Arrays.asList("shadow_table", "rule_name", "source_name", "shadow_name", "algorithm_type", "algorithm_props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final class ShowShadowTableRulesExecutor implements DistSQLQueryExecutor<
private ShadowRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShadowTableRulesStatement sqlStatement) {
return Arrays.asList(SHADOW_TABLE, SHADOW_ALGORITHM_NAME);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class ShowDefaultShardingStrategyExecutor implements DistSQLQueryEx
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowDefaultShardingStrategyStatement sqlStatement) {
return Arrays.asList("name", "type", "sharding_column", "sharding_algorithm_name", "sharding_algorithm_type", "sharding_algorithm_props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class ShowShardingAlgorithmExecutor implements DistSQLQueryExecutor
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShardingAlgorithmsStatement sqlStatement) {
return Arrays.asList("name", "type", "props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class ShowShardingAuditorsExecutor implements DistSQLQueryExecutor<
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShardingAuditorsStatement sqlStatement) {
return Arrays.asList("name", "type", "props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class ShowShardingKeyGeneratorExecutor implements DistSQLQueryExecu
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShardingKeyGeneratorsStatement sqlStatement) {
return Arrays.asList("name", "type", "props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class ShowShardingTableNodesExecutor implements DistSQLQueryExecuto
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShardingTableNodesStatement sqlStatement) {
return Arrays.asList("name", "nodes");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class ShowShardingTableReferenceRuleExecutor implements DistSQLQuer
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShardingTableReferenceRulesStatement sqlStatement) {
return Arrays.asList("name", "sharding_table_reference");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public final class ShowShardingTableRuleExecutor implements DistSQLQueryExecutor
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShardingTableRulesStatement sqlStatement) {
return Arrays.asList("table", "actual_data_nodes", "actual_data_sources", "database_strategy_type", "database_sharding_column", "database_sharding_algorithm_type",
"database_sharding_algorithm_props", "table_strategy_type", "table_sharding_column", "table_sharding_algorithm_type", "table_sharding_algorithm_props",
"key_generate_column", "key_generator_type", "key_generator_props", "auditor_types", "allow_hint_disable");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class ShowShardingTableRulesUsedAlgorithmExecutor implements DistSQ
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShardingTableRulesUsedAlgorithmStatement sqlStatement) {
return Arrays.asList("type", "name");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class ShowShardingTableRulesUsedAuditorExecutor implements DistSQLQ
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShardingTableRulesUsedAuditorStatement sqlStatement) {
return Arrays.asList("type", "name");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class ShowShardingTableRulesUsedKeyGeneratorExecutor implements Dis
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowShardingTableRulesUsedKeyGeneratorStatement sqlStatement) {
return Arrays.asList("type", "name");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final class ShowUnusedShardingAlgorithmsExecutor implements DistSQLQueryE
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowUnusedShardingAlgorithmsStatement sqlStatement) {
return Arrays.asList("name", "type", "props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class ShowUnusedShardingAuditorsExecutor implements DistSQLQueryExe
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowUnusedShardingAuditorsStatement sqlStatement) {
return Arrays.asList("name", "type", "props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class ShowUnusedShardingKeyGeneratorExecutor implements DistSQLQuer
private ShardingRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowUnusedShardingKeyGeneratorsStatement sqlStatement) {
return Arrays.asList("name", "type", "props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,13 @@ public DistSQLQueryExecuteEngine(final DistSQLStatement sqlStatement, final Stri
@SuppressWarnings("unchecked")
public void executeQuery() throws SQLException {
DistSQLQueryExecutor<DistSQLStatement> executor = TypedSPILoader.getService(DistSQLQueryExecutor.class, sqlStatement.getClass());
columnNames = executor.getColumnNames(sqlStatement);
try {
new DistSQLExecutorAwareSetter(executor).set(contextManager, null == databaseName ? null : contextManager.getDatabase(databaseName), distsqlConnectionContext);
} catch (final UnsupportedSQLOperationException ignored) {
rows = Collections.emptyList();
columnNames = executor.getColumnNames();
return;
}
rows = executor.getRows(sqlStatement, contextManager);
columnNames = executor.getColumnNames();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public interface DistSQLQueryExecutor<T extends DistSQLStatement> extends TypedS
/**
* Get column names.
*
* @param sqlStatement DistSQL statement
* @return column names
*/
Collection<String> getColumnNames();
Collection<String> getColumnNames(T sqlStatement);

/**
* Get query result rows.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public final class ShowPluginsExecutor implements DistSQLQueryExecutor<ShowPluginsStatement> {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class ShowLogicalTableExecutor implements DistSQLQueryExecutor<Show
private ShardingSphereDatabase database;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowLogicalTablesStatement sqlStatement) {
return Collections.singleton("table_name");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class ShowRulesUsedStorageUnitExecutor implements DistSQLQueryExecu
private ShardingSphereDatabase database;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowRulesUsedStorageUnitStatement sqlStatement) {
return Arrays.asList("type", "name");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public final class ShowStorageUnitExecutor implements DistSQLQueryExecutor<ShowS
private ShardingSphereDatabase database;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowStorageUnitsStatement sqlStatement) {
return Arrays.asList("name", "type", "host", "port", "db", "connection_timeout_milliseconds", "idle_timeout_milliseconds",
"max_lifetime_milliseconds", "max_pool_size", "min_pool_size", "read_only", "other_attributes");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class RuleCountExecutor implements DistSQLQueryExecutor<CountRuleSt
private ShardingSphereDatabase database;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final CountRuleStatement sqlStatement) {
return Arrays.asList("rule_name", "database", "count");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class ShowAuthorityRuleExecutor implements DistSQLQueryExecutor<Sho
private AuthorityRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowAuthorityRuleStatement sqlStatement) {
return Arrays.asList("users", "provider", "props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class ShowStreamingJobStatusExecutor implements DistSQLQueryExecuto
private final CDCJobAPI jobAPI = (CDCJobAPI) TypedSPILoader.getService(TransmissionJobAPI.class, "STREAMING");

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowStreamingStatusStatement sqlStatement) {
return Arrays.asList("item", "data_source", "status", "active", "processed_records_count", "inventory_finished_percentage", "incremental_idle_seconds", "confirmed_position",
"current_position", "error_message");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class ShowStreamingListExecutor implements DistSQLQueryExecutor<Sho
private final PipelineJobManager pipelineJobManager = new PipelineJobManager(new CDCJobType());

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowStreamingListStatement sqlStatement) {
return Arrays.asList("id", "database", "tables", "job_item_count", "active", "create_time", "stop_time");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class ShowStreamingRuleExecutor implements DistSQLQueryExecutor<Sho
private final ShowTransmissionRuleQueryResult queryResult = new ShowTransmissionRuleQueryResult("STREAMING");

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowStreamingRuleStatement sqlStatement) {
return queryResult.getColumnNames();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public final class ShowMigrationCheckAlgorithmsExecutor implements DistSQLQueryExecutor<ShowMigrationCheckAlgorithmsStatement> {

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowMigrationCheckAlgorithmsStatement sqlStatement) {
return new PluginMetaDataQueryResultRows(TableDataConsistencyChecker.class).getColumnNames();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class ShowMigrationCheckStatusExecutor implements DistSQLQueryExecu
private final ConsistencyCheckJobAPI jobAPI = new ConsistencyCheckJobAPI(new ConsistencyCheckJobType());

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowMigrationCheckStatusStatement sqlStatement) {
return Arrays.asList("tables", "result", "check_failed_tables", "active", "inventory_finished_percentage", "inventory_remaining_seconds", "incremental_idle_seconds",
"check_begin_time", "check_end_time", "duration_seconds", "algorithm_type", "algorithm_props", "error_message");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public final class ShowMigrationJobStatusExecutor implements DistSQLQueryExecutor<ShowMigrationStatusStatement> {

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowMigrationStatusStatement sqlStatement) {
return Arrays.asList("item", "data_source", "tables", "status", "active", "processed_records_count", "inventory_finished_percentage", "incremental_idle_seconds", "error_message");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class ShowMigrationListExecutor implements DistSQLQueryExecutor<Sho
private final PipelineJobManager pipelineJobManager = new PipelineJobManager(new MigrationJobType());

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowMigrationListStatement sqlStatement) {
return Arrays.asList("id", "tables", "job_item_count", "active", "create_time", "stop_time");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class ShowMigrationSourceStorageUnitsExecutor implements DistSQLQue
private final MigrationJobAPI jobAPI = (MigrationJobAPI) TypedSPILoader.getService(TransmissionJobAPI.class, "MIGRATION");

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowMigrationSourceStorageUnitsStatement sqlStatement) {
return Arrays.asList("name", "type", "host", "port", "db", "connection_timeout_milliseconds", "idle_timeout_milliseconds",
"max_lifetime_milliseconds", "max_pool_size", "min_pool_size", "read_only", "other_attributes");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class ShowGlobalClockRuleExecutor implements DistSQLQueryExecutor<S
private GlobalClockRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowGlobalClockRuleStatement sqlStatement) {
return Arrays.asList("type", "provider", "enable", "props");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class ShowDefaultSingleTableStorageUnitExecutor implements DistSQLQ
private SingleRule rule;

@Override
public Collection<String> getColumnNames() {
public Collection<String> getColumnNames(final ShowDefaultSingleTableStorageUnitStatement sqlStatement) {
return Collections.singleton("storage_unit_name");
}

Expand Down
Loading

0 comments on commit 538373b

Please sign in to comment.