diff --git a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/settings/ClickHouseQueryParam.java b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/settings/ClickHouseQueryParam.java index 4d6e57baa..f33564093 100644 --- a/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/settings/ClickHouseQueryParam.java +++ b/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/settings/ClickHouseQueryParam.java @@ -11,6 +11,10 @@ public enum ClickHouseQueryParam implements DriverPropertyCreator { AGGREGATION_MEMORY_EFFICIENT_MERGE_THREADS("aggregation_memory_efficient_merge_threads", null, Long.class, ""), + ALLOW_EXPERIMENTAL_BIGINT_TYPES("allow_experimental_bigint_types", null, Integer.class, "Enables or disables integer values exceeding the range that is supported by the int data type."), + + ALLOW_EXPERIMENTAL_MAP_TYPE("allow_experimental_map_type", null, Integer.class, "Enables or disables Map data type."), + BACKGROUND_POOL_SIZE("background_pool_size", null, Long.class, ""), AUTHORIZATION("authorization", null, String.class, "Authorization header content for HTTP transport"), @@ -78,6 +82,8 @@ public enum ClickHouseQueryParam implements DriverPropertyCreator { INTERACTIVE_DELAY("interactive_delay", null, Long.class, ""), + JOIN_ALGORITHM("join_algorithm", null, String.class, ""), + LOAD_BALANCING("load_balancing", null, String.class, ""), LOG_QUERIES("log_queries", false, Boolean.class, ""), @@ -245,9 +251,9 @@ public enum ClickHouseQueryParam implements DriverPropertyCreator { QUOTA_KEY("quota_key", null, String.class, "quota is calculated for each quota_key value. For example here may be some user name."), + @Deprecated use_client_time_zone("use_client_time_zone", false, Boolean.class, ""), - USE_UNCOMPRESSED_CACHE("use_uncompressed_cache", true, Boolean.class, "Whether to use the cache of uncompressed blocks."), USER("user", null, String.class, "user name, by default - default"), @@ -261,7 +267,7 @@ public enum ClickHouseQueryParam implements DriverPropertyCreator { private final String key; private final Object defaultValue; - private final Class clazz; + private final Class clazz; private final String description; ClickHouseQueryParam(String key, T defaultValue, Class clazz, String description) { @@ -279,7 +285,7 @@ public Object getDefaultValue() { return defaultValue; } - public Class getClazz() { + public Class getClazz() { return clazz; } diff --git a/clickhouse-jdbc/src/test/java/ru/yandex/clickhouse/integration/ClickHouseLargeNumberTest.java b/clickhouse-jdbc/src/test/java/ru/yandex/clickhouse/integration/ClickHouseLargeNumberTest.java index 7c972f410..e0eb722e3 100644 --- a/clickhouse-jdbc/src/test/java/ru/yandex/clickhouse/integration/ClickHouseLargeNumberTest.java +++ b/clickhouse-jdbc/src/test/java/ru/yandex/clickhouse/integration/ClickHouseLargeNumberTest.java @@ -1,23 +1,32 @@ package ru.yandex.clickhouse.integration; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Connection; import java.sql.ResultSet; +import java.sql.SQLException; import java.sql.Statement; +import java.util.EnumMap; +import java.util.Map; import java.util.UUID; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; +import ru.yandex.clickhouse.ClickHouseConnection; import ru.yandex.clickhouse.ClickHouseContainerForTest; import ru.yandex.clickhouse.ClickHouseDataSource; +import ru.yandex.clickhouse.ClickHouseStatement; import ru.yandex.clickhouse.except.ClickHouseException; import ru.yandex.clickhouse.settings.ClickHouseProperties; +import ru.yandex.clickhouse.settings.ClickHouseQueryParam; public class ClickHouseLargeNumberTest { private Connection conn; @@ -46,6 +55,41 @@ public void tearDown() throws Exception { } } + @Test + public void testBigIntSupport() throws SQLException { + if (conn == null) { + return; + } + + String testSql = "create table if not exists system.test_bigint_support(i Int256) engine=Memory;" + + "drop table if exists system.test_bigint_support;"; + try (Connection conn = ClickHouseContainerForTest.newDataSource().getConnection(); + Statement s = conn.createStatement()) { + s.execute("set allow_experimental_bigint_types=0;" + testSql); + fail("Should fail without enabling bigint support"); + } catch (SQLException e) { + assertEquals(e.getErrorCode(), 44); + } + + try (Connection conn = ClickHouseContainerForTest.newDataSource().getConnection(); + Statement s = conn.createStatement()) { + assertFalse(s.execute("set allow_experimental_bigint_types=1;" + testSql)); + } + + try (ClickHouseConnection conn = ClickHouseContainerForTest.newDataSource().getConnection(); + ClickHouseStatement s = conn.createStatement()) { + Map params = new EnumMap<>(ClickHouseQueryParam.class); + params.put(ClickHouseQueryParam.ALLOW_EXPERIMENTAL_BIGINT_TYPES, "1"); + assertNull(s.executeQuery(testSql, params)); + + params.put(ClickHouseQueryParam.ALLOW_EXPERIMENTAL_BIGINT_TYPES, "0"); + s.executeQuery(testSql, params); + fail("Should fail without enabling bigint support"); + } catch (SQLException e) { + assertEquals(e.getErrorCode(), 44); + } + } + @Test public void testSignedIntegers() throws Exception { if (conn == null) { diff --git a/clickhouse-jdbc/src/test/java/ru/yandex/clickhouse/integration/ClickHouseMapTest.java b/clickhouse-jdbc/src/test/java/ru/yandex/clickhouse/integration/ClickHouseMapTest.java index 562793928..32bc30537 100644 --- a/clickhouse-jdbc/src/test/java/ru/yandex/clickhouse/integration/ClickHouseMapTest.java +++ b/clickhouse-jdbc/src/test/java/ru/yandex/clickhouse/integration/ClickHouseMapTest.java @@ -2,12 +2,17 @@ import static org.junit.Assert.assertArrayEquals; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.sql.Statement; +import java.util.EnumMap; import java.util.Map; import java.util.UUID; @@ -15,10 +20,13 @@ import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; +import ru.yandex.clickhouse.ClickHouseConnection; import ru.yandex.clickhouse.ClickHouseContainerForTest; import ru.yandex.clickhouse.ClickHouseDataSource; +import ru.yandex.clickhouse.ClickHouseStatement; import ru.yandex.clickhouse.except.ClickHouseException; import ru.yandex.clickhouse.settings.ClickHouseProperties; +import ru.yandex.clickhouse.settings.ClickHouseQueryParam; import ru.yandex.clickhouse.util.Utils; public class ClickHouseMapTest { @@ -61,6 +69,41 @@ private void assertMap(Object actual, Object expected) { } } + @Test + public void testMapSupport() throws SQLException { + if (conn == null) { + return; + } + + String testSql = "create table if not exists system.test_map_support(m Map(UInt8, String)) engine=Memory;" + + "drop table if exists system.test_map_support;"; + try (Connection conn = ClickHouseContainerForTest.newDataSource().getConnection(); + Statement s = conn.createStatement()) { + s.execute("set allow_experimental_map_type=0;" + testSql); + fail("Should fail without enabling map support"); + } catch (SQLException e) { + assertEquals(e.getErrorCode(), 44); + } + + try (Connection conn = ClickHouseContainerForTest.newDataSource().getConnection(); + Statement s = conn.createStatement()) { + assertFalse(s.execute("set allow_experimental_map_type=1;" + testSql)); + } + + try (ClickHouseConnection conn = ClickHouseContainerForTest.newDataSource().getConnection(); + ClickHouseStatement s = conn.createStatement()) { + Map params = new EnumMap<>(ClickHouseQueryParam.class); + params.put(ClickHouseQueryParam.ALLOW_EXPERIMENTAL_MAP_TYPE, "1"); + assertNull(s.executeQuery(testSql, params)); + + params.put(ClickHouseQueryParam.ALLOW_EXPERIMENTAL_MAP_TYPE, "0"); + s.executeQuery(testSql, params); + fail("Should fail without enabling map support"); + } catch (SQLException e) { + assertEquals(e.getErrorCode(), 44); + } + } + @Test public void testMaps() throws Exception { if (conn == null) {