Skip to content

Commit

Permalink
CI fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinyhZou committed Dec 12, 2023
1 parent f003a17 commit 9c2fbb4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
5 changes: 4 additions & 1 deletion cpp-ch/local-engine/Parser/scalar_function_parser/ln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class FunctionParserLn : public FunctionParserLogBase

String getName() const override { return name; }
String getCHFunctionName() const override { return "log"; }
DB::Float64 getParameterLowerBoundValue() const override { return 0.0; }
const DB::ActionsDAG::Node * getParameterLowerBound(ActionsDAGPtr & actions_dag, const DataTypePtr & data_type) const override
{
return addColumnToActionsDAG(actions_dag, data_type, 0.0);
}
};

static FunctionParserRegister<FunctionParserLn> register_ln;
Expand Down
5 changes: 4 additions & 1 deletion cpp-ch/local-engine/Parser/scalar_function_parser/log10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class FunctionParserLog10 : public FunctionParserLogBase

String getName() const override { return name; }
String getCHFunctionName() const override { return "log10"; }
DB::Float64 getParameterLowerBoundValue() const override { return 0.0; }
const DB::ActionsDAG::Node * getParameterLowerBound(ActionsDAGPtr & actions_dag, const DataTypePtr & data_type) const override
{
return addColumnToActionsDAG(actions_dag, data_type, 0.0);
}
};

static FunctionParserRegister<FunctionParserLog10> register_log10;
Expand Down
5 changes: 4 additions & 1 deletion cpp-ch/local-engine/Parser/scalar_function_parser/log1p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class FunctionParserLog1p : public FunctionParserLogBase

String getName() const override { return name; }
String getCHFunctionName() const override { return "log1p"; }
DB::Float64 getParameterLowerBoundValue() const override { return -1.0; }
const DB::ActionsDAG::Node * getParameterLowerBound(ActionsDAGPtr & actions_dag, const DataTypePtr & data_type) const override
{
return addColumnToActionsDAG(actions_dag, data_type, -1.0);
}
};

static FunctionParserRegister<FunctionParserLog1p> register_log1p;
Expand Down
5 changes: 4 additions & 1 deletion cpp-ch/local-engine/Parser/scalar_function_parser/log2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class FunctionParserLog2 : public FunctionParserLogBase

String getName() const override { return name; }
String getCHFunctionName() const override { return "log2"; }
DB::Float64 getParameterLowerBoundValue() const override { return 0.0; }
const DB::ActionsDAG::Node * getParameterLowerBound(ActionsDAGPtr & actions_dag, const DataTypePtr & data_type) const override
{
return addColumnToActionsDAG(actions_dag, data_type, 0.0);
}
};

static FunctionParserRegister<FunctionParserLog2> register_log2;
Expand Down
14 changes: 8 additions & 6 deletions cpp-ch/local-engine/Parser/scalar_function_parser/logarithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,20 @@ namespace DB
namespace ErrorCodes
{
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
extern const int NOT_IMPLEMENTED;
}
}

namespace local_engine
{
template<typename FirstParameterDataType>
class FunctionParserLogBase : public FunctionParser
{
public:
explicit FunctionParserLogBase(SerializedPlanParser * plan_parser_) : FunctionParser(plan_parser_) {}
~FunctionParserLogBase() override = default;

virtual Number getParameterLowerBoundValue() const { return 0.0; }
virtual DB::String getCHFunctionName() const { return "log" };
virtual DB::String getCHFunctionName() const { return "log"; }
virtual const DB::ActionsDAG::Node * getParameterLowerBound(ActionsDAGPtr &, const DataTypePtr &) const { return nullptr; }

const ActionsDAG::Node * parse(
const substrait::Expression_ScalarFunction & substrait_func,
Expand All @@ -64,8 +63,11 @@ class FunctionParserLogBase : public FunctionParser
auto nullable_result_type = makeNullable(log_node->result_type);

const auto * null_const_node = addColumnToActionsDAG(actions_dag, nullable_result_type, Field());
const Number lowerBound = getParameterLowerBoundValue();
const auto * le_node = toFunctionNode(actions_dag, "lessOrEquals", {arg_node, addColumnToActionsDAG(actions_dag, result_type, lowerBound)});
const auto * lower_bound_node = getParameterLowerBound(actions_dag, arg_node->result_type);
if (!lower_bound_node)
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Vritual function {} may not implement for {}", "getParameterLowerBound", getName());

const auto * le_node = toFunctionNode(actions_dag, "lessOrEquals", {arg_node, lower_bound_node});
const auto * result_node = toFunctionNode(actions_dag, "if", {le_node, null_const_node, log_node});

return convertNodeTypeIfNeeded(substrait_func, result_node, actions_dag);
Expand Down

0 comments on commit 9c2fbb4

Please sign in to comment.