utafrali commented on code in PR #62517:
URL: https://github.com/apache/doris/pull/62517#discussion_r3084545914
##########
be/test/core/column/column_nullable_test.cpp:
##########
@@ -206,4 +206,66 @@ TEST(ColumnNullableTest, ScalaTypeNullStringTest2erase) {
}
}
+TEST(PredicateColumnTest, InsertDuplicateFieldsString) {
+ auto column = PredicateColumnType<TYPE_STRING>::create();
+ column->reserve(10);
+
+ // Test with a simple string - insert 5 duplicates
+ std::string test_str = "hello";
+ Field field = Field::create_field<TYPE_STRING>(test_str);
+ column->insert_duplicate_fields(field, 5);
+
+ EXPECT_EQ(column->size(), 5);
+ for (size_t i = 0; i < 5; i++) {
+ StringRef ref = column->get_data()[i];
+ EXPECT_EQ(ref.size, test_str.size());
+ EXPECT_EQ(std::string(ref.data, ref.size), test_str);
+ }
+
+ // Insert another batch to verify memory doesn't overlap
+ std::string str2 = "world";
+ Field field2 = Field::create_field<TYPE_STRING>(str2);
+ column->insert_duplicate_fields(field2, 3);
+
+ EXPECT_EQ(column->size(), 8);
+ // Verify first batch is still correct
+ for (size_t i = 0; i < 5; i++) {
+ StringRef ref = column->get_data()[i];
+ EXPECT_EQ(std::string(ref.data, ref.size), test_str);
+ }
+ // Verify second batch
+ for (size_t i = 5; i < 8; i++) {
+ StringRef ref = column->get_data()[i];
+ EXPECT_EQ(std::string(ref.data, ref.size), str2);
+ }
+}
+
+TEST(PredicateColumnTest, InsertDuplicateFieldsInt) {
+ auto column = PredicateColumnType<TYPE_INT>::create();
+ column->reserve(10);
+
+ Int32 val = 42;
+ Field field = Field::create_field<TYPE_INT>(val);
+ column->insert_duplicate_fields(field, 5);
+
+ EXPECT_EQ(column->size(), 5);
+ for (size_t i = 0; i < 5; i++) {
+ EXPECT_EQ(column->get_data()[i], 42);
+ }
+}
+
+TEST(PredicateColumnTest, InsertDuplicateFieldsLargeInt) {
+ auto column = PredicateColumnType<TYPE_LARGEINT>::create();
+ column->reserve(10);
+
+ Int128 val = Int128(123456789012345LL) * Int128(1000000000LL);
+ Field field = Field::create_field<TYPE_LARGEINT>(val);
+ column->insert_duplicate_fields(field, 3);
+
+ EXPECT_EQ(column->size(), 3);
+ for (size_t i = 0; i < 3; i++) {
+ EXPECT_EQ(column->get_data()[i], val);
+ }
+}
+
} // namespace doris
Review Comment:
Missing newline at end of file. The diff shows `\ No newline at end of file`
on the closing brace. Most editors and CI linters flag this; add a trailing
newline to stay consistent with the rest of the file.
##########
be/test/core/column/column_nullable_test.cpp:
##########
@@ -206,4 +206,66 @@ TEST(ColumnNullableTest, ScalaTypeNullStringTest2erase) {
}
}
+TEST(PredicateColumnTest, InsertDuplicateFieldsString) {
Review Comment:
These three tests use `PredicateColumnTest` as the suite name but live
inside `column_nullable_test.cpp`. They are testing `PredicateColumnType`
directly, not `ColumnNullable`. Consider moving them to a dedicated
`predicate_column_test.cpp` to keep test organization consistent with the class
under test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]