diff --git a/dbms/src/Columns/ColumnNullable.cpp b/dbms/src/Columns/ColumnNullable.cpp index d9a8ea4f825..20511ec6bfc 100644 --- a/dbms/src/Columns/ColumnNullable.cpp +++ b/dbms/src/Columns/ColumnNullable.cpp @@ -81,9 +81,18 @@ StringRef ColumnNullable::getDataAt(size_t /*n*/) const throw Exception{"Method getDataAt is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED}; } -void ColumnNullable::insertData(const char * /*pos*/, size_t /*length*/) +void ColumnNullable::insertData(const char * pos, size_t length) { - throw Exception{"Method insertData is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED}; + if (pos == nullptr) + { + getNestedColumn().insertDefault(); + getNullMapData().push_back(1); + } + else + { + getNestedColumn().insertData(pos, length); + getNullMapData().push_back(0); + } } StringRef ColumnNullable::serializeValueIntoArena(size_t n, Arena & arena, char const *& begin) const diff --git a/dbms/src/Columns/ColumnNullable.h b/dbms/src/Columns/ColumnNullable.h index 43a6256b1a5..19246cd597d 100644 --- a/dbms/src/Columns/ColumnNullable.h +++ b/dbms/src/Columns/ColumnNullable.h @@ -51,6 +51,8 @@ public: bool getBool(size_t n) const override { return isNullAt(n) ? 0 : nested_column->getBool(n); } UInt64 get64(size_t n) const override { return nested_column->get64(n); } StringRef getDataAt(size_t n) const override; + + /// Will insert null value if pos=nullptr void insertData(const char * pos, size_t length) override; StringRef serializeValueIntoArena(size_t n, Arena & arena, char const *& begin) const override; const char * deserializeAndInsertFromArena(const char * pos) override; diff --git a/dbms/src/Columns/IColumn.h b/dbms/src/Columns/IColumn.h index 74a1302d094..8839703ac1e 100644 --- a/dbms/src/Columns/IColumn.h +++ b/dbms/src/Columns/IColumn.h @@ -141,6 +141,7 @@ public: /// Appends data located in specified memory chunk if it is possible (throws an exception if it cannot be implemented). /// Is used to optimize some computations (in aggregation, for example). /// Parameter length could be ignored if column values have fixed size. + /// All data will be inserted as single element virtual void insertData(const char * pos, size_t length) = 0; /// Appends "default value".