#include #include #include namespace DB::GatherUtils { /// Creates IValueSource from Column template struct ValueSourceCreator; template struct ValueSourceCreator { static std::unique_ptr create(const IColumn & col, const NullMap * null_map, bool is_const, size_t total_rows) { if (auto column_vector = typeid_cast *>(&col)) { if (null_map) { if (is_const) return std::make_unique>>>(*column_vector, *null_map, total_rows); return std::make_unique>>(*column_vector, *null_map); } if (is_const) return std::make_unique>>(*column_vector, total_rows); return std::make_unique>(*column_vector); } return ValueSourceCreator::create(col, null_map, is_const, total_rows); } }; template <> struct ValueSourceCreator<> { static std::unique_ptr create(const IColumn & col, const NullMap * null_map, bool is_const, size_t total_rows) { if (null_map) { if (is_const) return std::make_unique>>(col, *null_map, total_rows); return std::make_unique>(col, *null_map); } if (is_const) return std::make_unique>(col, total_rows); return std::make_unique(col); } }; std::unique_ptr createValueSource(const IColumn & col, bool is_const, size_t total_rows) { using Creator = typename ApplyTypeListForClass::Type; if (auto column_nullable = typeid_cast(&col)) { return Creator::create(column_nullable->getNestedColumn(), &column_nullable->getNullMapData(), is_const, total_rows); } return Creator::create(col, nullptr, is_const, total_rows); } }