aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/skiff/unittests/skiff_ut.cpp
diff options
context:
space:
mode:
authorAndrey Chulkov <achulkov2@nebius.com>2024-10-15 14:10:17 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-10-15 14:27:22 +0300
commit05cf1efb77e08298322326fe748b6bcdb7b6526e (patch)
treeb55a13dc9277ebf98872ee1ddee93e8f24781265 /library/cpp/skiff/unittests/skiff_ut.cpp
parent2ff5baf34b9dea61580028eb4c4afde7601232a7 (diff)
downloadydb-05cf1efb77e08298322326fe748b6bcdb7b6526e.tar.gz
Increase max decimal precision to 76 (decimal256)
* Changelog entry Type: feature Component: type system Support for decimals with precision from 35 to 76. This PR adds decimal256 support to YT. Additionally: - Decimal256 is supported in skiff as int256. - ClickHouse decimal precisions from 35 to 76 are supported in CHYT. --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/798 Co-authored-by: ermolovd <ermolovd@yandex-team.com> Co-authored-by: dakovalkov <dakovalkov@yandex-team.com> commit_hash:73c4809966cf4c625e6007d31b5dde14bd80e829
Diffstat (limited to 'library/cpp/skiff/unittests/skiff_ut.cpp')
-rw-r--r--library/cpp/skiff/unittests/skiff_ut.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/library/cpp/skiff/unittests/skiff_ut.cpp b/library/cpp/skiff/unittests/skiff_ut.cpp
index 5e4c709611..cdb09e7d52 100644
--- a/library/cpp/skiff/unittests/skiff_ut.cpp
+++ b/library/cpp/skiff/unittests/skiff_ut.cpp
@@ -209,6 +209,29 @@ Y_UNIT_TEST_SUITE(Skiff)
UNIT_ASSERT_EQUAL(parser.ParseInt128(), val2);
}
+ Y_UNIT_TEST(TestInt256)
+ {
+ TBufferStream bufferStream;
+
+ auto schema = CreateSimpleTypeSchema(EWireType::Int256);
+
+ const TInt256 val1 = {0x1924cd4aeb9ced82, 0x0885e83f456d6a7e, 0xe9ba36585eccae1a, 0x7854b6f9ce448be9};
+ const TInt256 val2 = {0xe9ba36585eccae1a, 0x1924cd4aeb9ced82, 0x0885e83f456d6a7e, static_cast<ui64>(-0x7854b6f9ce448be9)};
+
+ TCheckedSkiffWriter writer(schema, &bufferStream);
+ writer.WriteInt256(val1);
+ writer.WriteInt256(val2);
+ writer.Finish();
+
+ UNIT_ASSERT_VALUES_EQUAL(HexEncode(bufferStream.Buffer()),
+ "82ed9ceb4acd2419" "7e6a6d453fe88508" "1aaecc5e5836bae9" "e98b44cef9b65478"
+ "1aaecc5e5836bae9" "82ed9ceb4acd2419" "7e6a6d453fe88508" "1774bb310649ab87");
+
+ TCheckedSkiffParser parser(schema, &bufferStream);
+ UNIT_ASSERT_EQUAL(parser.ParseInt256(), val1);
+ UNIT_ASSERT_EQUAL(parser.ParseInt256(), val2);
+ }
+
Y_UNIT_TEST(TestUint128)
{
TBufferStream bufferStream;
@@ -232,6 +255,29 @@ Y_UNIT_TEST_SUITE(Skiff)
UNIT_ASSERT_EQUAL(parser.ParseUint128(), val2);
}
+ Y_UNIT_TEST(TestUint256)
+ {
+ TBufferStream bufferStream;
+
+ auto schema = CreateSimpleTypeSchema(EWireType::Uint256);
+
+ const auto val1 = TUint256{0x1924cd4aeb9ced82, 0x7854b6f9ce448be9, 0x8854b6f9ce448be9, 0x0885e83f456d6a7e};
+ const auto val2 = TUint256{0xe9ba36585eccae1a, 0x8854b6f9ce448be9, 0x1924cd4aeb9ced82, 0xabacabadabacaba0};
+
+ TCheckedSkiffWriter writer(schema, &bufferStream);
+ writer.WriteUint256(val1);
+ writer.WriteUint256(val2);
+ writer.Finish();
+
+ UNIT_ASSERT_VALUES_EQUAL(HexEncode(bufferStream.Buffer()),
+ "82ed9ceb4acd2419" "e98b44cef9b65478" "e98b44cef9b65488" "7e6a6d453fe88508"
+ "1aaecc5e5836bae9" "e98b44cef9b65488" "82ed9ceb4acd2419" "a0abacabadabacab");
+
+ TCheckedSkiffParser parser(schema, &bufferStream);
+ UNIT_ASSERT_EQUAL(parser.ParseUint256(), val1);
+ UNIT_ASSERT_EQUAL(parser.ParseUint256(), val2);
+ }
+
Y_UNIT_TEST(TestBoolean)
{
auto schema = CreateSimpleTypeSchema(EWireType::Boolean);