#pragma once #include #include #include #include #include namespace DB { namespace ErrorCodes { extern const int ILLEGAL_TYPE_OF_ARGUMENT; } class ITupleFunction : public IFunction { protected: ContextPtr context; public: explicit ITupleFunction(ContextPtr context_) : context(context_) {} Columns getTupleElements(const IColumn & column) const { if (const auto * const_column = typeid_cast(&column)) return convertConstTupleToConstantElements(*const_column); if (const auto * column_tuple = typeid_cast(&column)) { Columns columns(column_tuple->tupleSize()); for (size_t i = 0; i < columns.size(); ++i) columns[i] = column_tuple->getColumnPtr(i); return columns; } throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Argument of function {} should be tuples, got {}", getName(), column.getName()); } bool useDefaultImplementationForConstants() const override { return true; } bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; } }; }