Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions be/src/vec/columns/column_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ class IColumnDummy : public IColumn {
__builtin_unreachable();
}

void update_hash_with_value(size_t n, SipHash& hash) const override {}

void update_hashes_with_value(uint64_t* __restrict hashes,
const uint8_t* __restrict null_data) const override {}

void update_xxHash_with_value(size_t start, size_t end, uint64_t& hash,
const uint8_t* __restrict null_data) const override {}

void update_crcs_with_value(uint32_t* __restrict hash, PrimitiveType type, uint32_t rows,
uint32_t offset,
const uint8_t* __restrict null_data) const override {}

void update_crc_with_value(size_t start, size_t end, uint32_t& hash,
const uint8_t* __restrict null_data) const override {}

protected:
size_t s;
};
Expand Down
65 changes: 65 additions & 0 deletions be/test/vec/columns/column_object_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,71 @@ TEST(ColumnVariantTest, basic_deserialize) {
}
}

// test ColumnVariant with ColumnNothing using update_hash_with_value
TEST(ColumnVariantTest, updateHashValueWithColumnNothingTest) {
// Create a ColumnObject with a subcolumn that contains ColumnNothing
auto variant = ColumnObject::create(3, 3);

// Create a subcolumn with ColumnNothing type
PathInData path("v.nothing");
auto type = DataTypeFactory::instance().create_data_type(TypeIndex::Nothing);
auto column = type->create_column();
column->insert_many_defaults(3);
variant->add_sub_column(path, std::move(column), type);

// Finalize the variant column to ensure proper structure
// EXPECT_TRUE(variant->finalize(ColumnObject::FinalizeMode::WRITE_MODE).ok());
// EXPECT_TRUE(variant->pick_subcolumns_to_sparse_column({}).ok());
EXPECT_EQ(variant->size(), 3);

// Test update_hash_with_value with ColumnNothing
SipHash hash1, hash2, hash3;

// Test that update_hash_with_value doesn't crash with ColumnNothing
EXPECT_NO_THROW(variant->update_hash_with_value(0, hash1));
EXPECT_NO_THROW(variant->update_hash_with_value(1, hash2));
EXPECT_NO_THROW(variant->update_hash_with_value(2, hash3));

// For ColumnNothing, the hash should be consistent since it doesn't contain actual data
// However, the hash might include structural information, so we just verify it doesn't crash
// and produces some hash value
EXPECT_NE(hash1.get64(), 0);
EXPECT_NE(hash2.get64(), 0);
EXPECT_NE(hash3.get64(), 0);

// Test update_hashes_with_value with ColumnNothing
std::vector<uint64_t> hashes(3, 0);
EXPECT_NO_THROW(variant->update_hashes_with_value(hashes.data()));

// Verify that hashes are computed (non-zero)
EXPECT_NE(hashes[0], 0);
EXPECT_NE(hashes[1], 0);
EXPECT_NE(hashes[2], 0);

// Test update_xxHash_with_value with ColumnNothing
uint64_t xxhash = 0;
EXPECT_NO_THROW(variant->update_xxHash_with_value(0, 3, xxhash, nullptr));
EXPECT_NE(xxhash, 0);

// Test update_crc_with_value with ColumnNothing
uint32_t crc_hash = 0;
EXPECT_NO_THROW(variant->update_crc_with_value(0, 3, crc_hash, nullptr));
EXPECT_NE(crc_hash, 0);

// Test with null map
std::vector<uint8_t> null_map(3, 0);
null_map[1] = 1; // Mark second row as null

std::vector<uint64_t> hashes_with_null(3, 0);
EXPECT_NO_THROW(variant->update_hashes_with_value(hashes_with_null.data(), null_map.data()));

uint64_t xxhash_with_null = 0;
EXPECT_NO_THROW(variant->update_xxHash_with_value(0, 3, xxhash_with_null, null_map.data()));

uint32_t crc_hash_with_null = 0;
EXPECT_NO_THROW(variant->update_crc_with_value(0, 3, crc_hash_with_null, null_map.data()));
}

TEST(ColumnVariantTest, basic_inset_range_from) {
auto src = VariantUtil::construct_basic_varint_column();
EXPECT_TRUE(src->finalize(ColumnObject::FinalizeMode::WRITE_MODE).ok());
Expand Down
Loading