#pragma once #include #include #include #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 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 || !column->isColumnConst()) 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 {}; return static_cast(&res->getDataColumn()); } template 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 std::enable_if_t, Field> toField(const T & x) { return Field(NearestFieldType(x)); } template inline std::enable_if_t, Field> toField(const T & x, UInt32 scale) { return Field(NearestFieldType(x, scale)); } Columns convertConstTupleToConstantElements(const ColumnConst & column); /// Returns the copy of a given block in which each column specified in /// the "arguments" parameter is replaced with its respective nested /// column if it is nullable. Block createBlockWithNestedColumns(const Block & block, const ColumnNumbers & args); /// Similar function as above. Additionally transform the result type if needed. Block createBlockWithNestedColumns(const Block & block, const ColumnNumbers & args, size_t result); }