Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
4paradigm committed Nov 17, 2023
1 parent 31c0a76 commit 4901af6
Showing 1 changed file with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,4 +415,78 @@ public void testDeploymentBatchRequest(String compressType, String storageMode)
}
}
}

@Test
public void testResultSetNull() {
java.sql.Statement state = executor.getStatement();
String dbname = "db" + random.nextInt(100000);
String deploymentName = "dp_test1";
try {
state.execute("drop database if exists " + dbname + ";");
state.execute("create database " + dbname + ";");
state.execute("use " + dbname + ";");
String baseSql = "create table trans(c1 string,\n" +
" c3 int,\n" +
" c4 bigint,\n" +
" c5 float,\n" +
" c6 double,\n" +
" c7 timestamp,\n" +
" c8 date,\n" +
" index(key=c1, ts=c7));";
state.execute(baseSql);
String selectSql = "SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM trans WINDOW w1 AS " +
"(PARTITION BY trans.c1 ORDER BY trans.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 0s OPEN PRECEDING EXCLUDE CURRENT_TIME);";
String deploySql = "DEPLOY " + deploymentName + " " + selectSql;
state.execute(deploySql);
} catch (SQLException e) {
e.printStackTrace();
Assert.fail();
}
PreparedStatement pstmt = null;
ResultSet resultSet = null;
try {
Thread.sleep(100);
pstmt = executor.getCallablePreparedStmt(dbname, deploymentName);

pstmt.setString(1, "aa");
pstmt.setInt(2, 20);
pstmt.setNull(3, Types.BIGINT);
pstmt.setFloat(4, 1.1f);
pstmt.setDouble(5, 2.1);
pstmt.setTimestamp(6, new Timestamp(0));
pstmt.setDate(7, Date.valueOf("2020-05-01"));

resultSet = pstmt.executeQuery();

Assert.assertEquals(resultSet.getMetaData().getColumnCount(), 3);
while (resultSet.next()) {
Assert.assertEquals(resultSet.getString(1), "aa");
Assert.assertEquals(resultSet.getInt(2), 20);
Assert.assertTrue(resultSet.getNString(3) == null);
}

state.execute("drop deployment " + deploymentName + ";");
String drop = "drop table trans;";
boolean ok = executor.executeDDL(dbname, drop);
Assert.assertTrue(ok);
ok = executor.dropDB(dbname);
Assert.assertTrue(ok);
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
} finally {
try {
state.close();
if (resultSet != null) {
resultSet.close();
}
if (pstmt != null) {
pstmt.close();
}
} catch (Exception throwables) {
throwables.printStackTrace();
}
}
}

}

0 comments on commit 4901af6

Please sign in to comment.