From 5e8931f0adb87dfad58118ac58e16b38d4f5c16f Mon Sep 17 00:00:00 2001 From: Andrew Slabko Date: Wed, 13 Aug 2025 18:37:33 +0200 Subject: [PATCH 1/2] Add ColumnNothing to the installation script Additionally, import it in client.h for consistency and to avoid manually importing it each time this column type is in use. --- clickhouse/CMakeLists.txt | 1 + clickhouse/client.h | 1 + 2 files changed, 2 insertions(+) diff --git a/clickhouse/CMakeLists.txt b/clickhouse/CMakeLists.txt index a98a8282..7669420a 100644 --- a/clickhouse/CMakeLists.txt +++ b/clickhouse/CMakeLists.txt @@ -221,6 +221,7 @@ INSTALL(FILES columns/ip4.h DESTINATION include/clickhouse/columns/) INSTALL(FILES columns/ip6.h DESTINATION include/clickhouse/columns/) INSTALL(FILES columns/itemview.h DESTINATION include/clickhouse/columns/) INSTALL(FILES columns/lowcardinality.h DESTINATION include/clickhouse/columns/) +INSTALL(FILES columns/nothing.h DESTINATION include/clickhouse/columns/) INSTALL(FILES columns/nullable.h DESTINATION include/clickhouse/columns/) INSTALL(FILES columns/numeric.h DESTINATION include/clickhouse/columns/) INSTALL(FILES columns/map.h DESTINATION include/clickhouse/columns/) diff --git a/clickhouse/client.h b/clickhouse/client.h index 0b15a792..dd4048cc 100644 --- a/clickhouse/client.h +++ b/clickhouse/client.h @@ -11,6 +11,7 @@ #include "columns/ip4.h" #include "columns/ip6.h" #include "columns/lowcardinality.h" +#include "columns/nothing.h" #include "columns/nullable.h" #include "columns/numeric.h" #include "columns/map.h" From beb10fc3eb75fb4e6b6802be3f57034ef91da6ac Mon Sep 17 00:00:00 2001 From: Andrew Slabko Date: Wed, 13 Aug 2025 18:40:39 +0200 Subject: [PATCH 2/2] Add small test for NothingColumn type --- ut/client_ut.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ut/client_ut.cpp b/ut/client_ut.cpp index 43b8a104..ddb0b4ca 100644 --- a/ut/client_ut.cpp +++ b/ut/client_ut.cpp @@ -434,6 +434,20 @@ TEST_P(ClientCase, Nullable) { EXPECT_EQ(sizeof(TEST_DATA) / sizeof(TEST_DATA[0]), row); } +TEST_P(ClientCase, Nothing) { + size_t total_row_count = 0; + client_->Select("SELECT NULL", [&total_row_count](const Block & block) + { + total_row_count += block.GetRowCount(); + for (size_t i = 0; i < block.GetRowCount(); ++i) { + EXPECT_TRUE(block[0]->AsStrict()->IsNull(i)); + auto column = ColumnNullableT::Wrap(block[0]->AsStrict()); + EXPECT_FALSE(column->At(i).has_value()); + } + }); + ASSERT_EQ(total_row_count, 1UL); +} + TEST_P(ClientCase, Numbers) { try { size_t num = 0;