2021-08-20 21:14:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-03-12 18:05:50 +00:00
|
|
|
#include <Columns/ColumnConst.h>
|
|
|
|
#include <Columns/ColumnTuple.h>
|
2021-08-20 14:06:57 +00:00
|
|
|
#include <Functions/IFunction.h>
|
2022-03-12 18:05:50 +00:00
|
|
|
#include <Functions/FunctionHelpers.h>
|
|
|
|
#include <Interpreters/Context_fwd.h>
|
|
|
|
|
2021-08-20 14:06:57 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-08-20 21:14:26 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
|
|
|
}
|
|
|
|
|
2021-09-09 12:41:22 +00:00
|
|
|
class ITupleFunction : public IFunction
|
2021-08-20 14:06:57 +00:00
|
|
|
{
|
2021-08-25 14:02:04 +00:00
|
|
|
protected:
|
|
|
|
ContextPtr context;
|
|
|
|
|
2021-08-20 14:06:57 +00:00
|
|
|
public:
|
2021-09-09 12:41:22 +00:00
|
|
|
explicit ITupleFunction(ContextPtr context_) : context(context_) {}
|
2021-08-25 14:02:04 +00:00
|
|
|
|
2021-08-20 14:06:57 +00:00
|
|
|
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());
|
|
|
|
}
|
2021-08-25 14:02:04 +00:00
|
|
|
|
|
|
|
bool useDefaultImplementationForConstants() const override { return true; }
|
|
|
|
|
|
|
|
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
|
2021-08-20 14:06:57 +00:00
|
|
|
};
|
|
|
|
}
|