Skip to content

Commit

Permalink
added type name method to column wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
moaazassali committed Jul 10, 2024
1 parent cccc99f commit c2ea477
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/columns/column_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ extern "C" EXPORT inline void chc_column_free(const Column *col) {
delete col;
}

extern "C" EXPORT inline int32_t chc_column_type(const Column *col) {
extern "C" EXPORT inline int32_t chc_column_type_code(const Column *col) {
return col->Type()->GetCode();
}

extern "C" EXPORT inline const char *chc_column_type_name(const Column *col) {
return col->Type()->GetName().c_str();
}

extern "C" EXPORT inline void chc_column_reserve(Column *col, const size_t new_cap) {
col->Reserve(new_cap);
}
Expand Down
8 changes: 7 additions & 1 deletion tests/columns/column_wrapper_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <doctest/doctest.h>
#include <clickhouse/columns/numeric.h>

#include "clickhouse/columns/array.h"
#include "columns/column_wrapper.h"

TEST_CASE("Column is nullptr after being freed") {
Expand All @@ -10,7 +11,12 @@ TEST_CASE("Column is nullptr after being freed") {

TEST_CASE("GetColumnType() returns correct type") {
const auto col = new ColumnInt8();
CHECK(chc_column_type(col) == Type::Int8);
CHECK(chc_column_type_code(col) == Type::Int8);
}

TEST_CASE("GetColumnTypeName() returns correct type name") {
const auto col = new ColumnArrayT<ColumnArrayT<ColumnInt8> >();
CHECK(std::string(chc_column_type_name(col)) == "Array(Array(Int8))");
}

TEST_CASE("ReserveColumn() correctly changes capacity") {
Expand Down

0 comments on commit c2ea477

Please sign in to comment.