diff --git a/docs/document/content/dev-manual/sharding.cn.md b/docs/document/content/dev-manual/sharding.cn.md index 2b47cf528a208..4c6e9f61997bd 100644 --- a/docs/document/content/dev-manual/sharding.cn.md +++ b/docs/document/content/dev-manual/sharding.cn.md @@ -34,7 +34,7 @@ chapter = true ### 全限定类名 -[`org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/sharding/api/src/main/java/org/apache/shardingsphere/sharding/spi/KeyGenerateAlgorithm.java) +[`org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/algorithm/KeyGenerateAlgorithm.java) ### 定义 @@ -44,8 +44,8 @@ chapter = true | *配置标识* | *详细说明* | *全限定类名* | |-----------------|-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| SNOWFLAKE | 基于雪花算法的分布式主键生成算法 | [`org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java) | -| UUID | 基于 UUID 的分布式主键生成算法 | [`org.apache.shardingsphere.sharding.algorithm.keygen.UUIDKeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithm.java) | +| SNOWFLAKE | 基于雪花算法的分布式主键生成算法 | [`org.apache.shardingsphere.keygen.snowflake.algorithm.SnowflakeKeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/algorithm/SnowflakeKeyGenerateAlgorithm.java) | +| UUID | 基于 UUID 的分布式主键生成算法 | [`org.apache.shardingsphere.keygen.uuid.algorithm.UUIDKeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/infra/algorithm/key-generator/type/uuid/src/main/java/org/apache/shardingsphere/keygen/uuid/algorithm/UUIDKeyGenerateAlgorithm.java) | ## ShardingAuditAlgorithm diff --git a/docs/document/content/dev-manual/sharding.en.md b/docs/document/content/dev-manual/sharding.en.md index 2ecb672dab2cc..9452548ecba36 100644 --- a/docs/document/content/dev-manual/sharding.en.md +++ b/docs/document/content/dev-manual/sharding.en.md @@ -34,7 +34,7 @@ Sharding Algorithm definition ### Fully-qualified class name -[`org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/sharding/api/src/main/java/org/apache/shardingsphere/sharding/spi/KeyGenerateAlgorithm.java) +[`org.apache.shardingsphere.keygen.core.algorithm.KeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/infra/algorithm/key-generator/core/src/main/java/org/apache/shardingsphere/keygen/core/algorithm/KeyGenerateAlgorithm.java) ### Definition @@ -44,8 +44,8 @@ Distributed Key Generating Algorithm definition | *Configuration Type* | *Description* | *Fully-qualified class name* | |----------------------|----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| SNOWFLAKE | Snowflake key generate algorithm | [`org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java) | -| UUID | UUID key generate algorithm | [`org.apache.shardingsphere.sharding.algorithm.keygen.UUIDKeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/UUIDKeyGenerateAlgorithm.java) | +| SNOWFLAKE | Snowflake key generate algorithm | [`org.apache.shardingsphere.keygen.snowflake.algorithm.SnowflakeKeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/infra/algorithm/key-generator/type/snowflake/src/main/java/org/apache/shardingsphere/keygen/snowflake/algorithm/SnowflakeKeyGenerateAlgorithm.java) | +| UUID | UUID key generate algorithm | [`org.apache.shardingsphere.keygen.uuid.algorithm.UUIDKeyGenerateAlgorithm`](https://github.com/apache/shardingsphere/blob/master/infra/algorithm/key-generator/type/uuid/src/main/java/org/apache/shardingsphere/keygen/uuid/algorithm/UUIDKeyGenerateAlgorithm.java) | ## ShardingAuditAlgorithm diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java index fb356f00517b8..ed49c35ef0790 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java @@ -22,8 +22,8 @@ import org.apache.shardingsphere.infra.util.json.JsonUtils; import java.util.LinkedHashMap; -import java.util.Map; import java.util.Properties; +import java.util.stream.Collectors; /** * Properties converter. @@ -38,11 +38,8 @@ public final class PropertiesConverter { * @return converted string content */ public static String convert(final Properties props) { - if (null == props) { - return ""; - } - Map sortedProps = new LinkedHashMap<>(); - props.keySet().stream().map(Object::toString).sorted().forEach(each -> sortedProps.put(each, props.get(each))); - return sortedProps.isEmpty() ? "" : JsonUtils.toJsonString(sortedProps); + return null == props || props.isEmpty() ? "" + : JsonUtils.toJsonString(props.keySet().stream().map(Object::toString).sorted() + .collect(Collectors.toMap(each -> each, props::get, (oldValue, currentValue) -> oldValue, LinkedHashMap::new))); } } diff --git a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java index e3e093d777cbd..d07019cefc6e3 100644 --- a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java +++ b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumper.java @@ -179,7 +179,7 @@ private List handleUpdateRowsEvent(final UpdateRowsEvent event, fina for (int j = 0; j < beforeValues.length; j++) { Serializable oldValue = beforeValues[j]; Serializable newValue = afterValues[j]; - boolean updated = !Objects.equals(newValue, oldValue); + boolean updated = !Objects.deepEquals(newValue, oldValue); PipelineColumnMetaData columnMetaData = tableMetaData.getColumnMetaData(j + 1); dataRecord.addColumn(new Column(columnMetaData.getName(), handleValue(columnMetaData, oldValue), diff --git a/kernel/sql-translator/distsql/handler/pom.xml b/kernel/sql-translator/distsql/handler/pom.xml index ccc63eb8510bb..2b8eb9362615d 100644 --- a/kernel/sql-translator/distsql/handler/pom.xml +++ b/kernel/sql-translator/distsql/handler/pom.xml @@ -47,5 +47,12 @@ shardingsphere-sql-translator-distsql-parser ${project.version} + + + org.apache.shardingsphere + shardingsphere-test-util + ${project.version} + test + diff --git a/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/ShowSQLTranslatorRuleExecutor.java b/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java similarity index 82% rename from kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/ShowSQLTranslatorRuleExecutor.java rename to kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java index d42a473e9b4fb..7b1fbac8d25d3 100644 --- a/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/ShowSQLTranslatorRuleExecutor.java +++ b/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutor.java @@ -15,13 +15,14 @@ * limitations under the License. */ -package org.apache.shardingsphere.sqltranslator.distsql.handler; +package org.apache.shardingsphere.sqltranslator.distsql.handler.query; import org.apache.shardingsphere.distsql.handler.ral.query.MetaDataRequiredQueryableRALExecutor; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData; +import org.apache.shardingsphere.infra.props.PropertiesConverter; import org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration; -import org.apache.shardingsphere.sqltranslator.distsql.statement.ShowSQLTranslatorRuleStatement; +import org.apache.shardingsphere.sqltranslator.distsql.statement.queryable.ShowSQLTranslatorRuleStatement; import org.apache.shardingsphere.sqltranslator.rule.SQLTranslatorRule; import java.util.Arrays; @@ -40,12 +41,13 @@ public Collection getRows(final ShardingSphereMetaData } private Collection buildData(final SQLTranslatorRuleConfiguration ruleConfig) { - return Collections.singleton(new LocalDataQueryResultRow(null != ruleConfig.getType() ? ruleConfig.getType() : "", String.valueOf(ruleConfig.isUseOriginalSQLWhenTranslatingFailed()))); + return Collections.singleton(new LocalDataQueryResultRow(null == ruleConfig.getType() ? "" : ruleConfig.getType(), + PropertiesConverter.convert(ruleConfig.getProps()), String.valueOf(ruleConfig.isUseOriginalSQLWhenTranslatingFailed()))); } @Override public Collection getColumnNames() { - return Arrays.asList("type", "use_original_sql_when_translating_failed"); + return Arrays.asList("type", "props", "use_original_sql_when_translating_failed"); } @Override diff --git a/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/update/AlterSQLTranslatorRuleStatementUpdater.java b/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/update/AlterSQLTranslatorRuleStatementUpdater.java new file mode 100644 index 0000000000000..d7ecee7eae90b --- /dev/null +++ b/kernel/sql-translator/distsql/handler/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/handler/update/AlterSQLTranslatorRuleStatementUpdater.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sqltranslator.distsql.handler.update; + +import org.apache.shardingsphere.distsql.handler.ral.update.GlobalRuleRALUpdater; +import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; +import org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration; +import org.apache.shardingsphere.sqltranslator.distsql.statement.updateable.AlterSQLTranslatorRuleStatement; +import org.apache.shardingsphere.sqltranslator.spi.SQLTranslator; + +/** + * Alter SQL translator rule statement handler. + */ +public final class AlterSQLTranslatorRuleStatementUpdater implements GlobalRuleRALUpdater { + + @Override + public void checkSQLStatement(final SQLTranslatorRuleConfiguration currentRuleConfig, final AlterSQLTranslatorRuleStatement sqlStatement) { + checkProvider(sqlStatement); + } + + private void checkProvider(final AlterSQLTranslatorRuleStatement sqlStatement) { + TypedSPILoader.checkService(SQLTranslator.class, sqlStatement.getType(), sqlStatement.getProps()); + } + + @Override + public SQLTranslatorRuleConfiguration buildAlteredRuleConfiguration(final SQLTranslatorRuleConfiguration currentRuleConfig, final AlterSQLTranslatorRuleStatement sqlStatement) { + return new SQLTranslatorRuleConfiguration(sqlStatement.getType(), sqlStatement.getProps(), + null == sqlStatement.getUseOriginalSQLWhenTranslatingFailed() ? currentRuleConfig.isUseOriginalSQLWhenTranslatingFailed() : sqlStatement.getUseOriginalSQLWhenTranslatingFailed()); + } + + @Override + public Class getRuleConfigurationClass() { + return SQLTranslatorRuleConfiguration.class; + } + + @Override + public Class getType() { + return AlterSQLTranslatorRuleStatement.class; + } +} diff --git a/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor b/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor index f4756663dd8b6..2e75a975ebb6b 100644 --- a/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor +++ b/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor @@ -15,4 +15,4 @@ # limitations under the License. # -org.apache.shardingsphere.sqltranslator.distsql.handler.ShowSQLTranslatorRuleExecutor +org.apache.shardingsphere.sqltranslator.distsql.handler.query.ShowSQLTranslatorRuleExecutor diff --git a/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.update.GlobalRuleRALUpdater b/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.update.GlobalRuleRALUpdater new file mode 100644 index 0000000000000..ef36ed5349ebb --- /dev/null +++ b/kernel/sql-translator/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.update.GlobalRuleRALUpdater @@ -0,0 +1,18 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +org.apache.shardingsphere.sqltranslator.distsql.handler.update.AlterSQLTranslatorRuleStatementUpdater diff --git a/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/ShowSQLTranslatorRuleExecutorTest.java b/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java similarity index 91% rename from kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/ShowSQLTranslatorRuleExecutorTest.java rename to kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java index fc28b45cd29f6..f37354b1bab4a 100644 --- a/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/ShowSQLTranslatorRuleExecutorTest.java +++ b/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.sqltranslator.distsql.handler; +package org.apache.shardingsphere.sqltranslator.distsql.handler.query; import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow; @@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; import org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration; -import org.apache.shardingsphere.sqltranslator.distsql.statement.ShowSQLTranslatorRuleStatement; +import org.apache.shardingsphere.sqltranslator.distsql.statement.queryable.ShowSQLTranslatorRuleStatement; import org.apache.shardingsphere.sqltranslator.rule.SQLTranslatorRule; import org.junit.jupiter.api.Test; @@ -49,16 +49,18 @@ void assertExecute() { Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); assertThat(row.getCell(1), is("NATIVE")); - assertThat(row.getCell(2), is("true")); + assertThat(row.getCell(2), is("")); + assertThat(row.getCell(3), is("true")); } @Test void assertGetColumnNames() { ShowSQLTranslatorRuleExecutor executor = new ShowSQLTranslatorRuleExecutor(); Collection columns = executor.getColumnNames(); - assertThat(columns.size(), is(2)); + assertThat(columns.size(), is(3)); Iterator iterator = columns.iterator(); assertThat(iterator.next(), is("type")); + assertThat(iterator.next(), is("props")); assertThat(iterator.next(), is("use_original_sql_when_translating_failed")); } diff --git a/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/update/AlterSQLTranslatorRuleStatementUpdaterTest.java b/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/update/AlterSQLTranslatorRuleStatementUpdaterTest.java new file mode 100644 index 0000000000000..ad32bb58bf4bd --- /dev/null +++ b/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/update/AlterSQLTranslatorRuleStatementUpdaterTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sqltranslator.distsql.handler.update; + +import org.apache.shardingsphere.infra.props.PropertiesConverter; +import org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration; +import org.apache.shardingsphere.sqltranslator.distsql.statement.updateable.AlterSQLTranslatorRuleStatement; +import org.apache.shardingsphere.test.util.PropertiesBuilder; +import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; +import org.junit.jupiter.api.Test; + +import java.util.Properties; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class AlterSQLTranslatorRuleStatementUpdaterTest { + + @Test + void assertExecute() { + AlterSQLTranslatorRuleStatementUpdater updater = new AlterSQLTranslatorRuleStatementUpdater(); + SQLTranslatorRuleConfiguration actual = updater.buildAlteredRuleConfiguration(createSQLTranslatorRuleConfiguration(), new AlterSQLTranslatorRuleStatement("JOOQ", + PropertiesBuilder.build(new Property("foo", "bar")), null)); + assertThat(actual.getType(), is("JOOQ")); + assertFalse(actual.getProps().isEmpty()); + String props = PropertiesConverter.convert(actual.getProps()); + assertThat(props, is("{\"foo\":\"bar\"}")); + assertTrue(actual.isUseOriginalSQLWhenTranslatingFailed()); + } + + private SQLTranslatorRuleConfiguration createSQLTranslatorRuleConfiguration() { + return new SQLTranslatorRuleConfiguration("NATIVE", new Properties(), true); + } +} diff --git a/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/BaseRule.g4 b/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/BaseRule.g4 new file mode 100644 index 0000000000000..bbc13c59b47fa --- /dev/null +++ b/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/BaseRule.g4 @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +grammar BaseRule; + +import Symbol, Keyword, Literals; + +propertiesDefinition + : PROPERTIES LP_ properties? RP_ + ; + +properties + : property (COMMA_ property)* + ; + +property + : key=STRING_ EQ_ value=literal + ; + +literal + : STRING_ | (MINUS_)? INT_ | TRUE | FALSE + ; diff --git a/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/Keyword.g4 b/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/Keyword.g4 index 088bfbdbe1f0a..8b1e92bf129b3 100644 --- a/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/Keyword.g4 +++ b/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/Keyword.g4 @@ -34,3 +34,39 @@ RULE SQL_TRANSLATOR : S Q L UL_ T R A N S L A T O R ; + +USE_ORIGINAL_SQL_WHEN_TRANSLATING_FAILED + : U S E UL_ O R I G I N A L UL_ S Q L UL_ W H E N UL_ T R A N S L A T I N G UL_ F A I L E D + ; + +ALTER + : A L T E R + ; + +TYPE + : T Y P E + ; + +JOOQ + : J O O Q + ; + +NATIVE + : N A T I V E + ; + +NAME + : N A M E + ; + +PROPERTIES + : P R O P E R T I E S + ; + +TRUE + : T R U E + ; + +FALSE + : F A L S E + ; diff --git a/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/Literals.g4 b/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/Literals.g4 new file mode 100644 index 0000000000000..68f6a1b07ed2e --- /dev/null +++ b/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/Literals.g4 @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +lexer grammar Literals; + +import Alphabet, Symbol; + +IDENTIFIER_ + : [A-Za-z_$0-9]*?[A-Za-z_$]+?[A-Za-z_$0-9]* + | BQ_ ~'`'+ BQ_ + ; + +STRING_ + : (DQ_ ('\\'. | '""' | ~('"' | '\\'))* DQ_) + | (SQ_ ('\\'. | '\'\'' | ~('\'' | '\\'))* SQ_) + ; + +INT_ + : [0-9]+ + ; diff --git a/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/RALStatement.g4 b/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/RALStatement.g4 index 98ca33b2abe7b..b99b2af908c81 100644 --- a/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/RALStatement.g4 +++ b/kernel/sql-translator/distsql/parser/src/main/antlr4/imports/sqltranslator/RALStatement.g4 @@ -17,8 +17,32 @@ grammar RALStatement; -import Keyword; +import BaseRule; showSQLTranslatorRule : SHOW SQL_TRANSLATOR RULE ; + +alterSQLTranslatorRule + : ALTER SQL_TRANSLATOR RULE LP_ sqlTranslatorRuleDefinition RP_ + ; + +sqlTranslatorRuleDefinition + : TYPE LP_ NAME EQ_ providerName (COMMA_ propertiesDefinition)? RP_ (COMMA_ useOriginalSQLDefinition)? + ; + +useOriginalSQLDefinition + : USE_ORIGINAL_SQL_WHEN_TRANSLATING_FAILED EQ_ useOriginalSQL + ; + +providerName + : STRING_ | buildInProviderTypeName + ; + +buildInProviderTypeName + : JOOQ | NATIVE + ; + +useOriginalSQL + : TRUE | FALSE + ; diff --git a/kernel/sql-translator/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/SQLTranslatorDistSQLStatement.g4 b/kernel/sql-translator/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/SQLTranslatorDistSQLStatement.g4 index dff20ae98bde4..aa3bbbd841351 100644 --- a/kernel/sql-translator/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/SQLTranslatorDistSQLStatement.g4 +++ b/kernel/sql-translator/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/SQLTranslatorDistSQLStatement.g4 @@ -20,5 +20,7 @@ grammar SQLTranslatorDistSQLStatement; import Symbol, RALStatement; execute - : (showSQLTranslatorRule) SEMI_? EOF + : (showSQLTranslatorRule + | alterSQLTranslatorRule + ) SEMI_? EOF ; diff --git a/kernel/sql-translator/distsql/parser/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/parser/core/SQLTranslatorDistSQLStatementVisitor.java b/kernel/sql-translator/distsql/parser/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/parser/core/SQLTranslatorDistSQLStatementVisitor.java index 37037fd4f5f14..9117042f7eb5f 100644 --- a/kernel/sql-translator/distsql/parser/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/parser/core/SQLTranslatorDistSQLStatementVisitor.java +++ b/kernel/sql-translator/distsql/parser/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/parser/core/SQLTranslatorDistSQLStatementVisitor.java @@ -17,11 +17,19 @@ package org.apache.shardingsphere.sqltranslator.distsql.parser.core; +import org.antlr.v4.runtime.tree.ParseTree; import org.apache.shardingsphere.distsql.parser.autogen.SQLTranslatorDistSQLStatementBaseVisitor; +import org.apache.shardingsphere.distsql.parser.autogen.SQLTranslatorDistSQLStatementParser.AlterSQLTranslatorRuleContext; +import org.apache.shardingsphere.distsql.parser.autogen.SQLTranslatorDistSQLStatementParser.PropertiesDefinitionContext; +import org.apache.shardingsphere.distsql.parser.autogen.SQLTranslatorDistSQLStatementParser.PropertyContext; import org.apache.shardingsphere.distsql.parser.autogen.SQLTranslatorDistSQLStatementParser.ShowSQLTranslatorRuleContext; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor; -import org.apache.shardingsphere.sqltranslator.distsql.statement.ShowSQLTranslatorRuleStatement; +import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue; +import org.apache.shardingsphere.sqltranslator.distsql.statement.queryable.ShowSQLTranslatorRuleStatement; +import org.apache.shardingsphere.sqltranslator.distsql.statement.updateable.AlterSQLTranslatorRuleStatement; + +import java.util.Properties; /** * SQL statement visitor for SQL translator DistSQL. @@ -32,4 +40,26 @@ public final class SQLTranslatorDistSQLStatementVisitor extends SQLTranslatorDis public ASTNode visitShowSQLTranslatorRule(final ShowSQLTranslatorRuleContext ctx) { return new ShowSQLTranslatorRuleStatement(); } + + @Override + public ASTNode visitAlterSQLTranslatorRule(final AlterSQLTranslatorRuleContext ctx) { + return new AlterSQLTranslatorRuleStatement(getIdentifierValue(ctx.sqlTranslatorRuleDefinition().providerName()), getProperties(ctx.sqlTranslatorRuleDefinition().propertiesDefinition()), + null == ctx.sqlTranslatorRuleDefinition().useOriginalSQLDefinition() ? null + : Boolean.valueOf(getIdentifierValue(ctx.sqlTranslatorRuleDefinition().useOriginalSQLDefinition().useOriginalSQL()))); + } + + private Properties getProperties(final PropertiesDefinitionContext ctx) { + Properties result = new Properties(); + if (null == ctx || null == ctx.properties()) { + return result; + } + for (PropertyContext each : ctx.properties().property()) { + result.setProperty(IdentifierValue.getQuotedContent(each.key.getText()), IdentifierValue.getQuotedContent(each.value.getText())); + } + return result; + } + + private String getIdentifierValue(final ParseTree context) { + return null == context ? null : new IdentifierValue(context.getText()).getValue(); + } } diff --git a/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/ShowSQLTranslatorRuleStatement.java b/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/queryable/ShowSQLTranslatorRuleStatement.java similarity index 98% rename from kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/ShowSQLTranslatorRuleStatement.java rename to kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/queryable/ShowSQLTranslatorRuleStatement.java index 583e666791554..81b611a67a851 100644 --- a/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/ShowSQLTranslatorRuleStatement.java +++ b/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/queryable/ShowSQLTranslatorRuleStatement.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.sqltranslator.distsql.statement; +package org.apache.shardingsphere.sqltranslator.distsql.statement.queryable; import org.apache.shardingsphere.distsql.statement.ral.QueryableRALStatement; diff --git a/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/updateable/AlterSQLTranslatorRuleStatement.java b/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/updateable/AlterSQLTranslatorRuleStatement.java new file mode 100644 index 0000000000000..f404cde243e19 --- /dev/null +++ b/kernel/sql-translator/distsql/statement/src/main/java/org/apache/shardingsphere/sqltranslator/distsql/statement/updateable/AlterSQLTranslatorRuleStatement.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sqltranslator.distsql.statement.updateable; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.apache.shardingsphere.distsql.statement.ral.UpdatableGlobalRuleRALStatement; + +import java.util.Properties; + +/** + * Alter SQL translator rule statement. + */ +@RequiredArgsConstructor +@Getter +public final class AlterSQLTranslatorRuleStatement extends UpdatableGlobalRuleRALStatement { + + private final String type; + + private final Properties props; + + private final Boolean useOriginalSQLWhenTranslatingFailed; +} diff --git a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 index a0620e1440193..02cad8304b278 100644 --- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 +++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 @@ -17,7 +17,7 @@ grammar DDLStatement; -import BaseRule, DCLStatement, DMLStatement; +import DMLStatement, DCLStatement; createView : CREATE (OR REPLACE)? (NO? FORCE)? (EDITIONING | EDITIONABLE EDITIONING? | NONEDITIONABLE)? VIEW viewName diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/composer/BatchE2EContainerComposer.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/composer/BatchE2EContainerComposer.java index d11bc084292e3..df6e7922d19e7 100644 --- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/composer/BatchE2EContainerComposer.java +++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/composer/BatchE2EContainerComposer.java @@ -63,7 +63,9 @@ public final class BatchE2EContainerComposer extends E2EContainerComposer implem private final DataSetEnvironmentManager dataSetEnvironmentManager; - private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + private final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"); public BatchE2EContainerComposer(final CaseTestParameter testParam) throws JAXBException, IOException { super(testParam); @@ -159,8 +161,10 @@ private void assertRows(final ResultSet actual, final List expectedD for (String expected : expectedDatSetRows.get(count).splitValues(", ")) { if (Types.DATE == actual.getMetaData().getColumnType(columnIndex)) { if (!E2EContainerComposer.NOT_VERIFY_FLAG.equals(expected)) { - assertThat(dateTimeFormatter.format(actual.getDate(columnIndex).toLocalDate()), is(expected)); + assertThat(dateFormatter.format(actual.getDate(columnIndex).toLocalDate()), is(expected)); } + } else if (Types.TIMESTAMP == actual.getMetaData().getColumnType(columnIndex)) { + assertThat(actual.getTimestamp(columnIndex).toLocalDateTime().format(dateTimeFormatter), is(expected)); } else if (Types.CHAR == actual.getMetaData().getColumnType(columnIndex) && ("PostgreSQL".equals(databaseType.getType()) || "openGauss".equals(databaseType.getType()))) { assertThat(String.valueOf(actual.getObject(columnIndex)).trim(), is(expected)); diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dql/BaseDQLE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dql/BaseDQLE2EIT.java index fd673015fb067..0a8bc2a843bfb 100644 --- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dql/BaseDQLE2EIT.java +++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dql/BaseDQLE2EIT.java @@ -36,7 +36,9 @@ import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Timestamp; +import java.sql.Types; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; @@ -57,6 +59,8 @@ public abstract class BaseDQLE2EIT { private boolean useXMLAsExpectedDataset; + private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + /** * Init. * @@ -196,6 +200,12 @@ private void assertRow(final ResultSet actualResultSet, final ResultSetMetaData } else if (actualValue instanceof Timestamp && expectedValue instanceof LocalDateTime) { // TODO Since mysql 8.0.23, for the DATETIME type, the mysql driver returns the LocalDateTime type, but the proxy returns the Timestamp type. assertThat(((Timestamp) actualValue).toLocalDateTime(), is(expectedValue)); + } else if (Types.TIMESTAMP == actualMetaData.getColumnType(i + 1) || Types.TIMESTAMP == expectedMetaData.getColumnType(i + 1)) { + Object convertedActualValue = + Types.TIMESTAMP == actualMetaData.getColumnType(i + 1) ? actualResultSet.getTimestamp(i + 1).toLocalDateTime().format(dateTimeFormatter) : actualValue; + Object convertedExpectedValue = + Types.TIMESTAMP == expectedMetaData.getColumnType(i + 1) ? expectedResultSet.getTimestamp(i + 1).toLocalDateTime().format(dateTimeFormatter) : actualValue; + assertThat(String.valueOf(convertedActualValue), is(String.valueOf(convertedExpectedValue))); } else { assertThat(String.valueOf(actualValue), is(String.valueOf(expectedValue))); } diff --git a/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema-mysql.xml b/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema-mysql.xml index a13ae6831e291..025a8539e3543 100644 --- a/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema-mysql.xml +++ b/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema-mysql.xml @@ -205,9 +205,10 @@ - + + diff --git a/test/e2e/sql/src/test/resources/env/scenario/encrypt_shadow/proxy/conf/mysql/config-encrypt-shadow.yaml b/test/e2e/sql/src/test/resources/env/scenario/encrypt_shadow/proxy/conf/mysql/config-encrypt-shadow.yaml index 3d6804693bc6c..1709fb1f10ffa 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/encrypt_shadow/proxy/conf/mysql/config-encrypt-shadow.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/encrypt_shadow/proxy/conf/mysql/config-encrypt-shadow.yaml @@ -19,7 +19,7 @@ databaseName: encrypt_shadow dataSources: db: - url: jdbc:mysql://mysql.encrypt_shadow.host:3306/db?useSSL=false&characterEncoding=utf-8 + url: jdbc:mysql://mysql.encrypt_shadow.host:3306/db?useSSL=false&characterEncoding=utf-8&tinyInt1isBit=true username: test_user password: Test@123 connectionTimeoutMilliseconds: 30000 @@ -28,7 +28,7 @@ dataSources: maxPoolSize: 2 minPoolSize: 2 encrypt_shadow_db: - url: jdbc:mysql://mysql.encrypt_shadow.host:3306/encrypt_shadow_db?useSSL=false&characterEncoding=utf-8 + url: jdbc:mysql://mysql.encrypt_shadow.host:3306/encrypt_shadow_db?useSSL=false&characterEncoding=utf-8&tinyInt1isBit=true username: test_user password: Test@123 connectionTimeoutMilliseconds: 30000 diff --git a/test/e2e/sql/src/test/resources/env/scenario/readwrite_splitting_and_shadow/proxy/conf/mysql/config-shadow.yaml b/test/e2e/sql/src/test/resources/env/scenario/readwrite_splitting_and_shadow/proxy/conf/mysql/config-shadow.yaml index 5542391d940a2..d083a8ba86a54 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/readwrite_splitting_and_shadow/proxy/conf/mysql/config-shadow.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/readwrite_splitting_and_shadow/proxy/conf/mysql/config-shadow.yaml @@ -19,7 +19,7 @@ databaseName: readwrite_splitting_and_shadow dataSources: write_db: - url: jdbc:mysql://mysql.readwrite_splitting_and_shadow.host:3306/write_db?useSSL=false&characterEncoding=utf-8 + url: jdbc:mysql://mysql.readwrite_splitting_and_shadow.host:3306/write_db?useSSL=false&characterEncoding=utf-8&tinyInt1isBit=true username: test_user password: Test@123 connectionTimeoutMilliseconds: 30000 @@ -28,7 +28,7 @@ dataSources: maxPoolSize: 2 minPoolSize: 2 write_db_shadow: - url: jdbc:mysql://mysql.readwrite_splitting_and_shadow.host:3306/write_db_shadow?useSSL=false&characterEncoding=utf-8 + url: jdbc:mysql://mysql.readwrite_splitting_and_shadow.host:3306/write_db_shadow?useSSL=false&characterEncoding=utf-8&tinyInt1isBit=true username: test_user password: Test@123 connectionTimeoutMilliseconds: 30000 @@ -37,7 +37,7 @@ dataSources: maxPoolSize: 2 minPoolSize: 2 read_0: - url: jdbc:mysql://mysql.readwrite_splitting_and_shadow.host:3306/read_0?useSSL=false&characterEncoding=utf-8 + url: jdbc:mysql://mysql.readwrite_splitting_and_shadow.host:3306/read_0?useSSL=false&characterEncoding=utf-8&tinyInt1isBit=true username: test_user password: Test@123 connectionTimeoutMilliseconds: 30000 @@ -46,7 +46,7 @@ dataSources: maxPoolSize: 2 minPoolSize: 2 read_1: - url: jdbc:mysql://mysql.readwrite_splitting_and_shadow.host:3306/read_1?useSSL=false&characterEncoding=utf-8 + url: jdbc:mysql://mysql.readwrite_splitting_and_shadow.host:3306/read_1?useSSL=false&characterEncoding=utf-8&tinyInt1isBit=true username: test_user password: Test@123 connectionTimeoutMilliseconds: 30000 diff --git a/test/e2e/sql/src/test/resources/env/scenario/shadow/proxy/conf/mysql/config-shadow.yaml b/test/e2e/sql/src/test/resources/env/scenario/shadow/proxy/conf/mysql/config-shadow.yaml index 799a48594eef9..ed6f273bca5d0 100644 --- a/test/e2e/sql/src/test/resources/env/scenario/shadow/proxy/conf/mysql/config-shadow.yaml +++ b/test/e2e/sql/src/test/resources/env/scenario/shadow/proxy/conf/mysql/config-shadow.yaml @@ -19,7 +19,7 @@ databaseName: shadow dataSources: db: - url: jdbc:mysql://mysql.shadow.host:3306/db?useSSL=false&characterEncoding=utf-8 + url: jdbc:mysql://mysql.shadow.host:3306/db?useSSL=false&characterEncoding=utf-8&tinyInt1isBit=true username: test_user password: Test@123 connectionTimeoutMilliseconds: 30000 @@ -28,7 +28,7 @@ dataSources: maxPoolSize: 2 minPoolSize: 2 shadow_db: - url: jdbc:mysql://mysql.shadow.host:3306/shadow_db?useSSL=false&characterEncoding=utf-8 + url: jdbc:mysql://mysql.shadow.host:3306/shadow_db?useSSL=false&characterEncoding=utf-8&tinyInt1isBit=true username: test_user password: Test@123 connectionTimeoutMilliseconds: 30000 diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java index d149c6dae724b..fff02ac1ec1a6 100644 --- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java +++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java @@ -33,7 +33,7 @@ import org.apache.shardingsphere.distsql.statement.ral.queryable.ShowTableMetaDataStatement; import org.apache.shardingsphere.parser.distsql.statement.queryable.ShowSQLParserRuleStatement; import org.apache.shardingsphere.readwritesplitting.distsql.statement.ShowStatusFromReadwriteSplittingRulesStatement; -import org.apache.shardingsphere.sqltranslator.distsql.statement.ShowSQLTranslatorRuleStatement; +import org.apache.shardingsphere.sqltranslator.distsql.statement.queryable.ShowSQLTranslatorRuleStatement; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert; import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ConvertYamlConfigurationStatementAssert; diff --git a/test/it/parser/src/main/resources/case/ddl/create-materialized-view.xml b/test/it/parser/src/main/resources/case/ddl/create-materialized-view.xml index c2868a5e02fcf..756b307a38c14 100644 --- a/test/it/parser/src/main/resources/case/ddl/create-materialized-view.xml +++ b/test/it/parser/src/main/resources/case/ddl/create-materialized-view.xml @@ -34,4 +34,5 @@ + diff --git a/test/it/parser/src/main/resources/case/ddl/create-view.xml b/test/it/parser/src/main/resources/case/ddl/create-view.xml index dd05e5686e3c2..6d28e86d42539 100644 --- a/test/it/parser/src/main/resources/case/ddl/create-view.xml +++ b/test/it/parser/src/main/resources/case/ddl/create-view.xml @@ -727,6 +727,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/it/parser/src/main/resources/sql/supported/ddl/create-materialized-view.xml b/test/it/parser/src/main/resources/sql/supported/ddl/create-materialized-view.xml index bef27cdbd8116..f54d4e5136149 100644 --- a/test/it/parser/src/main/resources/sql/supported/ddl/create-materialized-view.xml +++ b/test/it/parser/src/main/resources/sql/supported/ddl/create-materialized-view.xml @@ -131,4 +131,5 @@ SELECT p.prod_name, SUM(s.amount_sold) AS dollar_sales FROM sales s, products p WHERE s.prod_id = p.prod_id GROUP BY p.prod_name;" db-types="Oracle" /> + diff --git a/test/it/parser/src/main/resources/sql/supported/ddl/create-view.xml b/test/it/parser/src/main/resources/sql/supported/ddl/create-view.xml index b48261a6313a8..20ec091175512 100644 --- a/test/it/parser/src/main/resources/sql/supported/ddl/create-view.xml +++ b/test/it/parser/src/main/resources/sql/supported/ddl/create-view.xml @@ -40,6 +40,7 @@ + @@ -56,4 +57,42 @@ + + + + + + + +