From 794247a464b81c7958fa2b6b1faa11c076500e7c Mon Sep 17 00:00:00 2001 From: HappenLee Date: Mon, 13 Jan 2025 13:44:35 +0800 Subject: [PATCH] fix ut compile --- be/test/vec/core/block_test.cpp | 2 +- .../serde/data_type_serde_mysql_test.cpp | 2 +- .../data_types/serde/data_type_serde_pb_test.cpp | 7 ++----- be/test/vec/jsonb/serialize_test.cpp | 2 +- be/test/vec/runtime/vdatetime_value_test.cpp | 16 +++++++--------- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/be/test/vec/core/block_test.cpp b/be/test/vec/core/block_test.cpp index 134264f3e803646..7c876b00aa49527 100644 --- a/be/test/vec/core/block_test.cpp +++ b/be/test/vec/core/block_test.cpp @@ -771,7 +771,7 @@ TEST(BlockTest, dump_data) { auto& date_v2_data = column_vector_date_v2->get_data(); for (int i = 0; i < 1024; ++i) { DateV2Value value; - value.from_date((uint32_t)((2022 << 9) | (6 << 5) | 6)); + value.unchecked_set_time(2022, 6, 6, 0, 0, 0, 0); date_v2_data.push_back(*reinterpret_cast(&value)); } vectorized::DataTypePtr date_v2_type(std::make_shared()); diff --git a/be/test/vec/data_types/serde/data_type_serde_mysql_test.cpp b/be/test/vec/data_types/serde/data_type_serde_mysql_test.cpp index f05919e4a8f4777..3f37bf93c52909a 100644 --- a/be/test/vec/data_types/serde/data_type_serde_mysql_test.cpp +++ b/be/test/vec/data_types/serde/data_type_serde_mysql_test.cpp @@ -204,7 +204,7 @@ void serialize_and_deserialize_mysql_test() { auto& date_v2_data = column_vector_date_v2->get_data(); for (int i = 0; i < row_num; ++i) { DateV2Value value; - value.from_date((uint32_t)((2022 << 9) | (6 << 5) | 6)); + value.unchecked_set_time(2022, 6, 6, 0, 0, 0, 0); date_v2_data.push_back(*reinterpret_cast(&value)); } vectorized::DataTypePtr date_v2_type( diff --git a/be/test/vec/data_types/serde/data_type_serde_pb_test.cpp b/be/test/vec/data_types/serde/data_type_serde_pb_test.cpp index bf6ead9b21bd28c..1414d6c78dc443b 100644 --- a/be/test/vec/data_types/serde/data_type_serde_pb_test.cpp +++ b/be/test/vec/data_types/serde/data_type_serde_pb_test.cpp @@ -668,12 +668,9 @@ TEST(DataTypeSerDePbTest, DataTypeScalaSerDeTestDateTime) { uint8_t minute = i; uint8_t second = 0; uint32_t microsecond = 123000; - auto value = ((uint64_t)(((uint64_t)year << 46) | ((uint64_t)month << 42) | - ((uint64_t)day << 37) | ((uint64_t)hour << 32) | - ((uint64_t)minute << 26) | ((uint64_t)second << 20) | - (uint64_t)microsecond)); + DateV2Value datetime_v2; - datetime_v2.from_datetime(value); + datetime_v2.unchecked_set_time(year, month, day, hour, minute, second, microsecond); auto datetime_val = binary_cast, UInt64>(datetime_v2); data.push_back(datetime_val); } diff --git a/be/test/vec/jsonb/serialize_test.cpp b/be/test/vec/jsonb/serialize_test.cpp index f3bfc4448fa6535..239d2a5f165d825 100644 --- a/be/test/vec/jsonb/serialize_test.cpp +++ b/be/test/vec/jsonb/serialize_test.cpp @@ -483,7 +483,7 @@ TEST(BlockSerializeTest, JsonbBlock) { auto& date_v2_data = column_vector_date_v2->get_data(); for (int i = 0; i < 1024; ++i) { DateV2Value value; - value.from_date((uint32_t)((2022 << 9) | (6 << 5) | 6)); + value.unchecked_set_time(2022, 6, 6, 0, 0, 0, 0); date_v2_data.push_back(*reinterpret_cast(&value)); } vectorized::DataTypePtr date_v2_type(std::make_shared()); diff --git a/be/test/vec/runtime/vdatetime_value_test.cpp b/be/test/vec/runtime/vdatetime_value_test.cpp index 6c0bfad6b56f24e..fd0b3a1d2e5e743 100644 --- a/be/test/vec/runtime/vdatetime_value_test.cpp +++ b/be/test/vec/runtime/vdatetime_value_test.cpp @@ -75,7 +75,7 @@ TEST(VDateTimeValueTest, date_v2_from_uint32_test) { uint8_t day = 24; DateV2Value date_v2; - date_v2.from_date((uint32_t)((year << 9) | (month << 5) | day)); + date_v2.unchecked_set_time(year, month, day, 0, 0, 0, 0); EXPECT_TRUE(date_v2.year() == year); EXPECT_TRUE(date_v2.month() == month); @@ -114,10 +114,7 @@ TEST(VDateTimeValueTest, datetime_v2_from_uint64_test) { uint32_t microsecond = 999999; DateV2Value datetime_v2; - datetime_v2.from_datetime((uint64_t)(((uint64_t)year << 46) | ((uint64_t)month << 42) | - ((uint64_t)day << 37) | ((uint64_t)hour << 32) | - ((uint64_t)minute << 26) | ((uint64_t)second << 20) | - (uint64_t)microsecond)); + datetime_v2.unchecked_set_time(year, month, day, hour, minute, second, microsecond); EXPECT_TRUE(datetime_v2.year() == year); EXPECT_TRUE(datetime_v2.month() == month); @@ -142,10 +139,11 @@ TEST(VDateTimeValueTest, datetime_v2_from_uint64_test) { uint32_t microsecond = 123000; DateV2Value datetime_v2; - datetime_v2.from_datetime((uint64_t)(((uint64_t)year << 46) | ((uint64_t)month << 42) | - ((uint64_t)day << 37) | ((uint64_t)hour << 32) | - ((uint64_t)minute << 26) | ((uint64_t)second << 20) | - (uint64_t)microsecond)); + auto ui64 = (uint64_t)(((uint64_t)year << 46) | ((uint64_t)month << 42) | + ((uint64_t)day << 37) | ((uint64_t)hour << 32) | + ((uint64_t)minute << 26) | ((uint64_t)second << 20) | + (uint64_t)microsecond); + datetime_v2 = (DateV2Value&)ui64; EXPECT_TRUE(datetime_v2.year() == year); EXPECT_TRUE(datetime_v2.month() == month);