Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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, ""),
Expand Down Expand Up @@ -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"),
Expand All @@ -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;

<T> ClickHouseQueryParam(String key, T defaultValue, Class<T> clazz, String description) {
Expand All @@ -279,7 +285,7 @@ public Object getDefaultValue() {
return defaultValue;
}

public Class getClazz() {
public Class<?> getClazz() {
return clazz;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<ClickHouseQueryParam, String> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@

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;

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;
import ru.yandex.clickhouse.util.Utils;

public class ClickHouseMapTest {
Expand Down Expand Up @@ -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<ClickHouseQueryParam, String> 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) {
Expand Down