This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new e74b17c7614 [Fix](Row store) support decimal256 type (#34887) e74b17c7614 is described below commit e74b17c7614f3844d5f1e6b35ef773c80744b120 Author: lihangyu <15605149...@163.com> AuthorDate: Wed May 15 18:56:49 2024 +0800 [Fix](Row store) support decimal256 type (#34887) --- be/src/vec/data_types/serde/data_type_decimal_serde.h | 13 +++++++++++-- regression-test/data/point_query_p0/test_rowstore.out | 4 ++-- regression-test/suites/point_query_p0/test_rowstore.groovy | 6 ++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/be/src/vec/data_types/serde/data_type_decimal_serde.h b/be/src/vec/data_types/serde/data_type_decimal_serde.h index 6209838fb4b..16d6a5f806d 100644 --- a/be/src/vec/data_types/serde/data_type_decimal_serde.h +++ b/be/src/vec/data_types/serde/data_type_decimal_serde.h @@ -35,6 +35,7 @@ #include "vec/columns/column_const.h" #include "vec/common/string_ref.h" #include "vec/core/types.h" +#include "vec/core/wide_integer.h" namespace doris { @@ -172,7 +173,6 @@ void DataTypeDecimalSerDe<T>::write_one_cell_to_jsonb(const IColumn& column, Jso int row_num) const { StringRef data_ref = column.get_data_at(row_num); result.writeKey(col_id); - // TODO: decimal256 if constexpr (std::is_same_v<T, Decimal<Int128>>) { Decimal128V2::NativeType val = *reinterpret_cast<const Decimal128V2::NativeType*>(data_ref.data); @@ -187,6 +187,11 @@ void DataTypeDecimalSerDe<T>::write_one_cell_to_jsonb(const IColumn& column, Jso } else if constexpr (std::is_same_v<T, Decimal<Int64>>) { Decimal64::NativeType val = *reinterpret_cast<const Decimal64::NativeType*>(data_ref.data); result.writeInt64(val); + } else if constexpr (std::is_same_v<T, Decimal256>) { + // use binary type, since jsonb does not support int256 + result.writeStartBinary(); + result.writeBinary(data_ref.data, data_ref.size); + result.writeEndBinary(); } else { throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "write_one_cell_to_jsonb with type " + column.get_name()); @@ -197,7 +202,6 @@ template <typename T> void DataTypeDecimalSerDe<T>::read_one_cell_from_jsonb(IColumn& column, const JsonbValue* arg) const { auto& col = reinterpret_cast<ColumnDecimal<T>&>(column); - // TODO: decimal256 if constexpr (std::is_same_v<T, Decimal<Int128>>) { col.insert_value(static_cast<const JsonbInt128Val*>(arg)->val()); } else if constexpr (std::is_same_v<T, Decimal128V3>) { @@ -206,6 +210,11 @@ void DataTypeDecimalSerDe<T>::read_one_cell_from_jsonb(IColumn& column, col.insert_value(static_cast<const JsonbInt32Val*>(arg)->val()); } else if constexpr (std::is_same_v<T, Decimal<Int64>>) { col.insert_value(static_cast<const JsonbInt64Val*>(arg)->val()); + } else if constexpr (std::is_same_v<T, Decimal256>) { + // use binary type, since jsonb does not support int256 + const wide::Int256 val = *reinterpret_cast<const wide::Int256*>( + static_cast<const JsonbBlobVal*>(arg)->getBlob()); + col.insert_value(Decimal256(val)); } else { throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "read_one_cell_from_jsonb with type " + column.get_name()); diff --git a/regression-test/data/point_query_p0/test_rowstore.out b/regression-test/data/point_query_p0/test_rowstore.out index b73b91ff8ca..b50caf238c3 100644 --- a/regression-test/data/point_query_p0/test_rowstore.out +++ b/regression-test/data/point_query_p0/test_rowstore.out @@ -1,7 +1,7 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !sql -- -1 abc +1 abc 1111919.123456789190000000 -- !sql -- -1 abc 123 +1 abc 1111919.123456789190000000 123 diff --git a/regression-test/suites/point_query_p0/test_rowstore.groovy b/regression-test/suites/point_query_p0/test_rowstore.groovy index c7c2b763637..7838df2dd5a 100644 --- a/regression-test/suites/point_query_p0/test_rowstore.groovy +++ b/regression-test/suites/point_query_p0/test_rowstore.groovy @@ -18,10 +18,12 @@ suite("test_rowstore", "p0") { def tableName = "rs_query" sql """DROP TABLE IF EXISTS ${tableName}""" + sql "set enable_decimal256 = true" sql """ CREATE TABLE IF NOT EXISTS ${tableName} ( `k1` int(11) NULL COMMENT "", - `k2` text NULL COMMENT "" + `v1` text NULL COMMENT "", + `v2` DECIMAL(50, 18) NULL COMMENT "" ) ENGINE=OLAP UNIQUE KEY(`k1`) DISTRIBUTED BY HASH(`k1`) BUCKETS 1 @@ -35,7 +37,7 @@ suite("test_rowstore", "p0") { """ sql "set experimental_enable_nereids_planner = false" - sql """insert into ${tableName} values (1, 'abc')""" + sql """insert into ${tableName} values (1, 'abc', 1111919.12345678919)""" explain { sql("select * from ${tableName}") contains "OPT TWO PHASE" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org