Skip to content

Commit

Permalink
fix uts
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyang-li committed Jul 26, 2024
1 parent 5b41913 commit 8df6ee4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
15 changes: 14 additions & 1 deletion cpp-ch/local-engine/Common/CHUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,19 @@ const DB::ActionsDAG::Node * ActionsDAGUtil::convertNodeType(
DB::createInternalCastOverloadResolver(cast_type, std::move(diagnostic)), std::move(children), result_name);
}

const DB::ActionsDAG::Node * ActionsDAGUtil::convertNodeTypeIfNeeded(
DB::ActionsDAGPtr & actions_dag,
const DB::ActionsDAG::Node * node,
const DB::DataTypePtr & dst_type,
const std::string & result_name,
CastType cast_type)
{
if (node->result_type->equals(*dst_type))
return node;

return convertNodeType(actions_dag, node, dst_type->getName(), result_name, cast_type);
}

String QueryPipelineUtil::explainPipeline(DB::QueryPipeline & pipeline)
{
DB::WriteBufferFromOwnString buf;
Expand Down Expand Up @@ -844,7 +857,7 @@ void BackendInitializerUtil::initContexts(DB::Context::ConfigurationPtr config)
size_t index_uncompressed_cache_size = config->getUInt64("index_uncompressed_cache_size", DEFAULT_INDEX_UNCOMPRESSED_CACHE_MAX_SIZE);
double index_uncompressed_cache_size_ratio = config->getDouble("index_uncompressed_cache_size_ratio", DEFAULT_INDEX_UNCOMPRESSED_CACHE_SIZE_RATIO);
global_context->setIndexUncompressedCache(index_uncompressed_cache_policy, index_uncompressed_cache_size, index_uncompressed_cache_size_ratio);

String index_mark_cache_policy = config->getString("index_mark_cache_policy", DEFAULT_INDEX_MARK_CACHE_POLICY);
size_t index_mark_cache_size = config->getUInt64("index_mark_cache_size", DEFAULT_INDEX_MARK_CACHE_MAX_SIZE);
double index_mark_cache_size_ratio = config->getDouble("index_mark_cache_size_ratio", DEFAULT_INDEX_MARK_CACHE_SIZE_RATIO);
Expand Down
7 changes: 7 additions & 0 deletions cpp-ch/local-engine/Common/CHUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ class ActionsDAGUtil
const std::string & type_name,
const std::string & result_name = "",
DB::CastType cast_type = DB::CastType::nonAccurate);

static const DB::ActionsDAG::Node * convertNodeTypeIfNeeded(
DB::ActionsDAGPtr & actions_dag,
const DB::ActionsDAG::Node * node,
const DB::DataTypePtr & dst_type,
const std::string & result_name = "",
DB::CastType cast_type = DB::CastType::nonAccurate);
};

class QueryPipelineUtil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ class ArrayTransform : public FunctionParser
/// U is the argument type of lambda function. In some cases Array(T) is not equal to Array(U).
/// e.g. in the second query of https://github.com/apache/incubator-gluten/issues/6561, T is String, and U is Nullable(String)
/// The difference of both types will result in runtime exceptions in function capture.
auto dst_array_type = std::make_shared<DataTypeArray>(lambda_args.front().type);
const auto * dst_array_arg = ActionsDAGUtil::convertNodeType(actions_dag, parsed_args[0], dst_array_type->getName());
std::cout << "actions_dag:" << actions_dag->dumpDAG() << std::endl;
const auto & src_array_type = parsed_args[0]->result_type;
DataTypePtr dst_array_type = std::make_shared<DataTypeArray>(lambda_args.front().type);
if (isNullableOrLowCardinalityNullable(src_array_type))
dst_array_type = std::make_shared<DataTypeNullable>(dst_array_type);
const auto * dst_array_arg = ActionsDAGUtil::convertNodeTypeIfNeeded(actions_dag, parsed_args[0], dst_array_type);
return toFunctionNode(actions_dag, ch_func_name, {parsed_args[1], dst_array_arg});
}

Expand Down

0 comments on commit 8df6ee4

Please sign in to comment.