This is an automated email from the ASF dual-hosted git repository.
sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 81ff4448c4d For code format (#30925)
81ff4448c4d is described below
commit 81ff4448c4d6f2c0142a47cd33757b626c7118e7
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Apr 17 06:45:18 2024 +0800
For code format (#30925)
---
...yptRuleConfigurationToDistSQLConverterTest.java | 10 +++----
...askRuleConfigurationToDistSQLConverterTest.java | 10 +++----
...ingRuleConfigurationToDistSQLConverterTest.java | 10 +++----
.../ShowReadwriteSplittingRuleExecutorTest.java | 34 +++++++++++-----------
...dowRuleConfigurationToDistSQLConverterTest.java | 18 ++++++------
...ingRuleConfigurationToDistSQLConverterTest.java | 26 ++++++++---------
.../ShowDefaultShardingStrategyExecutorTest.java | 8 ++---
.../expression/impl/ColumnSegmentBinder.java | 4 +--
.../expression/impl/SubquerySegmentBinderTest.java | 10 +++----
.../caseinsensitive/CaseInsensitiveIdentifier.java | 2 +-
.../database/resource/unit/StorageUnit.java | 6 ++--
.../schema/manager/SystemSchemaManager.java | 2 +-
.../ShardingSphereDatabaseMetaDataTest.java | 8 ++---
.../pipeline/mysql/ingest/client/MySQLClient.java | 6 ++--
...gleRuleConfigurationToDistSQLConverterTest.java | 12 ++++----
.../xa/XAShardingSphereTransactionManager.java | 2 +-
.../statement/type/MySQLDMLStatementVisitor.java | 2 +-
.../type/PostgreSQLDDLStatementVisitor.java | 2 +-
.../general/PostgreSQLToMySQLMigrationE2EIT.java | 12 ++++----
19 files changed, 92 insertions(+), 92 deletions(-)
diff --git
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/provider/EncryptRuleConfigurationToDistSQLConverterTest.java
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/provider/EncryptRuleConfigurationToDistSQLConverterTest.java
index 04b44a66f41..3d79ea1501b 100644
---
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/provider/EncryptRuleConfigurationToDistSQLConverterTest.java
+++
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/provider/EncryptRuleConfigurationToDistSQLConverterTest.java
@@ -38,17 +38,17 @@ class EncryptRuleConfigurationToDistSQLConverterTest {
@Test
void assertConvertWithEmptyTables() {
- EncryptRuleConfiguration encryptRuleConfiguration =
mock(EncryptRuleConfiguration.class);
-
when(encryptRuleConfiguration.getTables()).thenReturn(Collections.emptyList());
+ EncryptRuleConfiguration encryptRuleConfig =
mock(EncryptRuleConfiguration.class);
+
when(encryptRuleConfig.getTables()).thenReturn(Collections.emptyList());
EncryptRuleConfigurationToDistSQLConverter
encryptRuleConfigurationToDistSQLConverter = new
EncryptRuleConfigurationToDistSQLConverter();
-
assertThat(encryptRuleConfigurationToDistSQLConverter.convert(encryptRuleConfiguration),
is(""));
+
assertThat(encryptRuleConfigurationToDistSQLConverter.convert(encryptRuleConfig),
is(""));
}
@Test
void assertConvert() {
- EncryptRuleConfiguration encryptRuleConfiguration =
getEncryptRuleConfiguration();
+ EncryptRuleConfiguration encryptRuleConfig =
getEncryptRuleConfiguration();
EncryptRuleConfigurationToDistSQLConverter
encryptRuleConfigurationToDistSQLConverter = new
EncryptRuleConfigurationToDistSQLConverter();
-
assertThat(encryptRuleConfigurationToDistSQLConverter.convert(encryptRuleConfiguration),
+
assertThat(encryptRuleConfigurationToDistSQLConverter.convert(encryptRuleConfig),
is("CREATE ENCRYPT RULE t_encrypt (" + System.lineSeparator()
+ "COLUMNS(" + System.lineSeparator()
+ "(NAME=user_id, CIPHER=user_cipher,
ASSISTED_QUERY_COLUMN=user_assisted, LIKE_QUERY_COLUMN=user_like,
ENCRYPT_ALGORITHM(TYPE(NAME='md5')), "
+ "ASSISTED_QUERY_ALGORITHM(),
LIKE_QUERY_ALGORITHM())," + System.lineSeparator()
diff --git
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/provider/MaskRuleConfigurationToDistSQLConverterTest.java
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/provider/MaskRuleConfigurationToDistSQLConverterTest.java
index 0bbca1c6fb6..91cd3568ca2 100644
---
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/provider/MaskRuleConfigurationToDistSQLConverterTest.java
+++
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/provider/MaskRuleConfigurationToDistSQLConverterTest.java
@@ -35,17 +35,17 @@ class MaskRuleConfigurationToDistSQLConverterTest {
@Test
void assertConvertWithEmptyTables() {
- MaskRuleConfiguration maskRuleConfiguration =
mock(MaskRuleConfiguration.class);
-
when(maskRuleConfiguration.getTables()).thenReturn(Collections.emptyList());
+ MaskRuleConfiguration maskRuleConfig =
mock(MaskRuleConfiguration.class);
+ when(maskRuleConfig.getTables()).thenReturn(Collections.emptyList());
MaskRuleConfigurationToDistSQLConverter
maskRuleConfigurationToDistSQLConverter = new
MaskRuleConfigurationToDistSQLConverter();
-
assertThat(maskRuleConfigurationToDistSQLConverter.convert(maskRuleConfiguration),
is(""));
+
assertThat(maskRuleConfigurationToDistSQLConverter.convert(maskRuleConfig),
is(""));
}
@Test
void assertConvert() {
- MaskRuleConfiguration maskRuleConfiguration =
getMaskRuleConfiguration();
+ MaskRuleConfiguration maskRuleConfig = getMaskRuleConfiguration();
MaskRuleConfigurationToDistSQLConverter
maskRuleConfigurationToDistSQLConverter = new
MaskRuleConfigurationToDistSQLConverter();
-
assertThat(maskRuleConfigurationToDistSQLConverter.convert(maskRuleConfiguration),
+
assertThat(maskRuleConfigurationToDistSQLConverter.convert(maskRuleConfig),
is("CREATE MASK RULE t_mask (" + System.lineSeparator() +
"COLUMNS(" + System.lineSeparator() + "(NAME=user_id, TYPE(NAME='md5'))" +
System.lineSeparator() + "),;"));
}
diff --git
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/provider/ReadwriteSplittingRuleConfigurationToDistSQLConverterTest.java
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/provider/ReadwriteSplittingRuleConfigurationToDistSQLConverterTest.java
index 4ab4343d3fd..6ee0ebd05af 100644
---
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/provider/ReadwriteSplittingRuleConfigurationToDistSQLConverterTest.java
+++
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/provider/ReadwriteSplittingRuleConfigurationToDistSQLConverterTest.java
@@ -35,20 +35,20 @@ class
ReadwriteSplittingRuleConfigurationToDistSQLConverterTest {
@Test
void assertConvertWithEmptyDataSources() {
- ReadwriteSplittingRuleConfiguration
readwriteSplittingRuleConfiguration =
mock(ReadwriteSplittingRuleConfiguration.class);
-
when(readwriteSplittingRuleConfiguration.getDataSources()).thenReturn(Collections.emptyList());
+ ReadwriteSplittingRuleConfiguration readwriteSplittingRuleConfig =
mock(ReadwriteSplittingRuleConfiguration.class);
+
when(readwriteSplittingRuleConfig.getDataSources()).thenReturn(Collections.emptyList());
ReadwriteSplittingRuleConfigurationToDistSQLConverter
readwriteSplittingRuleConfigurationToDistSQLConverter = new
ReadwriteSplittingRuleConfigurationToDistSQLConverter();
-
assertThat(readwriteSplittingRuleConfigurationToDistSQLConverter.convert(readwriteSplittingRuleConfiguration),
is(""));
+
assertThat(readwriteSplittingRuleConfigurationToDistSQLConverter.convert(readwriteSplittingRuleConfig),
is(""));
}
@Test
void assertConvert() {
ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig =
new
ReadwriteSplittingDataSourceRuleConfiguration("readwrite_ds", "ds_primary",
Arrays.asList("ds_slave_0", "ds_slave_1"), "test");
- ReadwriteSplittingRuleConfiguration
readwriteSplittingRuleConfiguration = new
ReadwriteSplittingRuleConfiguration(Collections.singleton(dataSourceRuleConfig),
+ ReadwriteSplittingRuleConfiguration readwriteSplittingRuleConfig = new
ReadwriteSplittingRuleConfiguration(Collections.singleton(dataSourceRuleConfig),
Collections.singletonMap("test", new
AlgorithmConfiguration("random", PropertiesBuilder.build(new
PropertiesBuilder.Property("read_weight", "2:1")))));
ReadwriteSplittingRuleConfigurationToDistSQLConverter
readwriteSplittingRuleConfigurationToDistSQLConverter = new
ReadwriteSplittingRuleConfigurationToDistSQLConverter();
-
assertThat(readwriteSplittingRuleConfigurationToDistSQLConverter.convert(readwriteSplittingRuleConfiguration),
+
assertThat(readwriteSplittingRuleConfigurationToDistSQLConverter.convert(readwriteSplittingRuleConfig),
is("CREATE READWRITE_SPLITTING RULE readwrite_ds (" +
System.lineSeparator() + "WRITE_STORAGE_UNIT=ds_primary," +
System.lineSeparator() + "READ_STORAGE_UNITS(ds_slave_0,ds_slave_1),"
+ System.lineSeparator() +
"TRANSACTIONAL_READ_QUERY_STRATEGY='DYNAMIC'," + System.lineSeparator() +
"TYPE(NAME='random', PROPERTIES('read_weight'='2:1'))"
+ System.lineSeparator() + ");"));
diff --git
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
index 30a4986530f..0b2c2a88d94 100644
---
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
+++
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
@@ -53,23 +53,6 @@ class ShowReadwriteSplittingRuleExecutorTest {
private DistSQLQueryExecuteEngine engine;
- private DistSQLQueryExecuteEngine setUp(final
ShowReadwriteSplittingRulesStatement statement, final
ReadwriteSplittingRuleConfiguration configuration) {
- return new DistSQLQueryExecuteEngine(statement, "foo_db",
mockContextManager(configuration), mock(DistSQLConnectionContext.class));
- }
-
- private ContextManager mockContextManager(final
ReadwriteSplittingRuleConfiguration ruleConfig) {
- ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
- ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
- when(result.getDatabase("foo_db")).thenReturn(database);
- ReadwriteSplittingRule rule = mock(ReadwriteSplittingRule.class);
- ReadwriteSplittingExportableRuleAttribute ruleAttribute =
mock(ReadwriteSplittingExportableRuleAttribute.class);
- when(ruleAttribute.getExportData()).thenReturn(createExportedData());
- when(rule.getConfiguration()).thenReturn(ruleConfig);
- when(rule.getAttributes()).thenReturn(new
RuleAttributes(ruleAttribute));
-
when(database.getRuleMetaData().findSingleRule(ReadwriteSplittingRule.class)).thenReturn(Optional.of(rule));
- return result;
- }
-
@Test
void assertGetRowData() throws SQLException {
engine = setUp(mock(ShowReadwriteSplittingRulesStatement.class),
createRuleConfiguration());
@@ -102,6 +85,23 @@ class ShowReadwriteSplittingRuleExecutorTest {
assertThat(row.getCell(6), is("{\"read_weight\":\"2:1\"}"));
}
+ private DistSQLQueryExecuteEngine setUp(final
ShowReadwriteSplittingRulesStatement statement, final
ReadwriteSplittingRuleConfiguration ruleConfig) {
+ return new DistSQLQueryExecuteEngine(statement, "foo_db",
mockContextManager(ruleConfig), mock(DistSQLConnectionContext.class));
+ }
+
+ private ContextManager mockContextManager(final
ReadwriteSplittingRuleConfiguration ruleConfig) {
+ ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+ ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
+ when(result.getDatabase("foo_db")).thenReturn(database);
+ ReadwriteSplittingRule rule = mock(ReadwriteSplittingRule.class);
+ ReadwriteSplittingExportableRuleAttribute ruleAttribute =
mock(ReadwriteSplittingExportableRuleAttribute.class);
+ when(ruleAttribute.getExportData()).thenReturn(createExportedData());
+ when(rule.getConfiguration()).thenReturn(ruleConfig);
+ when(rule.getAttributes()).thenReturn(new
RuleAttributes(ruleAttribute));
+
when(database.getRuleMetaData().findSingleRule(ReadwriteSplittingRule.class)).thenReturn(Optional.of(rule));
+ return result;
+ }
+
private Map<String, Object> createExportedData() {
Map<String, Object> result = new HashMap<>(2, 1F);
result.put(ExportableConstants.EXPORT_DYNAMIC_READWRITE_SPLITTING_RULE,
Collections.emptyMap());
diff --git
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/provider/ShadowRuleConfigurationToDistSQLConverterTest.java
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/provider/ShadowRuleConfigurationToDistSQLConverterTest.java
index 2a5e0a99dbe..35b2e514e39 100644
---
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/provider/ShadowRuleConfigurationToDistSQLConverterTest.java
+++
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/provider/ShadowRuleConfigurationToDistSQLConverterTest.java
@@ -36,21 +36,21 @@ class ShadowRuleConfigurationToDistSQLConverterTest {
@Test
void assertConvertWithoutDataSources() {
- ShadowRuleConfiguration shadowRuleConfiguration =
mock(ShadowRuleConfiguration.class);
-
when(shadowRuleConfiguration.getDataSources()).thenReturn(Collections.emptyList());
+ ShadowRuleConfiguration shadowRuleConfig =
mock(ShadowRuleConfiguration.class);
+
when(shadowRuleConfig.getDataSources()).thenReturn(Collections.emptyList());
ShadowRuleConfigurationToDistSQLConverter
shadowRuleConfigurationToDistSQLConverter = new
ShadowRuleConfigurationToDistSQLConverter();
-
assertThat(shadowRuleConfigurationToDistSQLConverter.convert(shadowRuleConfiguration),
is(""));
+
assertThat(shadowRuleConfigurationToDistSQLConverter.convert(shadowRuleConfig),
is(""));
}
@Test
void assertConvert() {
- ShadowRuleConfiguration shadowRuleConfiguration = new
ShadowRuleConfiguration();
- shadowRuleConfiguration.getDataSources().add(new
ShadowDataSourceConfiguration("shadow_rule", "source", "shadow"));
-
shadowRuleConfiguration.getShadowAlgorithms().put("user_id_select_match_algorithm",
new AlgorithmConfiguration("REGEX_MATCH", new Properties()));
- shadowRuleConfiguration.getTables().put("t_order", new
ShadowTableConfiguration(Collections.singleton("shadow_rule"),
Collections.singleton("user_id_select_match_algorithm")));
- shadowRuleConfiguration.getTables().put("t_order_item", new
ShadowTableConfiguration(Collections.singleton("shadow_rule"),
Collections.singleton("user_id_select_match_algorithm")));
+ ShadowRuleConfiguration shadowRuleConfig = new
ShadowRuleConfiguration();
+ shadowRuleConfig.getDataSources().add(new
ShadowDataSourceConfiguration("shadow_rule", "source", "shadow"));
+
shadowRuleConfig.getShadowAlgorithms().put("user_id_select_match_algorithm",
new AlgorithmConfiguration("REGEX_MATCH", new Properties()));
+ shadowRuleConfig.getTables().put("t_order", new
ShadowTableConfiguration(Collections.singleton("shadow_rule"),
Collections.singleton("user_id_select_match_algorithm")));
+ shadowRuleConfig.getTables().put("t_order_item", new
ShadowTableConfiguration(Collections.singleton("shadow_rule"),
Collections.singleton("user_id_select_match_algorithm")));
ShadowRuleConfigurationToDistSQLConverter
shadowRuleConfigurationToDistSQLConverter = new
ShadowRuleConfigurationToDistSQLConverter();
-
assertThat(shadowRuleConfigurationToDistSQLConverter.convert(shadowRuleConfiguration),
+
assertThat(shadowRuleConfigurationToDistSQLConverter.convert(shadowRuleConfig),
is("CREATE SHADOW RULE shadow_rule(" + System.lineSeparator()
+ "SOURCE=source," + System.lineSeparator() + "SHADOW=shadow," +
System.lineSeparator()
+ "t_order(TYPE(NAME='regex_match'))," +
System.lineSeparator() + "t_order_item(TYPE(NAME='regex_match'))" +
System.lineSeparator() + ");"));
}
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/provider/ShardingRuleConfigurationToDistSQLConverterTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/provider/ShardingRuleConfigurationToDistSQLConverterTest.java
index 23e9d007f99..f0fabc9c78a 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/provider/ShardingRuleConfigurationToDistSQLConverterTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/provider/ShardingRuleConfigurationToDistSQLConverterTest.java
@@ -40,25 +40,25 @@ class ShardingRuleConfigurationToDistSQLConverterTest {
@Test
void assertConvertWithEmptyTables() {
- ShardingRuleConfiguration shardingRuleConfiguration =
mock(ShardingRuleConfiguration.class);
-
when(shardingRuleConfiguration.getTables()).thenReturn(Collections.emptyList());
-
when(shardingRuleConfiguration.getAutoTables()).thenReturn(Collections.emptyList());
+ ShardingRuleConfiguration shardingRuleConfig =
mock(ShardingRuleConfiguration.class);
+
when(shardingRuleConfig.getTables()).thenReturn(Collections.emptyList());
+
when(shardingRuleConfig.getAutoTables()).thenReturn(Collections.emptyList());
ShardingRuleConfigurationToDistSQLConverter
shardingRuleConfigurationToDistSQLConverter = new
ShardingRuleConfigurationToDistSQLConverter();
-
assertThat(shardingRuleConfigurationToDistSQLConverter.convert(shardingRuleConfiguration),
is(""));
+
assertThat(shardingRuleConfigurationToDistSQLConverter.convert(shardingRuleConfig),
is(""));
}
@Test
void assertConvert() {
- ShardingRuleConfiguration shardingRuleConfiguration = new
ShardingRuleConfiguration();
-
shardingRuleConfiguration.getTables().add(createShardingTableRuleConfiguration());
- shardingRuleConfiguration.setDefaultDatabaseShardingStrategy(new
StandardShardingStrategyConfiguration("user_id", "database_inline"));
- shardingRuleConfiguration.setDefaultTableShardingStrategy(new
NoneShardingStrategyConfiguration());
-
shardingRuleConfiguration.getShardingAlgorithms().put("database_inline",
createShardingInlineAlgorithmConfiguration("ds_${user_id % 2}"));
-
shardingRuleConfiguration.getShardingAlgorithms().put("t_order_inline",
createShardingInlineAlgorithmConfiguration("t_order_${order_id % 2}"));
- shardingRuleConfiguration.getKeyGenerators().put("snowflake",
createKeyGeneratorConfiguration());
-
shardingRuleConfiguration.getAuditors().put("sharding_key_required_auditor",
createAuditorConfiguration());
+ ShardingRuleConfiguration shardingRuleConfig = new
ShardingRuleConfiguration();
+
shardingRuleConfig.getTables().add(createShardingTableRuleConfiguration());
+ shardingRuleConfig.setDefaultDatabaseShardingStrategy(new
StandardShardingStrategyConfiguration("user_id", "database_inline"));
+ shardingRuleConfig.setDefaultTableShardingStrategy(new
NoneShardingStrategyConfiguration());
+ shardingRuleConfig.getShardingAlgorithms().put("database_inline",
createShardingInlineAlgorithmConfiguration("ds_${user_id % 2}"));
+ shardingRuleConfig.getShardingAlgorithms().put("t_order_inline",
createShardingInlineAlgorithmConfiguration("t_order_${order_id % 2}"));
+ shardingRuleConfig.getKeyGenerators().put("snowflake",
createKeyGeneratorConfiguration());
+ shardingRuleConfig.getAuditors().put("sharding_key_required_auditor",
createAuditorConfiguration());
ShardingRuleConfigurationToDistSQLConverter
shardingRuleConfigurationToDistSQLConverter = new
ShardingRuleConfigurationToDistSQLConverter();
-
assertThat(shardingRuleConfigurationToDistSQLConverter.convert(shardingRuleConfiguration),
+
assertThat(shardingRuleConfigurationToDistSQLConverter.convert(shardingRuleConfig),
is("CREATE SHARDING TABLE RULE t_order (" +
System.lineSeparator() + "DATANODES('ds_${0..1}.t_order_${0..1}')," +
System.lineSeparator()
+ "TABLE_STRATEGY(TYPE='standard',
SHARDING_COLUMN=order_id, SHARDING_ALGORITHM(TYPE(NAME='inline',
PROPERTIES('algorithm-expression'='t_order_${order_id % 2}')))),"
+ System.lineSeparator() +
"KEY_GENERATE_STRATEGY(COLUMN=order_id, TYPE(NAME='snowflake'))," +
System.lineSeparator()
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowDefaultShardingStrategyExecutorTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowDefaultShardingStrategyExecutorTest.java
index 5dd7ccfb2b1..45576d6b576 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowDefaultShardingStrategyExecutorTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowDefaultShardingStrategyExecutorTest.java
@@ -49,16 +49,16 @@ class ShowDefaultShardingStrategyExecutorTest {
private DistSQLQueryExecuteEngine engine;
- DistSQLQueryExecuteEngine setUp(final ShardingRuleConfiguration
configuration) {
- return new
DistSQLQueryExecuteEngine(mock(ShowDefaultShardingStrategyStatement.class),
"foo_db", mockContextManager(configuration),
mock(DistSQLConnectionContext.class));
+ DistSQLQueryExecuteEngine setUp(final ShardingRuleConfiguration
ruleConfig) {
+ return new
DistSQLQueryExecuteEngine(mock(ShowDefaultShardingStrategyStatement.class),
"foo_db", mockContextManager(ruleConfig), mock(DistSQLConnectionContext.class));
}
- private ContextManager mockContextManager(final ShardingRuleConfiguration
configuration) {
+ private ContextManager mockContextManager(final ShardingRuleConfiguration
ruleConfig) {
ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(result.getDatabase("foo_db")).thenReturn(database);
ShardingRule rule = mock(ShardingRule.class);
- when(rule.getConfiguration()).thenReturn(configuration);
+ when(rule.getConfiguration()).thenReturn(ruleConfig);
when(database.getRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
return result;
}
diff --git
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/ColumnSegmentBinder.java
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/ColumnSegmentBinder.java
index cd53b7b8587..6d4d9407ace 100644
---
a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/ColumnSegmentBinder.java
+++
b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/ColumnSegmentBinder.java
@@ -151,11 +151,11 @@ public final class ColumnSegmentBinder {
}
if (!isFindInputColumn) {
result = findInputColumnSegmentByVariables(segment,
statementBinderContext.getVariableNames()).orElse(null);
- isFindInputColumn = result != null;
+ isFindInputColumn = null != result;
}
if (!isFindInputColumn) {
result = findInputColumnSegmentByPivotColumns(segment,
statementBinderContext.getPivotColumnNames()).orElse(null);
- isFindInputColumn = result != null;
+ isFindInputColumn = null != result;
}
ShardingSpherePreconditions.checkState(isFindInputColumn ||
containsFunctionTable(tableBinderContexts, outerTableBinderContexts.values()),
() -> new ColumnNotFoundException(segment.getExpression(),
SEGMENT_TYPE_MESSAGES.getOrDefault(parentSegmentType,
UNKNOWN_SEGMENT_TYPE_MESSAGE)));
diff --git
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/SubquerySegmentBinderTest.java
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/SubquerySegmentBinderTest.java
index cd63255f0f1..e2347e83e59 100644
---
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/SubquerySegmentBinderTest.java
+++
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/SubquerySegmentBinderTest.java
@@ -62,15 +62,15 @@ class SubquerySegmentBinderTest {
@Test
void assertBind() {
- MySQLSelectStatement mySQLSelectStatement = new MySQLSelectStatement();
+ MySQLSelectStatement mysqlSelectStatement = new MySQLSelectStatement();
ColumnSegment columnSegment = new ColumnSegment(58, 65, new
IdentifierValue("order_id"));
ProjectionsSegment projectionsSegment = new ProjectionsSegment(58, 65);
projectionsSegment.getProjections().add(new
ColumnProjectionSegment(columnSegment));
- mySQLSelectStatement.setProjections(projectionsSegment);
- mySQLSelectStatement.setFrom(new SimpleTableSegment(new
TableNameSegment(72, 78, new IdentifierValue("t_order"))));
+ mysqlSelectStatement.setProjections(projectionsSegment);
+ mysqlSelectStatement.setFrom(new SimpleTableSegment(new
TableNameSegment(72, 78, new IdentifierValue("t_order"))));
ExpressionSegment whereExpressionSegment = new ColumnSegment(86, 91,
new IdentifierValue("status"));
- mySQLSelectStatement.setWhere(new WhereSegment(80, 102,
whereExpressionSegment));
- SubquerySegment subquerySegment = new SubquerySegment(39, 103,
mySQLSelectStatement, "order_id = (SELECT order_id FROM t_order WHERE status =
'SUBMIT')");
+ mysqlSelectStatement.setWhere(new WhereSegment(80, 102,
whereExpressionSegment));
+ SubquerySegment subquerySegment = new SubquerySegment(39, 103,
mysqlSelectStatement, "order_id = (SELECT order_id FROM t_order WHERE status =
'SUBMIT')");
SQLStatementBinderContext sqlStatementBinderContext =
new SQLStatementBinderContext(createMetaData(),
DefaultDatabase.LOGIC_NAME, TypedSPILoader.getService(DatabaseType.class,
"FIXTURE"), Collections.emptySet());
ColumnSegment boundedNameColumn = new ColumnSegment(7, 13, new
IdentifierValue("user_id"));
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/caseinsensitive/CaseInsensitiveIdentifier.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/caseinsensitive/CaseInsensitiveIdentifier.java
index 0624301e821..5149ec6a6ac 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/caseinsensitive/CaseInsensitiveIdentifier.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/caseinsensitive/CaseInsensitiveIdentifier.java
@@ -35,6 +35,6 @@ public final class CaseInsensitiveIdentifier {
@Override
public String toString() {
- return null != original ? original.toString() : null;
+ return null == original ? null : original.toString();
}
}
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java
index 2f806be4870..5724cbe8c12 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java
@@ -50,15 +50,15 @@ public final class StorageUnit {
private final ConnectionProperties connectionProperties;
- public StorageUnit(final StorageNode storageNode, final
DataSourcePoolProperties dataSourcePoolProperties, final DataSource dataSource)
{
+ public StorageUnit(final StorageNode storageNode, final
DataSourcePoolProperties dataSourcePoolProps, final DataSource dataSource) {
this.storageNode = storageNode;
- Map<String, Object> standardProps =
dataSourcePoolProperties.getConnectionPropertySynonyms().getStandardProperties();
+ Map<String, Object> standardProps =
dataSourcePoolProps.getConnectionPropertySynonyms().getStandardProperties();
String url = standardProps.get("url").toString();
storageType = DatabaseTypeFactory.get(url);
boolean isInstanceConnectionAvailable = new
DatabaseTypeRegistry(DatabaseTypeFactory.get(url)).getDialectDatabaseMetaData().isInstanceConnectionAvailable();
catalog = isInstanceConnectionAvailable ? new
StandardJdbcUrlParser().parse(url).getDatabase() : null;
this.dataSource = new CatalogSwitchableDataSource(dataSource, catalog,
url);
- this.dataSourcePoolProperties = dataSourcePoolProperties;
+ this.dataSourcePoolProperties = dataSourcePoolProps;
connectionProperties = createConnectionProperties(standardProps);
}
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManager.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManager.java
index 2020706bd31..21995c62ea7 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManager.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManager.java
@@ -100,7 +100,7 @@ public final class SystemSchemaManager {
public static boolean isSystemTable(final String databaseType, final
String schema, final Collection<String> tableNames) {
Collection<String> databaseTypeTables =
Optional.ofNullable(DATABASE_TYPE_SCHEMA_TABLE_MAP.get(databaseType)).map(schemas
-> schemas.get(schema)).orElse(Collections.emptyList());
Collection<String> commonTables =
Optional.ofNullable(DATABASE_TYPE_SCHEMA_TABLE_MAP.get(COMMON)).map(schemas ->
schemas.get(schema)).orElse(Collections.emptyList());
- for (final String each : tableNames) {
+ for (String each : tableNames) {
if (!databaseTypeTables.contains(each) &&
!commonTables.contains(each)) {
return false;
}
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
index 30ebcad91a7..355f669774a 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
@@ -96,10 +96,10 @@ class ShardingSphereDatabaseMetaDataTest {
when(metaDataContexts.getMetaData().getDatabase(shardingSphereConnection.getDatabaseName())).thenReturn(database);
ShardingRule shardingRule = mockShardingRule();
when(database.getRuleMetaData().getRules()).thenReturn(Collections.singleton(shardingRule));
- ConnectionProperties connectionProperties =
mock(ConnectionProperties.class);
- when(connectionProperties.getCatalog()).thenReturn("test");
- when(connectionProperties.getSchema()).thenReturn("test");
-
when(database.getResourceMetaData().getStorageUnits().get(DATA_SOURCE_NAME).getConnectionProperties()).thenReturn(connectionProperties);
+ ConnectionProperties connectionProps =
mock(ConnectionProperties.class);
+ when(connectionProps.getCatalog()).thenReturn("test");
+ when(connectionProps.getSchema()).thenReturn("test");
+
when(database.getResourceMetaData().getStorageUnits().get(DATA_SOURCE_NAME).getConnectionProperties()).thenReturn(connectionProps);
shardingSphereDatabaseMetaData = new
ShardingSphereDatabaseMetaData(shardingSphereConnection);
}
diff --git
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
index 19ac57b04db..9ea0b0809b0 100644
---
a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
+++
b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java
@@ -359,9 +359,9 @@ public final class MySQLClient {
}
private void reconnect() throws ExecutionException,
InterruptedException, TimeoutException {
- Optional<ChannelFuture> futureOptional = closeChannel();
- if (futureOptional.isPresent()) {
- futureOptional.get().get(1, TimeUnit.SECONDS);
+ Optional<ChannelFuture> future = closeChannel();
+ if (future.isPresent()) {
+ future.get().get(1, TimeUnit.SECONDS);
}
if (reconnectTimes.incrementAndGet() > 3) {
log.warn("Exceeds the maximum number of retry times, last
binlog event:{}", lastBinlogEvent);
diff --git
a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/provider/SingleRuleConfigurationToDistSQLConverterTest.java
b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/provider/SingleRuleConfigurationToDistSQLConverterTest.java
index 7ae04edc5be..6888fdbb216 100644
---
a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/provider/SingleRuleConfigurationToDistSQLConverterTest.java
+++
b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/provider/SingleRuleConfigurationToDistSQLConverterTest.java
@@ -34,19 +34,19 @@ class SingleRuleConfigurationToDistSQLConverterTest {
@Test
void assertConvert() {
- SingleRuleConfiguration singleRuleConfiguration = new
SingleRuleConfiguration(new LinkedList<>(Arrays.asList("t_0", "t_1")),
"foo_ds");
+ SingleRuleConfiguration singleRuleConfig = new
SingleRuleConfiguration(new LinkedList<>(Arrays.asList("t_0", "t_1")),
"foo_ds");
SingleRuleConfigurationToDistSQLConverter
singleRuleConfigurationToDistSQLConverter = new
SingleRuleConfigurationToDistSQLConverter();
-
assertThat(singleRuleConfigurationToDistSQLConverter.convert(singleRuleConfiguration),
+
assertThat(singleRuleConfigurationToDistSQLConverter.convert(singleRuleConfig),
is("LOAD SINGLE TABLE t_0,t_1;" + System.lineSeparator() +
System.lineSeparator() + "SET DEFAULT SINGLE TABLE STORAGE UNIT = foo_ds;"));
}
@Test
void assertConvertWithoutDefaultDatasourceAndTables() {
- SingleRuleConfiguration singleRuleConfiguration =
mock(SingleRuleConfiguration.class);
-
when(singleRuleConfiguration.getDefaultDataSource()).thenReturn(Optional.empty());
-
when(singleRuleConfiguration.getTables()).thenReturn(Collections.emptyList());
+ SingleRuleConfiguration singleRuleConfig =
mock(SingleRuleConfiguration.class);
+
when(singleRuleConfig.getDefaultDataSource()).thenReturn(Optional.empty());
+ when(singleRuleConfig.getTables()).thenReturn(Collections.emptyList());
SingleRuleConfigurationToDistSQLConverter
singleRuleConfigurationToDistSQLConverter = new
SingleRuleConfigurationToDistSQLConverter();
-
assertThat(singleRuleConfigurationToDistSQLConverter.convert(singleRuleConfiguration),
is(""));
+
assertThat(singleRuleConfigurationToDistSQLConverter.convert(singleRuleConfig),
is(""));
}
@Test
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManager.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManager.java
index e2fdc5f2e11..3d132595738 100644
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManager.java
+++
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManager.java
@@ -89,7 +89,7 @@ public final class XAShardingSphereTransactionManager
implements ShardingSphereT
@SneakyThrows(SystemException.class)
@Override
public boolean isInTransaction() {
- return xaTransactionManagerProvider != null &&
Status.STATUS_NO_TRANSACTION !=
xaTransactionManagerProvider.getTransactionManager().getStatus();
+ return null != xaTransactionManagerProvider &&
Status.STATUS_NO_TRANSACTION !=
xaTransactionManagerProvider.getTransactionManager().getStatus();
}
@Override
diff --git
a/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/type/MySQLDMLStatementVisitor.java
b/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/type/MySQLDMLStatementVisitor.java
index 0ba7f25cab8..b32aac425a7 100644
---
a/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/type/MySQLDMLStatementVisitor.java
+++
b/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/type/MySQLDMLStatementVisitor.java
@@ -158,7 +158,7 @@ public final class MySQLDMLStatementVisitor extends
MySQLStatementVisitor implem
if (null != ctx.frameClause()) {
result.setFrameClause(new
CommonExpressionSegment(ctx.frameClause().start.getStartIndex(),
ctx.frameClause().stop.getStopIndex(), ctx.frameClause().getText()));
}
- if (ctx.identifier() != null) {
+ if (null != ctx.identifier()) {
result.setWindowName(new
IdentifierValue(ctx.identifier().getText()));
}
return result;
diff --git
a/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
b/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
index 2d0cb8e226b..9b1cc6670ea 100644
---
a/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
+++
b/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
@@ -617,7 +617,7 @@ public final class PostgreSQLDDLStatementVisitor extends
PostgreSQLStatementVisi
@SuppressWarnings("unchecked")
@Override
public ASTNode visitDropTable(final DropTableContext ctx) {
- boolean containsCascade = ctx.dropTableOpt() != null && null !=
ctx.dropTableOpt().CASCADE();
+ boolean containsCascade = null != ctx.dropTableOpt() && null !=
ctx.dropTableOpt().CASCADE();
PostgreSQLDropTableStatement result = new
PostgreSQLDropTableStatement(null != ctx.ifExists(), containsCascade);
result.getTables().addAll(((CollectionValue<SimpleTableSegment>)
visit(ctx.tableNames())).getValue());
return result;
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
index 878e4cd6126..6b124a232b8 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/PostgreSQLToMySQLMigrationE2EIT.java
@@ -60,14 +60,14 @@ class PostgreSQLToMySQLMigrationE2EIT extends
AbstractMigrationE2EIT {
@EnabledIf("isEnabled")
@ArgumentsSource(PipelineE2ETestCaseArgumentsProvider.class)
void assertMySQLToPostgreSQLMigrationSuccess(final PipelineTestParameter
testParam) throws SQLException {
- PostgreSQLContainer<?> postgreSQLContainer = null;
+ PostgreSQLContainer<?> postgresqlContainer = null;
try (PipelineContainerComposer containerComposer = new
PipelineContainerComposer(testParam, new MigrationJobType())) {
if (PipelineEnvTypeEnum.DOCKER ==
PipelineE2EEnvironment.getInstance().getItEnvType()) {
- postgreSQLContainer = new PostgreSQLContainer<>("postgres:13");
-
postgreSQLContainer.withNetwork(containerComposer.getContainerComposer().getContainers().getNetwork()).withNetworkAliases("postgresql.host")
+ postgresqlContainer = new PostgreSQLContainer<>("postgres:13");
+
postgresqlContainer.withNetwork(containerComposer.getContainerComposer().getContainers().getNetwork()).withNetworkAliases("postgresql.host")
.withDatabaseName("postgres").withUsername("postgres").withPassword("postgres").withCommand("-c
wal_level=logical").start();
}
- String jdbcUrl =
PipelineE2EEnvironment.getInstance().getItEnvType() ==
PipelineEnvTypeEnum.DOCKER ? postgreSQLContainer.getJdbcUrl() :
"jdbc:postgresql://localhost:5432/postgres";
+ String jdbcUrl =
PipelineE2EEnvironment.getInstance().getItEnvType() ==
PipelineEnvTypeEnum.DOCKER ? postgresqlContainer.getJdbcUrl() :
"jdbc:postgresql://localhost:5432/postgres";
initSourceTable(jdbcUrl);
registerMigrationSourceStorageUnit(containerComposer);
containerComposer.registerStorageUnit(PipelineContainerComposer.DS_0);
@@ -88,8 +88,8 @@ class PostgreSQLToMySQLMigrationE2EIT extends
AbstractMigrationE2EIT {
List<String> lastJobIds = listJobId(containerComposer);
assertTrue(lastJobIds.isEmpty());
} finally {
- if (null != postgreSQLContainer) {
- postgreSQLContainer.close();
+ if (null != postgresqlContainer) {
+ postgresqlContainer.close();
}
}
}