#include #include #include #include #include #include #include #include "FunctionsArithmetic.h" namespace DB { const ColumnConst * checkAndGetColumnConstStringOrFixedString(const IColumn * column) { if (!column->isColumnConst()) return {}; const ColumnConst * res = static_cast(column); if (checkColumn(&res->getDataColumn()) || checkColumn(&res->getDataColumn())) return res; return {}; } Columns convertConstTupleToConstantElements(const ColumnConst & column) { const ColumnTuple & src_tuple = static_cast(column.getDataColumn()); const Columns & src_tuple_columns = src_tuple.getColumns(); size_t tuple_size = src_tuple_columns.size(); size_t rows = column.size(); Columns res(tuple_size); for (size_t i = 0; i < tuple_size; ++i) res[i] = std::make_shared(src_tuple_columns[i], rows); return res; } Block createBlockWithNestedColumns(const Block & block, ColumnNumbers args) { std::sort(args.begin(), args.end()); Block res; size_t rows = res.rows(); size_t columns = res.columns(); size_t j = 0; for (size_t i = 0; i < columns; ++i) { const auto & col = block.getByPosition(i); bool is_inserted = false; if ((j < args.size()) && (i == args[j])) { ++j; if (col.type->isNullable()) { const DataTypePtr & nested_type = static_cast(col.type).getNestedType(); if (!col.column) { res.insert(i, {nullptr, nested_type, col.name}); is_inserted = true; } else if (col.column->isColumnNullable()) { const auto & nested_col = static_cast(*col.column).getNestedColumn(); res.insert(i, {nested_col, nested_type, col.name}); is_inserted = true; } else if (col.column->isColumnConst()) { const auto & nested_col = static_cast( static_cast(*col.column).getDataColumn()).getNestedColumn(); res.insert(i, { std::make_shared(nested_col, rows), nested_type, col.name}); is_inserted = true; } } } if (!is_inserted) res.insert(i, col); } return res; } Block createBlockWithNestedColumns(const Block & block, ColumnNumbers args, size_t result) { args.push_back(result); return createBlockWithNestedColumns(block, args); } }