#pragma once #include #include #include #include namespace DB { /// Methods, that helps dispatching over real column types. template const Type * checkAndGetDataType(const IDataType * data_type) { return typeid_cast(data_type); } template bool checkDataType(const IDataType * data_type) { return checkAndGetDataType(data_type); } template const Type * checkAndGetColumn(const IColumn * column) { return typeid_cast(column); } template bool checkColumn(const IColumn * column) { return checkAndGetColumn(column); } template const ColumnConst * checkAndGetColumnConst(const IColumn * column) { if (!column->isConst()) return {}; const ColumnConst * res = static_cast(column); if (!checkColumn(&res->getDataColumn())) return {}; return res; } template const Type * checkAndGetColumnConstData(const IColumn * column) { const ColumnConst * res = checkAndGetColumnConst(column); if (!res) return res; return &res->getDataColumn(); } template const bool checkColumnConst(const IColumn * column) { return checkAndGetColumnConst(column); } /// Returns non-nullptr if column is ColumnConst with ColumnString or ColumnFixedString inside. const ColumnConst * checkAndGetColumnConstStringOrFixedString(const IColumn * column); /// Transform anything to Field. template inline Field toField(const T & x) { return Field(typename NearestFieldType::Type(x)); } ColumnPtr convertConstTupleToTupleOfConstants(const ColumnConst & column); template bool dispatchForFirstType(F && f) { return false; } template bool dispatchForFirstType(F && f) { if (f(static_cast(nullptr))) return true; return dispatchForFirstType(std::forward(f)); } template bool dispatchForFirstNumericType(F && f) { return dispatchForFirstType(std::forward(f)); } template bool dispatchForFirstIntegerType(F && f) { return dispatchForFirstType(std::forward(f)); } }