Skip to content

Commit ca3c0c0

Browse files
authored
Merge pull request #2166 from ClickHouse/small_fixes
[client-v1,v2] Small fix and change in tests
2 parents b7c0e9e + e30544d commit ca3c0c0

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

clickhouse-http-client/src/main/java/com/clickhouse/client/http/ApacheHttpConnectionImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,7 @@ static class HttpConnectionManager extends PoolingHttpClientConnectionManager {
433433
USER_AGENT = ClickHouseClientOption.buildUserAgent(null,
434434
versionInfo != null && !versionInfo.isEmpty() ? versionInfo : PROVIDER);
435435

436-
try {
437-
Socket s = new Socket();
436+
try (Socket s = new Socket()) {
438437
int defaultSoRcvBuf = s.getReceiveBufferSize();
439438
int defaultSoSndBuf = s.getSendBufferSize();
440439
s.setReceiveBufferSize(Integer.MAX_VALUE);
@@ -446,6 +445,7 @@ static class HttpConnectionManager extends PoolingHttpClientConnectionManager {
446445
defaultSoRcvBuf, defaultSoSndBuf, maxSoRcvBuf, maxSoSndBuf);
447446
} catch (Exception e) { // NOSONAR
448447
// ignore
448+
log.warn("Failed to get default socket buffer size", e);
449449
}
450450
}
451451

client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public static String tblCreateSQL(String table) {
142142

143143
@Test(groups = {"integration"})
144144
public void testVariantWithSimpleDataTypes() throws Exception {
145-
if (isVersionMatch("(,24.8]") || isCloud()) {
145+
if (isVersionMatch("(,24.8]")) {
146146
return;
147147
}
148148

@@ -183,9 +183,10 @@ public void testVariantWithSimpleDataTypes() throws Exception {
183183
continue dataTypesLoop;
184184

185185
}
186-
b.append(")) Engine = MergeTree ORDER BY () SETTINGS enable_variant_type=1");
186+
b.append(")) Engine = MergeTree ORDER BY ()");
187187

188-
client.execute(b.toString());
188+
client.execute(b.toString(),
189+
(CommandSettings) new CommandSettings().serverSetting("allow_experimental_variant_type", "1"));
189190
client.register(DTOForVariantPrimitivesTests.class, client.getTableSchema(table));
190191

191192
Object value = null;
@@ -396,7 +397,7 @@ public void testVariantWithTuple() throws Exception {
396397

397398
@Test(groups = {"integration"})
398399
public void testDynamicWithPrimitives() throws Exception {
399-
if (isVersionMatch("(,24.8]") || isCloud()) {
400+
if (isVersionMatch("(,24.8]")) {
400401
return;
401402
}
402403

@@ -588,14 +589,14 @@ public static class DTOForDynamicPrimitivesTests {
588589
}
589590

590591
private void testDynamicWith(String withWhat, Object[] values, String[] expectedStrValues) throws Exception {
591-
if (isVersionMatch("(,24.8]") || isCloud()) {
592+
if (isVersionMatch("(,24.8]")) {
592593
return;
593594
}
594595

595596
String table = "test_dynamic_with_" + withWhat;
596597
client.execute("DROP TABLE IF EXISTS " + table).get();
597598
client.execute(tableDefinition(table, "rowId Int32", "field Dynamic"),
598-
(CommandSettings) new CommandSettings().serverSetting("enable_dynamic_type", "1")).get();
599+
(CommandSettings) new CommandSettings().serverSetting("allow_experimental_dynamic_type", "1")).get();
599600

600601
client.register(DTOForDynamicPrimitivesTests.class, client.getTableSchema(table));
601602

@@ -612,7 +613,7 @@ private void testDynamicWith(String withWhat, Object[] values, String[] expected
612613
}
613614

614615
private void testVariantWith(String withWhat, String[] fields, Object[] values, String[] expectedStrValues) throws Exception {
615-
if (isVersionMatch("(,24.8]") || isCloud()) {
616+
if (isVersionMatch("(,24.8]")) {
616617
return;
617618
}
618619

@@ -621,7 +622,8 @@ private void testVariantWith(String withWhat, String[] fields, Object[] values,
621622
actualFields[0] = "rowId Int32";
622623
System.arraycopy(fields, 0, actualFields, 1, fields.length);
623624
client.execute("DROP TABLE IF EXISTS " + table).get();
624-
client.execute(tableDefinition(table, actualFields), (CommandSettings) new CommandSettings().serverSetting("enable_variant_type", "1")).get();
625+
client.execute(tableDefinition(table, actualFields),
626+
(CommandSettings) new CommandSettings().serverSetting("allow_experimental_variant_type", "1")).get();
625627

626628
client.register(DTOForVariantPrimitivesTests.class, client.getTableSchema(table));
627629

client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,8 +1418,9 @@ private List<Map<String, Object>> prepareDataSet(String table, List<String> colu
14181418

14191419
// Create table
14201420
CommandSettings settings = new CommandSettings();
1421-
if (isVersionMatch("[24.8,)") && !isCloud()) {
1422-
settings.serverSetting("allow_experimental_dynamic_type", "1")
1421+
if (isVersionMatch("[24.8,)")) {
1422+
settings.serverSetting("allow_experimental_variant_type", "1")
1423+
.serverSetting("allow_experimental_dynamic_type", "1")
14231424
.serverSetting("allow_experimental_json_type", "1");
14241425
}
14251426
StringBuilder createStmtBuilder = new StringBuilder();

jdbc-v2/src/test/java/com/clickhouse/jdbc/DataTypeTests.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -823,14 +823,12 @@ public void testGeometricTypesSimpleStatement() throws SQLException {
823823

824824
@Test(groups = { "integration" })
825825
public void testDynamicTypesSimpleStatement() throws SQLException {
826-
if (earlierThan(24, 8) || isCloud()) {
826+
if (earlierThan(24, 8)) {
827827
return;
828828
}
829829

830830
Properties properties = new Properties();
831-
if (!isCloud()) {
832-
properties.setProperty(ClientConfigProperties.serverSetting("allow_experimental_dynamic_type"), "1");
833-
}
831+
properties.setProperty(ClientConfigProperties.serverSetting("allow_experimental_dynamic_type"), "1");
834832
runQuery("CREATE TABLE test_dynamic (order Int8, "
835833
+ "dynamic Dynamic"
836834
+ ") ENGINE = MergeTree ORDER BY ()",
@@ -941,14 +939,12 @@ public void testTypeConversions() throws Exception {
941939

942940
@Test(groups = { "integration" })
943941
public void testVariantTypesSimpleStatement() throws SQLException {
944-
if (earlierThan(24, 8) || isCloud()) {
942+
if (earlierThan(24, 8)) {
945943
return;
946944
}
947945

948946
Properties properties = new Properties();
949-
if (!isCloud()) {
950-
properties.setProperty(ClientConfigProperties.serverSetting("allow_experimental_variant_type"), "1");
951-
}
947+
properties.setProperty(ClientConfigProperties.serverSetting("allow_experimental_variant_type"), "1");
952948
runQuery("CREATE TABLE test_variant (order Int8, "
953949
+ "v Variant(String, Int32)"
954950
+ ") ENGINE = MergeTree ORDER BY ()",

0 commit comments

Comments
 (0)