#include #include namespace DB { namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; } std::vector FunctionJSONHelpers::prepareMoves(const char * function_name, ColumnsWithTypeAndName & columns, size_t first_index_argument, size_t num_index_arguments) { std::vector moves; moves.reserve(num_index_arguments); for (const auto i : ext::range(first_index_argument, first_index_argument + num_index_arguments)) { const auto & column = columns[i]; if (!isString(column.type) && !isInteger(column.type)) throw Exception{"The argument " + std::to_string(i + 1) + " of function " + String(function_name) + " should be a string specifying key or an integer specifying index, illegal type: " + column.type->getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; if (column.column && isColumnConst(*column.column)) { const auto & column_const = assert_cast(*column.column); if (isString(column.type)) moves.emplace_back(MoveType::ConstKey, column_const.getValue()); else moves.emplace_back(MoveType::ConstIndex, column_const.getInt(0)); } else { if (isString(column.type)) moves.emplace_back(MoveType::Key, ""); else moves.emplace_back(MoveType::Index, 0); } } return moves; } size_t FunctionJSONHelpers::calculateMaxSize(const ColumnString::Offsets & offsets) { size_t max_size = 0; for (const auto i : ext::range(0, offsets.size())) { size_t size = offsets[i] - offsets[i - 1]; if (max_size < size) max_size = size; } if (max_size) --max_size; return max_size; } void registerFunctionsJSON(FunctionFactory & factory) { factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); factory.registerFunction>(); } }