1 | #include <Functions/IFunctionImpl.h> |
---|---|
2 | #include <Functions/FunctionFactory.h> |
3 | #include <DataTypes/DataTypesNumber.h> |
4 | |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | /** ignore(...) is a function that takes any arguments, and always returns 0. |
10 | */ |
11 | class FunctionIgnore : public IFunction |
12 | { |
13 | public: |
14 | static constexpr auto name = "ignore"; |
15 | static FunctionPtr create(const Context &) |
16 | { |
17 | return std::make_shared<FunctionIgnore>(); |
18 | } |
19 | |
20 | bool isVariadic() const override |
21 | { |
22 | return true; |
23 | } |
24 | size_t getNumberOfArguments() const override |
25 | { |
26 | return 0; |
27 | } |
28 | |
29 | bool useDefaultImplementationForNulls() const override { return false; } |
30 | |
31 | String getName() const override |
32 | { |
33 | return name; |
34 | } |
35 | |
36 | DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override |
37 | { |
38 | return std::make_shared<DataTypeUInt8>(); |
39 | } |
40 | |
41 | void executeImpl(Block & block, const ColumnNumbers &, size_t result, size_t input_rows_count) override |
42 | { |
43 | block.getByPosition(result).column = DataTypeUInt8().createColumnConst(input_rows_count, 0u); |
44 | } |
45 | |
46 | ColumnPtr getResultIfAlwaysReturnsConstantAndHasArguments(const Block &, const ColumnNumbers &) const override |
47 | { |
48 | return DataTypeUInt8().createColumnConst(1, 0u); |
49 | } |
50 | }; |
51 | |
52 | |
53 | void registerFunctionIgnore(FunctionFactory & factory) |
54 | { |
55 | factory.registerFunction<FunctionIgnore>(); |
56 | } |
57 | |
58 | } |
59 |