mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Fix
This commit is contained in:
parent
30f0e48777
commit
f820047cc8
@ -56,7 +56,7 @@ static DataTypePtr convertPostgreSQLDataType(std::string & type, bool is_nullabl
|
||||
{
|
||||
/// Numeric and decimal will both end up here as numeric. If it has type and precision,
|
||||
/// there will be Numeric(x, y), otherwise just Numeric
|
||||
uint32_t precision, scale;
|
||||
UInt32 precision, scale;
|
||||
if (type.ends_with(")"))
|
||||
{
|
||||
res = DataTypeFactory::instance().get(type);
|
||||
@ -71,11 +71,14 @@ static DataTypePtr convertPostgreSQLDataType(std::string & type, bool is_nullabl
|
||||
res = std::make_shared<DataTypeDecimal<Decimal128>>(precision, scale);
|
||||
else if (precision <= DecimalUtils::maxPrecision<Decimal256>())
|
||||
res = std::make_shared<DataTypeDecimal<Decimal256>>(precision, scale);
|
||||
else
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Presicion {} and scale {} are too big and not supported", precision, scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
precision = DecimalUtils::maxPrecision<Decimal128>();
|
||||
res = std::make_shared<DataTypeDecimal<Decimal128>>(precision, precision);
|
||||
scale = precision >> 1;
|
||||
res = std::make_shared<DataTypeDecimal<Decimal128>>(precision, scale);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,13 +63,13 @@ def test_postgres_conversions(started_cluster):
|
||||
cursor.execute(
|
||||
'''CREATE TABLE IF NOT EXISTS test_types (
|
||||
a smallint, b integer, c bigint, d real, e double precision, f serial, g bigserial,
|
||||
h timestamp, i date, j decimal(5, 5), k numeric)''')
|
||||
h timestamp, i date, j decimal(5, 3), k numeric)''')
|
||||
node1.query('''
|
||||
INSERT INTO TABLE FUNCTION postgresql('postgres1:5432', 'clickhouse', 'test_types', 'postgres', 'mysecretpassword') VALUES
|
||||
(-32768, -2147483648, -9223372036854775808, 1.12345, 1.1234567890, 2147483647, 9223372036854775807, '2000-05-12 12:12:12', '2000-05-12', 0.22222, 0.22222)''')
|
||||
(-32768, -2147483648, -9223372036854775808, 1.12345, 1.1234567890, 2147483647, 9223372036854775807, '2000-05-12 12:12:12', '2000-05-12', 22.222, 22.222)''')
|
||||
result = node1.query('''
|
||||
SELECT a, b, c, d, e, f, g, h, i, j, toDecimal32(k, 5) FROM postgresql('postgres1:5432', 'clickhouse', 'test_types', 'postgres', 'mysecretpassword')''')
|
||||
assert(result == '-32768\t-2147483648\t-9223372036854775808\t1.12345\t1.123456789\t2147483647\t9223372036854775807\t2000-05-12 12:12:12\t2000-05-12\t0.22222\t0.22222\n')
|
||||
SELECT a, b, c, d, e, f, g, h, i, j, toDecimal128(k, 3) FROM postgresql('postgres1:5432', 'clickhouse', 'test_types', 'postgres', 'mysecretpassword')''')
|
||||
assert(result == '-32768\t-2147483648\t-9223372036854775808\t1.12345\t1.123456789\t2147483647\t9223372036854775807\t2000-05-12 12:12:12\t2000-05-12\t22.222\t22.222\n')
|
||||
|
||||
cursor.execute(
|
||||
'''CREATE TABLE IF NOT EXISTS test_array_dimensions
|
||||
|
Loading…
Reference in New Issue
Block a user