@@ -1418,17 +1418,19 @@ private List<Map<String, Object>> prepareDataSet(String table, List<String> colu
14181418 client .execute ("DROP TABLE IF EXISTS " + table ).get (10 , TimeUnit .SECONDS );
14191419
14201420 // Create table
1421+ CommandSettings settings = new CommandSettings ();
1422+ if (isVersionMatch ("[24.8,)" )) {
1423+ settings .serverSetting ("enable_dynamic_type" , "1" )
1424+ .serverSetting ("allow_experimental_json_type" , "1" );
1425+ }
14211426 StringBuilder createStmtBuilder = new StringBuilder ();
14221427 createStmtBuilder .append ("CREATE TABLE IF NOT EXISTS " ).append (table ).append (" (" );
14231428 for (String column : columns ) {
14241429 createStmtBuilder .append (column ).append (", " );
14251430 }
14261431 createStmtBuilder .setLength (createStmtBuilder .length () - 2 );
14271432 createStmtBuilder .append (") ENGINE = MergeTree ORDER BY tuple()" );
1428- client .execute (createStmtBuilder .toString (), (CommandSettings )
1429- new CommandSettings ().serverSetting ("enable_dynamic_type" , "1" )
1430- .serverSetting ("allow_experimental_json_type" , "1" ))
1431- .get (10 , TimeUnit .SECONDS );
1433+ client .execute (createStmtBuilder .toString (), settings ).get (10 , TimeUnit .SECONDS );
14321434
14331435 // Insert data
14341436 StringBuilder insertStmtBuilder = new StringBuilder ();
@@ -1787,9 +1789,7 @@ private static Object[][] sessionRoles() {
17871789
17881790 @ Test (groups = {"integration" }, dataProvider = "sessionRoles" , dataProviderClass = QueryTests .class )
17891791 public void testOperationCustomRoles (String [] roles ) throws Exception {
1790- List <GenericRecord > serverVersion = client .queryAll ("SELECT version()" );
1791- if (ClickHouseVersion .of (serverVersion .get (0 ).getString (1 )).check ("(,24.3]" )) {
1792- System .out .println ("Test is skipped: feature is supported since 24.4" );
1792+ if (isVersionMatch ("(,24.3]" )) {
17931793 return ;
17941794 }
17951795
@@ -1825,9 +1825,7 @@ private static Object[][] clientSessionRoles() {
18251825 }
18261826 @ Test (groups = {"integration" }, dataProvider = "clientSessionRoles" , dataProviderClass = QueryTests .class )
18271827 public void testClientCustomRoles (String [] roles ) throws Exception {
1828- List <GenericRecord > serverVersion = client .queryAll ("SELECT version()" );
1829- if (ClickHouseVersion .of (serverVersion .get (0 ).getString (1 )).check ("(,24.3]" )) {
1830- System .out .println ("Test is skipped: feature is supported since 24.4" );
1828+ if (isVersionMatch ("(,24.3]" )) {
18311829 return ;
18321830 }
18331831
@@ -1909,9 +1907,7 @@ public void testReadingJSONValues() throws Exception {
19091907 if (isCloud ()) {
19101908 return ; // TODO: add support on cloud
19111909 }
1912- List <GenericRecord > serverVersion = client .queryAll ("SELECT version()" );
1913- if (ClickHouseVersion .of (serverVersion .get (0 ).getString (1 )).check ("(,24.8]" )) {
1914- System .out .println ("Test is skipped: feature is supported since 24.8" );
1910+ if (isVersionMatch ("(,24.8]" )) {
19151911 return ;
19161912 }
19171913 CommandSettings commandSettings = new CommandSettings ();
@@ -2050,8 +2046,7 @@ public void testLowCardinalityValues() throws Exception {
20502046 @ Test (groups = {"integration" })
20512047 public void testGettingRowsBeforeLimit () throws Exception {
20522048 int expectedTotalRowsToRead = 100 ;
2053- List <GenericRecord > serverVersion = client .queryAll ("SELECT version()" );
2054- if (ClickHouseVersion .of (serverVersion .get (0 ).getString (1 )).check ("(,23.8]" )) {
2049+ if (isVersionMatch ("(,23.8]" )) {
20552050 // issue in prev. release.
20562051 expectedTotalRowsToRead = 0 ;
20572052 }
@@ -2065,6 +2060,10 @@ public void testGettingRowsBeforeLimit() throws Exception {
20652060
20662061 @ Test (groups = {"integration" })
20672062 public void testGetDynamicValue () throws Exception {
2063+ if (isVersionMatch ("(,24.8]" )) {
2064+ return ;
2065+ }
2066+
20682067 String table = "test_get_dynamic_values" ;
20692068
20702069 final AtomicInteger rowId = new AtomicInteger (-1 );
@@ -2093,6 +2092,10 @@ public void testGetDynamicValue() throws Exception {
20932092
20942093 @ Test (groups = {"integration" })
20952094 public void testGetJSON () throws Exception {
2095+ if (isVersionMatch ("(,24.8]" )) {
2096+ return ;
2097+ }
2098+
20962099 String table = "test_get_json_values" ;
20972100
20982101 final AtomicInteger rowId = new AtomicInteger (-1 );
@@ -2121,4 +2124,9 @@ public void testGetJSON() throws Exception {
21212124 }
21222125 }
21232126 }
2127+
2128+ public boolean isVersionMatch (String versionExpression ) {
2129+ List <GenericRecord > serverVersion = client .queryAll ("SELECT version()" );
2130+ return ClickHouseVersion .of (serverVersion .get (0 ).getString (1 )).check (versionExpression );
2131+ }
21242132}
0 commit comments