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 3288510 OracleParserStatementExample issue #11193 (#11225)
3288510 is described below
commit 32885101d6c1ef07ca85f3557e7dbfccab8ad031
Author: liguoping <[email protected]>
AuthorDate: Thu Jul 8 20:20:30 2021 +0800
OracleParserStatementExample issue #11193 (#11225)
---
examples/shardingsphere-parser-example/pom.xml | 5 +++++
.../mysql/format/MySQLParserFormatExample.java | 2 +-
.../statement/MySQLParserStatementExample.java | 6 ++---
.../statement/OracleParserStatementExample.java} | 26 ++++++++++------------
4 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/examples/shardingsphere-parser-example/pom.xml
b/examples/shardingsphere-parser-example/pom.xml
index cdc7da3..a2547c7 100644
--- a/examples/shardingsphere-parser-example/pom.xml
+++ b/examples/shardingsphere-parser-example/pom.xml
@@ -39,5 +39,10 @@
<artifactId>shardingsphere-sql-parser-mysql</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-sql-parser-oracle</artifactId>
+ <version>5.0.0-RC1-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
diff --git
a/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/format/MySQLParserFormatExample.java
b/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/format/MySQLParserFormatExample.java
index 44adc1a..389107c 100644
---
a/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/format/MySQLParserFormatExample.java
+++
b/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/format/MySQLParserFormatExample.java
@@ -25,7 +25,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Properties;
-public class MySQLParserFormatExample {
+public final class MySQLParserFormatExample {
private static final String DML_SELECT_SQL = "SELECT age AS b, name AS n
FROM table1 JOIN table2 WHERE id = 1 AND name = 'lu';";
diff --git
a/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/statement/MySQLParserStatementExample.java
b/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/statement/MySQLParserStatementExample.java
index 7ed6dba..186094e 100644
---
a/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/statement/MySQLParserStatementExample.java
+++
b/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/statement/MySQLParserStatementExample.java
@@ -26,7 +26,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Properties;
-public class MySQLParserStatementExample {
+public final class MySQLParserStatementExample {
private static final String DML_SELECT_SQL = "SELECT t.id, t.name, t.age
FROM table1 AS t ORDER BY t.id DESC;";
@@ -36,7 +36,7 @@ public class MySQLParserStatementExample {
private static final String DML_DELETE_SQL = "DELETE FROM table1 AS t1
WHERE id = 1;";
- private static final String DDL_CREAT_SQL = "CREATE TABLE table2 (id
BIGINT(20) PRIMARY KEY, name VARCHAR(20), age INT(2))";
+ private static final String DDL_CREATE_SQL = "CREATE TABLE table2 (id
BIGINT(20) PRIMARY KEY, name VARCHAR(20), age INT(2))";
private static final String DDL_DROP_SQL = "DROP TABLE table1, table2;";
@@ -48,7 +48,7 @@ public class MySQLParserStatementExample {
static {
MYSQL_PARSER_STATEMENT_LIST = Arrays.asList(DML_SELECT_SQL,
DML_INSERT_SQL, DML_UPDATE_SQL, DML_DELETE_SQL,
- DDL_CREAT_SQL, DDL_DROP_SQL, DDL_ALTER_SQL, DDL_SHOW_SQL);
+ DDL_CREATE_SQL, DDL_DROP_SQL, DDL_ALTER_SQL, DDL_SHOW_SQL);
}
public static void main(String[] args) {
diff --git
a/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/statement/MySQLParserStatementExample.java
b/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/oracle/statement/OracleParserStatementExample.java
similarity index 72%
copy from
examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/statement/MySQLParserStatementExample.java
copy to
examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/oracle/statement/OracleParserStatementExample.java
index 7ed6dba..c0880d0 100644
---
a/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/mysql/statement/MySQLParserStatementExample.java
+++
b/examples/shardingsphere-parser-example/src/main/java/org/apache/shardingsphere/example/parser/oracle/statement/OracleParserStatementExample.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.example.parser.mysql.statement;
+package org.apache.shardingsphere.example.parser.oracle.statement;
import org.antlr.v4.runtime.tree.ParseTree;
import org.apache.shardingsphere.sql.parser.api.SQLParserEngine;
import org.apache.shardingsphere.sql.parser.api.SQLVisitorEngine;
-import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.OracleStatement;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
-public class MySQLParserStatementExample {
+public final class OracleParserStatementExample {
private static final String DML_SELECT_SQL = "SELECT t.id, t.name, t.age
FROM table1 AS t ORDER BY t.id DESC;";
@@ -36,27 +36,25 @@ public class MySQLParserStatementExample {
private static final String DML_DELETE_SQL = "DELETE FROM table1 AS t1
WHERE id = 1;";
- private static final String DDL_CREAT_SQL = "CREATE TABLE table2 (id
BIGINT(20) PRIMARY KEY, name VARCHAR(20), age INT(2))";
+ private static final String DDL_CREATE_SQL = "CREATE TABLE table2 (id
BIGINT(20) PRIMARY KEY, name VARCHAR(20), age INT(2))";
private static final String DDL_DROP_SQL = "DROP TABLE table1, table2;";
private static final String DDL_ALTER_SQL = "ALTER TABLE table1 DROP age;";
-
- private static final String DDL_SHOW_SQL = "SHOW COLUMNS FROM table1;";
-
- private static List<String> MYSQL_PARSER_STATEMENT_LIST;
+
+ private static final List<String> ORACLE_PARSER_STATEMENT_LIST;
static {
- MYSQL_PARSER_STATEMENT_LIST = Arrays.asList(DML_SELECT_SQL,
DML_INSERT_SQL, DML_UPDATE_SQL, DML_DELETE_SQL,
- DDL_CREAT_SQL, DDL_DROP_SQL, DDL_ALTER_SQL, DDL_SHOW_SQL);
+ ORACLE_PARSER_STATEMENT_LIST = Arrays.asList(DML_SELECT_SQL,
DML_INSERT_SQL, DML_UPDATE_SQL, DML_DELETE_SQL,
+ DDL_CREATE_SQL, DDL_DROP_SQL, DDL_ALTER_SQL);
}
public static void main(String[] args) {
- MYSQL_PARSER_STATEMENT_LIST.stream().forEach(sql -> {
- SQLParserEngine parserEngine = new SQLParserEngine("MySQL");
+ ORACLE_PARSER_STATEMENT_LIST.forEach(sql -> {
+ SQLParserEngine parserEngine = new SQLParserEngine("Oracle");
ParseTree tree = parserEngine.parse(sql, false);
- SQLVisitorEngine visitorEngine = new SQLVisitorEngine("MySQL",
"STATEMENT", new Properties());
- MySQLStatement sqlStatement = visitorEngine.visit(tree);
+ SQLVisitorEngine visitorEngine = new SQLVisitorEngine("Oracle",
"STATEMENT", new Properties());
+ OracleStatement sqlStatement = visitorEngine.visit(tree);
System.out.println(sqlStatement.toString());
});
}