#include "ExternalResultDescription.h" #include #include #include #include #include #include #include #include #include #include namespace DB { namespace ErrorCodes { extern const int UNKNOWN_TYPE; } void ExternalResultDescription::init(const Block & sample_block_) { sample_block = sample_block_; types.reserve(sample_block.columns()); for (auto & elem : sample_block) { /// If default value for column was not provided, use default from data type. if (elem.column->empty()) elem.column = elem.type->createColumnConstWithDefaultValue(1)->convertToFullColumnIfConst(); bool is_nullable = elem.type->isNullable(); DataTypePtr type_not_nullable = removeNullable(elem.type); const IDataType * type = type_not_nullable.get(); if (typeid_cast(type)) types.emplace_back(ValueType::vtUInt8, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtUInt16, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtUInt32, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtUInt64, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtInt8, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtInt16, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtInt32, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtInt64, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtFloat32, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtFloat64, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtString, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtDate, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtDateTime, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtUUID, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtString, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtString, is_nullable); else if (typeid_cast(type)) types.emplace_back(ValueType::vtDateTime64, is_nullable); else if (typeid_cast *>(type)) types.emplace_back(ValueType::vtDecimal32, is_nullable); else if (typeid_cast *>(type)) types.emplace_back(ValueType::vtDecimal64, is_nullable); else if (typeid_cast *>(type)) types.emplace_back(ValueType::vtDecimal128, is_nullable); else if (typeid_cast *>(type)) types.emplace_back(ValueType::vtDecimal256, is_nullable); else throw Exception{"Unsupported type " + type->getName(), ErrorCodes::UNKNOWN_TYPE}; } } }