diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml
index 590d40c..0330e03 100644
--- a/.github/workflows/maven-publish.yml
+++ b/.github/workflows/maven-publish.yml
@@ -29,8 +29,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: target/sqllogictest-jdbc-runner-1.0.5-jar-with-dependencies.jar
- asset_name: sqllogictest-jdbc-runner-1.0.5-jar-with-dependencies.jar
+ asset_path: target/sqllogictest-jdbc-runner-1.0.6-jar-with-dependencies.jar
+ asset_name: sqllogictest-jdbc-runner-1.0.6-jar-with-dependencies.jar
asset_content_type: application/java-archive
- name: Publish release
uses: StuYarrow/publish-release@v1.1.2
diff --git a/pom.xml b/pom.xml
index d274748..638ef95 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.risingwave.sqllogictest
sqllogictest-jdbc-runner
- 1.0.5
+ 1.0.6
sqllogictest-jdbc-runner
https://github.com/risinglightdb/sqllogictest-rs
diff --git a/src/main/java/com/risingwave/sqllogictest/App.java b/src/main/java/com/risingwave/sqllogictest/App.java
index 996ee77..e98d089 100644
--- a/src/main/java/com/risingwave/sqllogictest/App.java
+++ b/src/main/java/com/risingwave/sqllogictest/App.java
@@ -6,41 +6,42 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.ArrayList;
import java.util.Properties;
import com.google.gson.JsonObject;
import com.google.gson.JsonStreamParser;
+import com.google.gson.Gson;
public class App
{
- private static String handleOne(Statement stmt, String sql) throws SQLException {
- var builder = new StringBuilder();
+ private static ArrayList> handleOne(Statement stmt, String sql) throws SQLException {
+ var result = new ArrayList>();
if (stmt.execute(sql)) {
try (ResultSet rs = stmt.getResultSet()) {
var colCnt = rs.getMetaData().getColumnCount();
while (rs.next()) {
+ var arr = new ArrayList();
for (var i = 1; i <= colCnt; i++) {
- if (i != 1) {
- builder.append(' ');
- }
var v = rs.getString(i);
if (v == null) {
- builder.append("NULL");
+ arr.add("NULL");
} else if (v.isEmpty()) {
- builder.append("(empty)");
+ arr.add("(empty)");
} else {
- builder.append(v);
+ arr.add(v);
}
}
- builder.append('\n');
+ result.add(arr);
}
}
}
- return builder.toString();
+ return result;
}
private static void mainLoop(Connection conn) throws Exception {
var parser = new JsonStreamParser(new InputStreamReader(System.in));
+ var gson = new Gson();
try (var stmt = conn.createStatement()) {
while (parser.hasNext()) {
var ele = parser.next();
@@ -48,13 +49,13 @@ private static void mainLoop(Connection conn) throws Exception {
try {
var result = handleOne(stmt, sql);
var resultJson = new JsonObject();
- resultJson.addProperty("result", result);
- System.out.println(resultJson.toString());
+ resultJson.add("result", gson.toJsonTree(result));
+ System.out.println(resultJson);
} catch (SQLException e) {
e.printStackTrace();
var resultJson = new JsonObject();
resultJson.addProperty("err", e.getMessage());
- System.out.println(resultJson.toString());
+ System.out.println(resultJson);
}
}
}
@@ -62,7 +63,7 @@ private static void mainLoop(Connection conn) throws Exception {
public static void main(String[] args)
{
- var url = args[0];;
+ var url = args[0];
var props = new Properties();
if (args.length > 1) {
props.setProperty("user", args[1]);