Skip to content

Commit

Permalink
fix ci error
Browse files Browse the repository at this point in the history
  • Loading branch information
loneylee committed Dec 6, 2023
1 parent e20d4e8 commit 4ca8998
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
15 changes: 7 additions & 8 deletions cpp-ch/local-engine/Common/CHUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <DataTypes/DataTypeTuple.h>
#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/NestedUtils.h>
#include <Functions/CastOverloadResolver.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionsConversion.h>
#include <Functions/registerFunctions.h>
Expand Down Expand Up @@ -390,7 +389,11 @@ const DB::ColumnWithTypeAndName * NestedColumnExtractHelper::findColumn(const DB
}

const DB::ActionsDAG::Node * ActionsDAGUtil::convertNodeType(
DB::ActionsDAGPtr & actions_dag, const DB::ActionsDAG::Node * node, const std::string & type_name, const std::string & result_name)
DB::ActionsDAGPtr & actions_dag,
const DB::ActionsDAG::Node * node,
const std::string & type_name,
const std::string & result_name,
CastType cast_type)
{
DB::ColumnWithTypeAndName type_name_col;
type_name_col.name = type_name;
Expand All @@ -399,13 +402,9 @@ const DB::ActionsDAG::Node * ActionsDAGUtil::convertNodeType(
const auto * right_arg = &actions_dag->addColumn(std::move(type_name_col));
const auto * left_arg = node;
DB::CastDiagnostic diagnostic = {node->result_name, node->result_name};
auto type = CastType::nonAccurate;

if (startsWith(type_name, "Nullable"))
type = CastType::accurateOrNull;

DB::ActionsDAG::NodeRawConstPtrs children = {left_arg, right_arg};
return &actions_dag->addFunction(DB::createInternalCastOverloadResolver(type, std::move(diagnostic)), std::move(children), result_name);
return &actions_dag->addFunction(
DB::createInternalCastOverloadResolver(cast_type, std::move(diagnostic)), std::move(children), result_name);
}

String QueryPipelineUtil::explainPipeline(DB::QueryPipeline & pipeline)
Expand Down
4 changes: 3 additions & 1 deletion cpp-ch/local-engine/Common/CHUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <Core/ColumnWithTypeAndName.h>
#include <Core/NamesAndTypes.h>
#include <DataTypes/Serializations/ISerialization.h>
#include <Functions/CastOverloadResolver.h>
#include <Interpreters/ActionsDAG.h>
#include <Interpreters/Context.h>
#include <Processors/Chunk.h>
Expand Down Expand Up @@ -99,7 +100,8 @@ class ActionsDAGUtil
DB::ActionsDAGPtr & actions_dag,
const DB::ActionsDAG::Node * node,
const std::string & type_name,
const std::string & result_name = "");
const std::string & result_name = "",
DB::CastType cast_type = DB::CastType::nonAccurate);
};

class QueryPipelineUtil
Expand Down
30 changes: 22 additions & 8 deletions cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,14 +1038,28 @@ const ActionsDAG::Node * SerializedPlanParser::parseFunctionWithDAG(

if (!TypeParser::isTypeMatched(rel.scalar_function().output_type(), function_node->result_type) && !converted_decimal_args)
{
result_node = ActionsDAGUtil::convertNodeType(
actions_dag,
function_node,
// as stated in isTypeMatched, currently we don't change nullability of the result type
function_node->result_type->isNullable()
? local_engine::wrapNullableType(true, TypeParser::parseType(rel.scalar_function().output_type()))->getName()
: local_engine::removeNullable(TypeParser::parseType(rel.scalar_function().output_type()))->getName(),
function_node->result_name);
auto result_type = TypeParser::parseType(rel.scalar_function().output_type());
if (isDecimalOrNullableDecimal(result_type))
{
result_node = ActionsDAGUtil::convertNodeType(
actions_dag,
function_node,
// as stated in isTypeMatched, currently we don't change nullability of the result type
function_node->result_type->isNullable() ? local_engine::wrapNullableType(true, result_type)->getName()
: local_engine::removeNullable(result_type)->getName(),
function_node->result_name,
DB::CastType::accurateOrNull);
}
else
{
result_node = ActionsDAGUtil::convertNodeType(
actions_dag,
function_node,
// as stated in isTypeMatched, currently we don't change nullability of the result type
function_node->result_type->isNullable() ? local_engine::wrapNullableType(true, result_type)->getName()
: local_engine::removeNullable(result_type)->getName(),
function_node->result_name);
}
}

if (ch_func_name == "JSON_VALUE")
Expand Down

0 comments on commit 4ca8998

Please sign in to comment.