You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/12/03 05:09:01 UTC

[shardingsphere] branch master updated: Move SQLNodeConverterEngineIT from test module to optimized module (#22613)

This is an automated email from the ASF dual-hosted git repository.

panjuan 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 fc426b7360b Move SQLNodeConverterEngineIT from test module to optimized module (#22613)
fc426b7360b is described below

commit fc426b7360ba605590570db78cc0dd017bea2326
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Dec 3 13:08:46 2022 +0800

    Move SQLNodeConverterEngineIT from test module to optimized module (#22613)
---
 kernel/sql-federation/optimizer/pom.xml            | 27 +++++++-
 .../optimizer/parser/rexnode/ParseRexNode.g4       |  2 +-
 .../optimizer/it/SQLNodeConverterEngineIT.java     | 31 ++++-----
 test/optimize/pom.xml                              | 76 ----------------------
 test/optimize/src/test/resources/logback-test.xml  | 33 ----------
 test/parser/pom.xml                                | 42 ++++++------
 test/pom.xml                                       |  1 -
 7 files changed, 60 insertions(+), 152 deletions(-)

diff --git a/kernel/sql-federation/optimizer/pom.xml b/kernel/sql-federation/optimizer/pom.xml
index cd2f9012a36..77519b39ab0 100644
--- a/kernel/sql-federation/optimizer/pom.xml
+++ b/kernel/sql-federation/optimizer/pom.xml
@@ -38,15 +38,17 @@
             <artifactId>shardingsphere-infra-binder</artifactId>
             <version>${project.version}</version>
         </dependency>
-        
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
             <artifactId>shardingsphere-parser-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+        
         <dependency>
-            <groupId>org.apache.calcite</groupId>
-            <artifactId>calcite-core</artifactId>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-parser-test</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
@@ -84,6 +86,12 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.calcite</groupId>
+            <artifactId>calcite-core</artifactId>
+        </dependency>
+        
         <dependency>
             <groupId>javax.xml.bind</groupId>
             <artifactId>jaxb-api</artifactId>
@@ -105,6 +113,7 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
+    
     <build>
         <plugins>
             <plugin>
@@ -124,6 +133,18 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>integration-tests</id>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>
diff --git a/kernel/sql-federation/optimizer/src/main/antlr4/org/apache/shardingsphere/sqlfederation/optimizer/parser/rexnode/ParseRexNode.g4 b/kernel/sql-federation/optimizer/src/main/antlr4/org/apache/shardingsphere/sqlfederation/optimizer/parser/rexnode/ParseRexNode.g4
index f3d06eba3d8..adb06dc8a64 100644
--- a/kernel/sql-federation/optimizer/src/main/antlr4/org/apache/shardingsphere/sqlfederation/optimizer/parser/rexnode/ParseRexNode.g4
+++ b/kernel/sql-federation/optimizer/src/main/antlr4/org/apache/shardingsphere/sqlfederation/optimizer/parser/rexnode/ParseRexNode.g4
@@ -17,7 +17,7 @@
 
 grammar ParseRexNode;
 
-import Symbol,Keyword,Literals;
+import Symbol, Keyword, Literals;
 
 expression
     : op LP_ parameter COMMA_ parameter RP_
diff --git a/test/optimize/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConverterEngineParameterizedTest.java b/kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/SQLNodeConverterEngineIT.java
similarity index 91%
rename from test/optimize/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConverterEngineParameterizedTest.java
rename to kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/SQLNodeConverterEngineIT.java
index 9aa9110eda3..2632e2f4a1a 100644
--- a/test/optimize/src/test/java/org/apache/shardingsphere/infra/federation/converter/parameterized/engine/SQLNodeConverterEngineParameterizedTest.java
+++ b/kernel/sql-federation/optimizer/src/test/java/org/apache/shardingsphere/sqlfederation/optimizer/it/SQLNodeConverterEngineIT.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.infra.federation.converter.parameterized.engine;
+package org.apache.shardingsphere.sqlfederation.optimizer.it;
 
 import lombok.SneakyThrows;
 import org.apache.calcite.avatica.util.Casing;
@@ -28,7 +28,6 @@ import org.apache.calcite.sql.parser.SqlParser;
 import org.apache.calcite.sql.parser.SqlParser.Config;
 import org.apache.calcite.sql.parser.impl.SqlParserImpl;
 import org.apache.calcite.util.Litmus;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
 import org.apache.shardingsphere.sql.parser.api.CacheOption;
 import org.apache.shardingsphere.sql.parser.api.SQLParserEngine;
@@ -58,7 +57,7 @@ import java.util.stream.Collectors;
 import static org.junit.Assert.assertTrue;
 
 @RunWith(Parameterized.class)
-public final class SQLNodeConverterEngineParameterizedTest {
+public final class SQLNodeConverterEngineIT {
     
     private static final SQLCases SQL_CASES = SQLCasesRegistry.getInstance().getCases();
     
@@ -156,7 +155,7 @@ public final class SQLNodeConverterEngineParameterizedTest {
     
     private final SQLCaseType sqlCaseType;
     
-    public SQLNodeConverterEngineParameterizedTest(final InternalSQLParserParameterizedArray parameterizedArray) {
+    public SQLNodeConverterEngineIT(final InternalSQLParserParameterizedArray parameterizedArray) {
         sqlCaseId = parameterizedArray.getSqlCaseId();
         databaseType = parameterizedArray.getDatabaseType();
         sqlCaseType = parameterizedArray.getSqlCaseType();
@@ -189,32 +188,30 @@ public final class SQLNodeConverterEngineParameterizedTest {
     public void assertConvert() {
         String databaseType = "H2".equals(this.databaseType) ? "MySQL" : this.databaseType;
         String sql = SQL_CASES.getSQL(sqlCaseId, sqlCaseType, SQL_PARSER_TEST_CASES.get(sqlCaseId).getParameters());
-        SQLStatement sqlStatement = parseSQLStatement(databaseType, sql);
-        SqlNode actual = SQLNodeConverterEngine.convert(sqlStatement);
-        SqlNode expected = parseSqlNode(databaseType, sql);
+        SqlNode actual = SQLNodeConverterEngine.convert(parseSQLStatement(databaseType, sql));
+        SqlNode expected = parseSQLNode(databaseType, sql);
         assertTrue(actual.equalsDeep(expected, Litmus.THROW));
     }
     
+    private SQLStatement parseSQLStatement(final String databaseType, final String sql) {
+        return new SQLVisitorEngine(databaseType, "STATEMENT", true, new Properties()).visit(new SQLParserEngine(databaseType, new CacheOption(128, 1024L)).parse(sql, false));
+    }
+    
     @SneakyThrows(SqlParseException.class)
-    private SqlNode parseSqlNode(final String databaseType, final String sql) {
-        return SqlParser.create(sql, createConfig(DatabaseTypeFactory.getInstance(databaseType))).parseQuery();
+    private SqlNode parseSQLNode(final String databaseType, final String sql) {
+        return SqlParser.create(sql, createConfiguration(databaseType)).parseQuery();
     }
     
-    private Config createConfig(final DatabaseType databaseType) {
+    private Config createConfiguration(final String databaseType) {
         CalciteConnectionConfig connectionConfig = new CalciteConnectionConfigImpl(createSQLDialectProperties(databaseType));
         return SqlParser.config().withLex(connectionConfig.lex()).withUnquotedCasing(Casing.UNCHANGED)
                 .withIdentifierMaxLength(SqlParser.DEFAULT_IDENTIFIER_MAX_LENGTH).withConformance(connectionConfig.conformance()).withParserFactory(SqlParserImpl.FACTORY);
     }
     
-    private Properties createSQLDialectProperties(final DatabaseType databaseType) {
+    private Properties createSQLDialectProperties(final String databaseType) {
         Properties result = new Properties();
         result.setProperty(CalciteConnectionProperty.TIME_ZONE.camelName(), "UTC");
-        result.putAll(OptimizerSQLDialectBuilderFactory.build(databaseType));
+        result.putAll(OptimizerSQLDialectBuilderFactory.build(DatabaseTypeFactory.getInstance(databaseType)));
         return result;
     }
-    
-    private SQLStatement parseSQLStatement(final String databaseType, final String sql) {
-        CacheOption cacheOption = new CacheOption(128, 1024L);
-        return new SQLVisitorEngine(databaseType, "STATEMENT", true, new Properties()).visit(new SQLParserEngine(databaseType, cacheOption).parse(sql, false));
-    }
 }
diff --git a/test/optimize/pom.xml b/test/optimize/pom.xml
deleted file mode 100644
index dc244a6321b..00000000000
--- a/test/optimize/pom.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.shardingsphere</groupId>
-        <artifactId>shardingsphere-test</artifactId>
-        <version>5.2.2-SNAPSHOT</version>
-    </parent>
-    <artifactId>shardingsphere-optimize-test</artifactId>
-    <name>${project.artifactId}</name>
-    
-    <properties>
-        <maven.deploy.skip>true</maven.deploy.skip>
-    </properties>
-    
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-sql-federation-optimizer</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-parser-test</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-sql-parser-sql92</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-sql-parser-mysql</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-sql-parser-postgresql</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-sql-parser-oracle</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-sql-parser-sqlserver</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-sql-parser-opengauss</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-    </dependencies>
-</project>
diff --git a/test/optimize/src/test/resources/logback-test.xml b/test/optimize/src/test/resources/logback-test.xml
deleted file mode 100644
index d90fc4a7156..00000000000
--- a/test/optimize/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0"?>
-<!--
-  ~ 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.
-  -->
-
-<configuration>
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n</pattern>
-        </encoder>
-    </appender>
-    <logger name="org.apache.shardingsphere" level="warn" additivity="false">
-        <appender-ref ref="console" />
-    </logger>
-    
-    <root>
-        <level value="error" />
-        <appender-ref ref="console" />
-    </root>
-</configuration> 
diff --git a/test/parser/pom.xml b/test/parser/pom.xml
index 03f3c292d57..7ec80a3e4cc 100644
--- a/test/parser/pom.xml
+++ b/test/parser/pom.xml
@@ -35,27 +35,6 @@
     </properties>
     
     <dependencies>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.junit.vintage</groupId>
-            <artifactId>junit-vintage-engine</artifactId>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.jayway.jsonpath</groupId>
-            <artifactId>json-path</artifactId>
-            <version>${json-path.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-csv</artifactId>
-            <version>${commons-csv.version}</version>
-        </dependency>
-        
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
             <artifactId>shardingsphere-sql-parser-engine</artifactId>
@@ -136,6 +115,27 @@
             <artifactId>shardingsphere-shadow-distsql-parser</artifactId>
             <version>${project.version}</version>
         </dependency>
+        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.jayway.jsonpath</groupId>
+            <artifactId>json-path</artifactId>
+            <version>${json-path.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-csv</artifactId>
+            <version>${commons-csv.version}</version>
+        </dependency>
     </dependencies>
     
     <build>
diff --git a/test/pom.xml b/test/pom.xml
index 3c8084c83de..d7d05bfbf65 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -35,7 +35,6 @@
         <module>integration-agent-test</module>
         <module>rewrite</module>
         <module>parser</module>
-        <module>optimize</module>
         <module>pipeline</module>
     </modules>