@@ -415,4 +415,80 @@ public void testDeploymentBatchRequest(String compressType, String storageMode)
415415 }
416416 }
417417 }
418+
419+ @ Test
420+ public void testResultSetNull () {
421+ java .sql .Statement state = executor .getStatement ();
422+ String dbname = "db" + random .nextInt (100000 );
423+ String deploymentName = "dp_test1" ;
424+ try {
425+ state .execute ("drop database if exists " + dbname + ";" );
426+ state .execute ("create database " + dbname + ";" );
427+ state .execute ("use " + dbname + ";" );
428+ String baseSql = "create table trans(c1 string,\n " +
429+ " c3 int,\n " +
430+ " c4 bigint,\n " +
431+ " c5 float,\n " +
432+ " c6 double,\n " +
433+ " c7 timestamp,\n " +
434+ " c8 date,\n " +
435+ " index(key=c1, ts=c7));" ;
436+ state .execute (baseSql );
437+ String selectSql = "SELECT c1, c3, sum(c4) OVER w1 as w1_c4_sum FROM trans WINDOW w1 AS " +
438+ "(PARTITION BY trans.c1 ORDER BY trans.c7 ROWS_RANGE BETWEEN 2s PRECEDING AND 0s OPEN PRECEDING EXCLUDE CURRENT_TIME);" ;
439+ String deploySql = "DEPLOY " + deploymentName + " " + selectSql ;
440+ state .execute (deploySql );
441+ } catch (SQLException e ) {
442+ e .printStackTrace ();
443+ Assert .fail ();
444+ }
445+ PreparedStatement pstmt = null ;
446+ ResultSet resultSet = null ;
447+ try {
448+ Thread .sleep (100 );
449+ pstmt = executor .getCallablePreparedStmt (dbname , deploymentName );
450+
451+ pstmt .setString (1 , "aa" );
452+ pstmt .setInt (2 , 20 );
453+ pstmt .setNull (3 , Types .BIGINT );
454+ pstmt .setFloat (4 , 1.1f );
455+ pstmt .setDouble (5 , 2.1 );
456+ pstmt .setTimestamp (6 , new Timestamp (0 ));
457+ pstmt .setDate (7 , Date .valueOf ("2020-05-01" ));
458+
459+ resultSet = pstmt .executeQuery ();
460+
461+ Assert .assertEquals (resultSet .getMetaData ().getColumnCount (), 3 );
462+ while (resultSet .next ()) {
463+ Assert .assertEquals (resultSet .getString (1 ), "aa" );
464+ Assert .assertEquals (resultSet .getNString (1 ), "aa" );
465+ Assert .assertEquals (resultSet .getInt (2 ), 20 );
466+ Assert .assertEquals (resultSet .getNString (2 ), "20" );
467+ Assert .assertTrue (resultSet .getNString (3 ) == null );
468+ }
469+
470+ state .execute ("drop deployment " + deploymentName + ";" );
471+ String drop = "drop table trans;" ;
472+ boolean ok = executor .executeDDL (dbname , drop );
473+ Assert .assertTrue (ok );
474+ ok = executor .dropDB (dbname );
475+ Assert .assertTrue (ok );
476+ } catch (Exception e ) {
477+ e .printStackTrace ();
478+ Assert .fail ();
479+ } finally {
480+ try {
481+ state .close ();
482+ if (resultSet != null ) {
483+ resultSet .close ();
484+ }
485+ if (pstmt != null ) {
486+ pstmt .close ();
487+ }
488+ } catch (Exception throwables ) {
489+ throwables .printStackTrace ();
490+ }
491+ }
492+ }
493+
418494}
0 commit comments