2018-02-06 19:34:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-10-04 17:46:36 +00:00
|
|
|
#include <Core/Field.h>
|
2018-02-06 19:34:53 +00:00
|
|
|
#include <Core/NamesAndTypes.h>
|
2018-02-14 17:27:14 +00:00
|
|
|
#include <Core/ColumnsWithTypeAndName.h>
|
2018-02-06 19:34:53 +00:00
|
|
|
#include <Columns/IColumn.h>
|
|
|
|
|
|
|
|
class IFunctionBase;
|
|
|
|
using FunctionBasePtr = std::shared_ptr<IFunctionBase>;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-02-25 18:10:48 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int NOT_IMPLEMENTED;
|
|
|
|
}
|
2018-02-06 19:34:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** A column containing a lambda expression.
|
|
|
|
* Behaves like a constant-column. Contains an expression, but not input or output data.
|
|
|
|
*/
|
2019-04-19 20:21:17 +00:00
|
|
|
class ColumnFunction final : public COWHelper<IColumn, ColumnFunction>
|
2018-02-06 19:34:53 +00:00
|
|
|
{
|
|
|
|
private:
|
2019-04-19 20:21:17 +00:00
|
|
|
friend class COWHelper<IColumn, ColumnFunction>;
|
2018-02-06 19:34:53 +00:00
|
|
|
|
2019-08-03 11:02:40 +00:00
|
|
|
ColumnFunction(size_t size, FunctionBasePtr function_, const ColumnsWithTypeAndName & columns_to_capture);
|
2018-02-06 19:34:53 +00:00
|
|
|
|
2018-02-09 19:02:37 +00:00
|
|
|
public:
|
2018-02-06 19:34:53 +00:00
|
|
|
const char * getFamilyName() const override { return "Function"; }
|
|
|
|
|
|
|
|
MutableColumnPtr cloneResized(size_t size) const override;
|
|
|
|
|
|
|
|
size_t size() const override { return size_; }
|
|
|
|
|
2018-03-20 14:17:09 +00:00
|
|
|
ColumnPtr cut(size_t start, size_t length) const override;
|
|
|
|
ColumnPtr replicate(const Offsets & offsets) const override;
|
|
|
|
ColumnPtr filter(const Filter & filt, ssize_t result_size_hint) const override;
|
2019-02-18 19:44:26 +00:00
|
|
|
ColumnPtr permute(const Permutation & perm, size_t limit) const override;
|
2019-02-18 17:28:53 +00:00
|
|
|
ColumnPtr index(const IColumn & indexes, size_t limit) const override;
|
2019-03-29 13:46:36 +00:00
|
|
|
|
2018-02-06 19:34:53 +00:00
|
|
|
std::vector<MutableColumnPtr> scatter(IColumn::ColumnIndex num_columns,
|
|
|
|
const IColumn::Selector & selector) const override;
|
|
|
|
|
|
|
|
void getExtremes(Field &, Field &) const override {}
|
|
|
|
|
|
|
|
size_t byteSize() const override;
|
|
|
|
size_t allocatedBytes() const override;
|
|
|
|
|
|
|
|
void appendArguments(const ColumnsWithTypeAndName & columns);
|
|
|
|
ColumnWithTypeAndName reduce() const;
|
|
|
|
|
|
|
|
Field operator[](size_t) const override
|
|
|
|
{
|
|
|
|
throw Exception("Cannot get value from " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void get(size_t, Field &) const override
|
|
|
|
{
|
|
|
|
throw Exception("Cannot get value from " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef getDataAt(size_t) const override
|
|
|
|
{
|
|
|
|
throw Exception("Cannot get value from " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void insert(const Field &) override
|
|
|
|
{
|
2019-03-29 13:46:36 +00:00
|
|
|
throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void insertDefault() override
|
|
|
|
{
|
|
|
|
throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
2018-02-06 19:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void insertRangeFrom(const IColumn &, size_t, size_t) override
|
|
|
|
{
|
|
|
|
throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void insertData(const char *, size_t) override
|
|
|
|
{
|
|
|
|
throw Exception("Cannot insert into " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef serializeValueIntoArena(size_t, Arena &, char const *&) const override
|
|
|
|
{
|
|
|
|
throw Exception("Cannot serialize from " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * deserializeAndInsertFromArena(const char *) override
|
|
|
|
{
|
|
|
|
throw Exception("Cannot deserialize to " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void updateHashWithValue(size_t, SipHash &) const override
|
|
|
|
{
|
|
|
|
throw Exception("updateHashWithValue is not implemented for " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
2020-03-18 16:03:55 +00:00
|
|
|
void updateWeakHash32(WeakHash32 &) const override
|
|
|
|
{
|
|
|
|
throw Exception("updateWeakHash32 is not implemented for " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
2019-03-29 13:46:36 +00:00
|
|
|
void popBack(size_t) override
|
|
|
|
{
|
|
|
|
throw Exception("popBack is not implemented for " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
2018-02-06 19:34:53 +00:00
|
|
|
int compareAt(size_t, size_t, const IColumn &, int) const override
|
|
|
|
{
|
|
|
|
throw Exception("compareAt is not implemented for " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void getPermutation(bool, size_t, int, Permutation &) const override
|
|
|
|
{
|
|
|
|
throw Exception("getPermutation is not implemented for " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gather(ColumnGathererStream &) override
|
|
|
|
{
|
|
|
|
throw Exception("Method gather is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
size_t size_;
|
|
|
|
FunctionBasePtr function;
|
2019-03-29 16:42:26 +00:00
|
|
|
ColumnsWithTypeAndName captured_columns;
|
2018-02-06 19:34:53 +00:00
|
|
|
|
|
|
|
void appendArgument(const ColumnWithTypeAndName & column);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|