Skip to content

Commit 803e9b3

Browse files
authored
fix(ut): prevent incorrect implicit conversion of string literals to … (#24)
1 parent b9cd10e commit 803e9b3

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/paimon/common/predicate/literal_converter_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ TEST_F(LiteralConverterTest, TestStringLiteral) {
198198
std::vector<Literal>({Literal(FieldType::STRING, "apple", 5),
199199
Literal(FieldType::STRING, str.data(), str.size())}));
200200
CheckLiteralFromRow(
201-
arrow::utf8(), {"apple", "苹果", NullType()}, FieldType::STRING,
201+
arrow::utf8(), {std::string("apple"), std::string("苹果"), NullType()}, FieldType::STRING,
202202
{Literal(FieldType::STRING, "apple", 5), Literal(FieldType::STRING, str.data(), str.size()),
203203
Literal(FieldType::STRING)});
204204
}
@@ -217,7 +217,7 @@ TEST_F(LiteralConverterTest, TestBinaryLiteral) {
217217
std::vector<Literal>({Literal(FieldType::BINARY, "apple", 5),
218218
Literal(FieldType::BINARY, str.data(), str.size())}));
219219
CheckLiteralFromRow(
220-
arrow::binary(), {"apple", "苹果", NullType()}, FieldType::BINARY,
220+
arrow::binary(), {std::string("apple"), std::string("苹果"), NullType()}, FieldType::BINARY,
221221
{Literal(FieldType::BINARY, "apple", 5), Literal(FieldType::BINARY, str.data(), str.size()),
222222
Literal(FieldType::BINARY)});
223223
}

src/paimon/common/reader/data_evolution_row_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ TEST(DataEvolutionRowTest, TestSimple) {
3838
std::vector<int32_t> field_offsets = {0, 0, 1, 1, 1, 0};
3939

4040
auto pool = GetDefaultPool();
41-
BinaryRow row1 = BinaryRowGenerator::GenerateRow({0, "00"}, pool.get());
41+
BinaryRow row1 = BinaryRowGenerator::GenerateRow({0, std::string("00")}, pool.get());
4242
BinaryRow row2 = BinaryRowGenerator::GenerateRow({10, 110}, pool.get());
43-
BinaryRow row3 = BinaryRowGenerator::GenerateRow({20, "20"}, pool.get());
43+
BinaryRow row3 = BinaryRowGenerator::GenerateRow({20, std::string("20")}, pool.get());
4444

4545
DataEvolutionRow row({row1, row2, row3}, row_offsets, field_offsets);
4646
ASSERT_EQ(row.GetFieldCount(), 6);
@@ -73,7 +73,7 @@ TEST(DataEvolutionRowTest, TestNull) {
7373
std::vector<int32_t> field_offsets = {0, 0, 1, 1, 1, 0, -1, -1};
7474

7575
auto pool = GetDefaultPool();
76-
BinaryRow row1 = BinaryRowGenerator::GenerateRow({0, "00"}, pool.get());
76+
BinaryRow row1 = BinaryRowGenerator::GenerateRow({0, std::string("00")}, pool.get());
7777
BinaryRow row2 = BinaryRowGenerator::GenerateRow({10, 110}, pool.get());
7878
BinaryRow row3 = BinaryRowGenerator::GenerateRow({20, NullType()}, pool.get());
7979

src/paimon/common/utils/binary_row_partition_computer_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <cstdint>
2020
#include <limits>
21+
#include <string>
2122
#include <variant>
2223

2324
#include "arrow/type.h"
@@ -275,8 +276,8 @@ TEST(BinaryRowPartitionComputerTest, TestNullOrWhitespaceOnlyStr) {
275276
/*legacy_partition_name_enabled=*/true, pool));
276277

277278
ASSERT_OK_AND_ASSIGN(auto partition_key_values,
278-
computer->GeneratePartitionVector(
279-
BinaryRowGenerator::GenerateRow({" ", "", "ab "}, pool.get())));
279+
computer->GeneratePartitionVector(BinaryRowGenerator::GenerateRow(
280+
{std::string(" "), std::string(""), std::string("ab ")}, pool.get())));
280281
std::vector<std::pair<std::string, std::string>> expected = {
281282
{"f0", "__DEFAULT_PARTITION__"}, {"f1", "__DEFAULT_PARTITION__"}, {"f2", "ab "}};
282283
ASSERT_EQ(partition_key_values, expected);

src/paimon/core/io/key_value_in_memory_record_reader_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ TEST_F(KeyValueInMemoryRecordReaderTest, TestVariantType) {
394394
])")
395395
.ValueOrDie());
396396

397-
CheckVariantType(fields, std::move(src_array), {"1.1", "2.1"},
397+
CheckVariantType(fields, std::move(src_array), {std::string("1.1"), std::string("2.1")},
398398
{std::make_shared<Bytes>("1.12", pool_.get()),
399399
std::make_shared<Bytes>("2.12", pool_.get())});
400400
}

0 commit comments

Comments
 (0)