2021-08-20 21:14:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-08-20 14:06:57 +00:00
|
|
|
#include <Functions/IFunction.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-08-20 21:14:26 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
|
|
|
}
|
|
|
|
|
2021-08-20 14:06:57 +00:00
|
|
|
class TupleIFunction : public IFunction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Columns getTupleElements(const IColumn & column) const
|
|
|
|
{
|
|
|
|
if (const auto * const_column = typeid_cast<const ColumnConst *>(&column))
|
|
|
|
return convertConstTupleToConstantElements(*const_column);
|
|
|
|
|
|
|
|
if (const auto * column_tuple = typeid_cast<const ColumnTuple *>(&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());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|