You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/11/13 08:50:59 UTC
[shardingsphere] branch master updated: Refactor SQLParseResultReporter (#22138)
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 92ab021acd4 Refactor SQLParseResultReporter (#22138)
92ab021acd4 is described below
commit 92ab021acd4387af02ec34f9e06dd25fd8ae354f
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Nov 13 16:50:52 2022 +0800
Refactor SQLParseResultReporter (#22138)
* Refactor SQLParseResultReporter
* Fix checkstyle
---
.../integration/sql/parser/engine/SQLParserParameterizedIT.java | 6 +++---
.../integration/sql/parser/result/SQLParseResultReporter.java | 9 ++++++---
.../sql/parser/result/SQLParseResultReporterCreatorFactory.java | 2 +-
.../sql/parser/result/type/csv/CsvSQLParseResultReporter.java | 4 ++--
.../sql/parser/result/type/log/LogSQLParseResultReporter.java | 2 +-
5 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/SQLParserParameterizedIT.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/SQLParserParameterizedIT.java
index 83b791beacb..6c190ab9966 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/SQLParserParameterizedIT.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/engine/SQLParserParameterizedIT.java
@@ -49,14 +49,14 @@ public abstract class SQLParserParameterizedIT {
@Test
public final void assertParseSQL() {
- String result = "success";
+ boolean isSuccess = true;
try {
ParseASTNode parseASTNode = new SQLParserEngine(databaseType, new CacheOption(128, 1024L)).parse(sql, false);
new SQLVisitorEngine(databaseType, "STATEMENT", true, new Properties()).visit(parseASTNode);
} catch (final ShardingSphereExternalException | ClassCastException | NullPointerException | IllegalArgumentException | IndexOutOfBoundsException ignore) {
- result = "failed";
+ isSuccess = false;
log.warn("ParserError: " + sqlCaseId + " value: " + sql + " db-type: " + databaseType);
}
- resultReporter.printResult(sqlCaseId, databaseType, result, sql);
+ resultReporter.printResult(sqlCaseId, databaseType, isSuccess, sql);
}
}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java
index f52af3d3720..4f5d3dc3acc 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporter.java
@@ -24,8 +24,11 @@ public interface SQLParseResultReporter {
/**
* Print result.
- *
- * @param recordValues record values
+ *
+ * @param sqlCaseId SQL case ID
+ * @param databaseType database type
+ * @param sql SQL
+ * @param isSuccess whether success
*/
- void printResult(Object... recordValues);
+ void printResult(String sqlCaseId, String databaseType, boolean isSuccess, String sql);
}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterCreatorFactory.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterCreatorFactory.java
index 38786ad5ee8..98f36d4db0a 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterCreatorFactory.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/SQLParseResultReporterCreatorFactory.java
@@ -38,7 +38,7 @@ public final class SQLParseResultReporterCreatorFactory {
* @param type type
* @return new instance of SQL parse result reporter creator
*/
- public static SQLParseResultReporterCreator newInstance(String type) {
+ public static SQLParseResultReporterCreator newInstance(final String type) {
return TypedSPIRegistry.getRegisteredService(SQLParseResultReporterCreator.class, type);
}
}
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/csv/CsvSQLParseResultReporter.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/csv/CsvSQLParseResultReporter.java
index 2148c524ad8..d0cf541e94c 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/csv/CsvSQLParseResultReporter.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/csv/CsvSQLParseResultReporter.java
@@ -56,9 +56,9 @@ public final class CsvSQLParseResultReporter implements SQLParseResultReporter {
}
@Override
- public void printResult(final Object... recordValues) {
+ public void printResult(final String sqlCaseId, final String databaseType, final boolean isSuccess, final String sql) {
try {
- printer.printRecord(recordValues);
+ printer.printRecord(sqlCaseId, databaseType, isSuccess ? "success" : "failed", sql);
printer.flush();
} catch (final IOException ex) {
throw new RuntimeException("Write CSV file failed.", ex);
diff --git a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/log/LogSQLParseResultReporter.java b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/log/LogSQLParseResultReporter.java
index 38e33087884..49b4d7c60f3 100644
--- a/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/log/LogSQLParseResultReporter.java
+++ b/test/integration-test/sql-parser/src/test/java/org/apache/shardingsphere/test/integration/sql/parser/result/type/log/LogSQLParseResultReporter.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.test.integration.sql.parser.result.SQLParseResu
public final class LogSQLParseResultReporter implements SQLParseResultReporter {
@Override
- public void printResult(final Object... recordValues) {
+ public void printResult(final String sqlCaseId, final String databaseType, final boolean isSuccess, final String sql) {
// TODO set up the log format
log.info("Printing the SQL parser process result");
}