mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Better
This commit is contained in:
parent
92eed10f10
commit
c060963875
@ -30,7 +30,6 @@
|
|||||||
#include <DataTypes/DataTypeArray.h>
|
#include <DataTypes/DataTypeArray.h>
|
||||||
#include <DataTypes/DataTypeTuple.h>
|
#include <DataTypes/DataTypeTuple.h>
|
||||||
#include <Interpreters/Context.h>
|
#include <Interpreters/Context.h>
|
||||||
#include <IO/ReadBufferFromString.h>
|
|
||||||
#include <common/range.h>
|
#include <common/range.h>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <boost/tti/has_member_function.hpp>
|
#include <boost/tti/has_member_function.hpp>
|
||||||
@ -679,11 +678,8 @@ struct JSONExtractTree
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const auto * type = assert_cast<const DataTypeDecimal<DecimalType> *>(data_type.get());
|
const auto * type = assert_cast<const DataTypeDecimal<DecimalType> *>(data_type.get());
|
||||||
std::stringstream ss; // STYLE_CHECK_ALLOW_STD_STRING_STREAM
|
auto result = convertToDecimal<DataTypeNumber<Float64>, DataTypeDecimal<DecimalType>>(element.getDouble(), type->getScale());
|
||||||
ss << std::setprecision(type->getPrecision()) << element.getDouble();
|
assert_cast<ColumnDecimal<DecimalType> &>(dest).insert(result);
|
||||||
auto str = ss.str();
|
|
||||||
ReadBufferFromString res(str);
|
|
||||||
assert_cast<const SerializationDecimal<DecimalType> *>(type->getDefaultSerialization().get())->deserializeText(dest, res, {});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
@ -63,7 +63,9 @@ hello
|
|||||||
(3333.6,'test')
|
(3333.6,'test')
|
||||||
(3333.6333333333,'test')
|
(3333.6333333333,'test')
|
||||||
123456.1234 Decimal(20, 4)
|
123456.1234 Decimal(20, 4)
|
||||||
123456789012345.1250
|
123456789012345.1136 123456789012345.1136
|
||||||
|
1234567890.12345677879616925706 (1234567890.12345677879616925706,'test')
|
||||||
|
1234567890.123456695758468374595199311875 (1234567890.123456695758468374595199311875,'test')
|
||||||
--JSONExtractKeysAndValues--
|
--JSONExtractKeysAndValues--
|
||||||
[('a','hello')]
|
[('a','hello')]
|
||||||
[('b',[-100,200,300])]
|
[('b',[-100,200,300])]
|
||||||
|
@ -72,7 +72,9 @@ SELECT JSONExtract('{"a": "hello", "b": [-100, 200.0, 300]}', 'a', 'LowCardinali
|
|||||||
SELECT JSONExtract('{"a":3333.6333333333333333333333, "b":"test"}', 'Tuple(a Decimal(10,1), b LowCardinality(String))');
|
SELECT JSONExtract('{"a":3333.6333333333333333333333, "b":"test"}', 'Tuple(a Decimal(10,1), b LowCardinality(String))');
|
||||||
SELECT JSONExtract('{"a":3333.6333333333333333333333, "b":"test"}', 'Tuple(a Decimal(20,10), b LowCardinality(String))');
|
SELECT JSONExtract('{"a":3333.6333333333333333333333, "b":"test"}', 'Tuple(a Decimal(20,10), b LowCardinality(String))');
|
||||||
SELECT JSONExtract('{"a":123456.123456}', 'a', 'Decimal(20, 4)') as a, toTypeName(a);
|
SELECT JSONExtract('{"a":123456.123456}', 'a', 'Decimal(20, 4)') as a, toTypeName(a);
|
||||||
SELECT JSONExtract('{"a":123456789012345.12}', 'a', 'Decimal(30, 4)');
|
SELECT toDecimal64(123456789012345.12, 4), JSONExtract('{"a":123456789012345.12}', 'a', 'Decimal(30, 4)');
|
||||||
|
SELECT toDecimal128(1234567890.12345678901234567890, 20), JSONExtract('{"a":1234567890.12345678901234567890, "b":"test"}', 'Tuple(a Decimal(35,20), b LowCardinality(String))');
|
||||||
|
SELECT toDecimal256(1234567890.123456789012345678901234567890, 30), JSONExtract('{"a":1234567890.12345678901234567890, "b":"test"}', 'Tuple(a Decimal(45,30), b LowCardinality(String))');
|
||||||
|
|
||||||
SELECT '--JSONExtractKeysAndValues--';
|
SELECT '--JSONExtractKeysAndValues--';
|
||||||
SELECT JSONExtractKeysAndValues('{"a": "hello", "b": [-100, 200.0, 300]}', 'String');
|
SELECT JSONExtractKeysAndValues('{"a": "hello", "b": [-100, 200.0, 300]}', 'String');
|
||||||
|
Loading…
Reference in New Issue
Block a user