未验证 提交 b0389897 编写于 作者: L Liang Zhang 提交者: GitHub

Add shardingsphere-infra-parser module (#7963)

上级 1fd45b30
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<module>shardingsphere-transaction</module> <module>shardingsphere-transaction</module>
<module>shardingsphere-governance</module> <module>shardingsphere-governance</module>
<module>shardingsphere-observability</module> <module>shardingsphere-observability</module>
<module>shardingsphere-test</module> <module>shardingsphere-test</module>
<module>shardingsphere-integration-test</module> <module>shardingsphere-integration-test</module>
<module>shardingsphere-distribution</module> <module>shardingsphere-distribution</module>
......
...@@ -44,7 +44,7 @@ import org.apache.shardingsphere.infra.schema.ShardingSphereSchema; ...@@ -44,7 +44,7 @@ import org.apache.shardingsphere.infra.schema.ShardingSphereSchema;
import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations; import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine; import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine; import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.sql.parser.statement.standard.StandardSQLStatementParserEngine; import org.apache.shardingsphere.infra.parser.standard.StandardSQLStatementParserEngine;
import org.junit.runners.Parameterized.Parameters; import org.junit.runners.Parameterized.Parameters;
import java.io.File; import java.io.File;
......
...@@ -47,7 +47,7 @@ import org.apache.shardingsphere.infra.schema.ShardingSphereSchema; ...@@ -47,7 +47,7 @@ import org.apache.shardingsphere.infra.schema.ShardingSphereSchema;
import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations; import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine; import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine; import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.sql.parser.statement.standard.StandardSQLStatementParserEngine; import org.apache.shardingsphere.infra.parser.standard.StandardSQLStatementParserEngine;
import org.junit.runners.Parameterized.Parameters; import org.junit.runners.Parameterized.Parameters;
import java.io.File; import java.io.File;
......
...@@ -47,7 +47,7 @@ import org.apache.shardingsphere.infra.schema.ShardingSphereSchema; ...@@ -47,7 +47,7 @@ import org.apache.shardingsphere.infra.schema.ShardingSphereSchema;
import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations; import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine; import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine; import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.sql.parser.statement.standard.StandardSQLStatementParserEngine; import org.apache.shardingsphere.infra.parser.standard.StandardSQLStatementParserEngine;
import org.junit.runners.Parameterized.Parameters; import org.junit.runners.Parameterized.Parameters;
import java.io.File; import java.io.File;
......
...@@ -36,7 +36,7 @@ import org.apache.shardingsphere.infra.route.engine.SQLRouteEngine; ...@@ -36,7 +36,7 @@ import org.apache.shardingsphere.infra.route.engine.SQLRouteEngine;
import org.apache.shardingsphere.infra.schema.ShardingSphereSchema; import org.apache.shardingsphere.infra.schema.ShardingSphereSchema;
import org.apache.shardingsphere.sharding.route.engine.fixture.AbstractRoutingEngineTest; import org.apache.shardingsphere.sharding.route.engine.fixture.AbstractRoutingEngineTest;
import org.apache.shardingsphere.sharding.rule.ShardingRule; import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sql.parser.statement.standard.StandardSQLStatementParserEngine; import org.apache.shardingsphere.infra.parser.standard.StandardSQLStatementParserEngine;
import java.sql.Types; import java.sql.Types;
import java.util.Arrays; import java.util.Arrays;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
<modules> <modules>
<module>shardingsphere-infra-common</module> <module>shardingsphere-infra-common</module>
<module>shardingsphere-infra-parser</module>
<module>shardingsphere-infra-binder</module> <module>shardingsphere-infra-binder</module>
<module>shardingsphere-infra-route</module> <module>shardingsphere-infra-route</module>
<module>shardingsphere-infra-rewrite</module> <module>shardingsphere-infra-rewrite</module>
......
...@@ -32,6 +32,12 @@ ...@@ -32,6 +32,12 @@
<artifactId>shardingsphere-sql-parser-engine</artifactId> <artifactId>shardingsphere-sql-parser-engine</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-parser</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.shardingsphere</groupId> <groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-common</artifactId> <artifactId>shardingsphere-infra-common</artifactId>
......
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-infra-parser</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-sql-parser-engine</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.shardingsphere.sql.parser.statement; package org.apache.shardingsphere.infra.parser;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement; import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
......
...@@ -15,14 +15,14 @@ ...@@ -15,14 +15,14 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.shardingsphere.sql.parser.statement.standard; package org.apache.shardingsphere.infra.parser.standard;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.sql.parser.api.SQLParserEngine; import org.apache.shardingsphere.sql.parser.api.SQLParserEngine;
import org.apache.shardingsphere.sql.parser.cache.SQLParsedResultCache; import org.apache.shardingsphere.sql.parser.cache.SQLParsedResultCache;
import org.apache.shardingsphere.sql.parser.hook.ParsingHookRegistry; import org.apache.shardingsphere.sql.parser.hook.ParsingHookRegistry;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement; import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.statement.SQLStatementParserEngine; import org.apache.shardingsphere.infra.parser.SQLStatementParserEngine;
import java.util.Optional; import java.util.Optional;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.shardingsphere.sql.parser.statement.standard; package org.apache.shardingsphere.infra.parser.standard;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
......
...@@ -36,6 +36,12 @@ ...@@ -36,6 +36,12 @@
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId> <artifactId>antlr4-runtime</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra-parser</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.shardingsphere</groupId> <groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-rdl-parser-sql</artifactId> <artifactId>shardingsphere-rdl-parser-sql</artifactId>
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
package org.apache.shardingsphere.rdl.parser.engine; package org.apache.shardingsphere.rdl.parser.engine;
import org.apache.shardingsphere.infra.parser.SQLStatementParserEngine;
import org.apache.shardingsphere.infra.parser.standard.StandardSQLStatementParserEngine;
import org.apache.shardingsphere.infra.parser.standard.StandardSQLStatementParserEngineFactory;
import org.apache.shardingsphere.rdl.parser.engine.engine.RDLSQLStatementParserEngine; import org.apache.shardingsphere.rdl.parser.engine.engine.RDLSQLStatementParserEngine;
import org.apache.shardingsphere.sql.parser.statement.SQLStatementParserEngine;
import org.apache.shardingsphere.sql.parser.statement.standard.StandardSQLStatementParserEngine;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement; import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.statement.standard.StandardSQLStatementParserEngineFactory;
/** /**
* ShardingSphere SQL statement parser engine. * ShardingSphere SQL statement parser engine.
......
...@@ -19,9 +19,9 @@ package org.apache.shardingsphere.rdl.parser.engine.engine; ...@@ -19,9 +19,9 @@ package org.apache.shardingsphere.rdl.parser.engine.engine;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.ParseTree;
import org.apache.shardingsphere.infra.parser.SQLStatementParserEngine;
import org.apache.shardingsphere.rdl.parser.engine.executor.RDLSQLParserExecutor; import org.apache.shardingsphere.rdl.parser.engine.executor.RDLSQLParserExecutor;
import org.apache.shardingsphere.rdl.parser.sql.visitor.ShardingSphereVisitor; import org.apache.shardingsphere.rdl.parser.sql.visitor.ShardingSphereVisitor;
import org.apache.shardingsphere.sql.parser.statement.SQLStatementParserEngine;
import org.apache.shardingsphere.sql.parser.hook.ParsingHookRegistry; import org.apache.shardingsphere.sql.parser.hook.ParsingHookRegistry;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement; import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
package org.apache.shardingsphere.test.sql.parser.parameterized.engine; package org.apache.shardingsphere.test.sql.parser.parameterized.engine;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.sql.parser.api.SQLParserEngine;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement; import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.statement.standard.StandardSQLStatementParserEngineFactory;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext; import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.SQLStatementAssert; import org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.SQLStatementAssert;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.SQLParserTestCasesRegistry; import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.SQLParserTestCasesRegistry;
...@@ -78,7 +78,7 @@ public abstract class SQLParserParameterizedTest { ...@@ -78,7 +78,7 @@ public abstract class SQLParserParameterizedTest {
SQLParserTestCase expected = SQL_PARSER_TEST_CASES_REGISTRY.get(sqlCaseId); SQLParserTestCase expected = SQL_PARSER_TEST_CASES_REGISTRY.get(sqlCaseId);
String databaseType = "H2".equals(this.databaseType) ? "MySQL" : this.databaseType; String databaseType = "H2".equals(this.databaseType) ? "MySQL" : this.databaseType;
String sql = SQL_CASES_LOADER.getSQL(sqlCaseId, sqlCaseType, SQL_PARSER_TEST_CASES_REGISTRY.get(sqlCaseId).getParameters()); String sql = SQL_CASES_LOADER.getSQL(sqlCaseId, sqlCaseType, SQL_PARSER_TEST_CASES_REGISTRY.get(sqlCaseId).getParameters());
SQLStatement actual = StandardSQLStatementParserEngineFactory.getSQLStatementParserEngine(databaseType).parse(sql, false); SQLStatement actual = SQLParserEngine.parse(databaseType, sql, false, "STATEMENT");
SQLStatementAssert.assertIs(new SQLCaseAssertContext(sqlCaseId, sqlCaseType), actual, expected); SQLStatementAssert.assertIs(new SQLCaseAssertContext(sqlCaseId, sqlCaseType), actual, expected);
} }
} }
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
package org.apache.shardingsphere.test.sql.parser.parameterized.engine; package org.apache.shardingsphere.test.sql.parser.parameterized.engine;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.sql.parser.api.SQLParserEngine;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException; import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
import org.apache.shardingsphere.sql.parser.statement.standard.StandardSQLStatementParserEngineFactory;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.sql.SQLCaseType; import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.sql.SQLCaseType;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.sql.loader.SQLCasesLoader; import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.sql.loader.SQLCasesLoader;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.sql.loader.UnsupportedSQLCasesRegistry; import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.sql.loader.UnsupportedSQLCasesRegistry;
...@@ -47,6 +47,6 @@ public abstract class UnsupportedSQLParserParameterizedTest { ...@@ -47,6 +47,6 @@ public abstract class UnsupportedSQLParserParameterizedTest {
public final void assertUnsupportedSQL() { public final void assertUnsupportedSQL() {
String sql = SQL_CASES_LOADER.getSQL(sqlCaseId, sqlCaseType, Collections.emptyList()); String sql = SQL_CASES_LOADER.getSQL(sqlCaseId, sqlCaseType, Collections.emptyList());
String databaseType = "H2".equals(this.databaseType) ? "MySQL" : this.databaseType; String databaseType = "H2".equals(this.databaseType) ? "MySQL" : this.databaseType;
StandardSQLStatementParserEngineFactory.getSQLStatementParserEngine(databaseType).parse(sql, false); SQLParserEngine.parse(databaseType, sql, false, "STATEMENT");
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册