Skip to content

Commit

Permalink
[GLUTEN-7795][CH] Remove duplicate log object (#7839)
Browse files Browse the repository at this point in the history
  • Loading branch information
loneylee authored Nov 7, 2024
1 parent 27ab77c commit c653337
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
9 changes: 5 additions & 4 deletions cpp-ch/local-engine/Common/DebugUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <google/protobuf/util/json_util.h>
#include <google/protobuf/wrappers.pb.h>
#include <Common/CHUtil.h>
#include <Common/QueryContext.h>
#include <Common/logger_useful.h>

namespace pb_util = google::protobuf::util;
Expand All @@ -51,9 +52,9 @@ void dumpPlan(DB::QueryPlan & plan, bool force, LoggerPtr logger)

auto out = local_engine::PlanUtil::explainPlan(plan);
if (force) // force
LOG_ERROR(logger, "clickhouse plan:\n{}", out);
LOG_ERROR(logger, "clickhouse plan({}):\n{}", local_engine::QueryContext::instance().currentTaskIdOrEmpty(), out);
else
LOG_DEBUG(logger, "clickhouse plan:\n{}", out);
LOG_DEBUG(logger, "clickhouse plan({}):\n{}", local_engine::QueryContext::instance().currentTaskIdOrEmpty(), out);
}

void dumpMessage(const google::protobuf::Message & message, const char * type, bool force, LoggerPtr logger)
Expand All @@ -73,9 +74,9 @@ void dumpMessage(const google::protobuf::Message & message, const char * type, b
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Can not convert {} to Json", type);

if (force) // force
LOG_ERROR(logger, "{}:\n{}", type, json);
LOG_ERROR(logger, "{}({}):\n{}", type, local_engine::QueryContext::instance().currentTaskIdOrEmpty(), json);
else
LOG_DEBUG(logger, "{}:\n{}", type, json);
LOG_DEBUG(logger, "{}({}):\n{}", type, local_engine::QueryContext::instance().currentTaskIdOrEmpty(), json);
}

void headBlock(const DB::Block & block, size_t count)
Expand Down
20 changes: 9 additions & 11 deletions cpp-ch/local-engine/Parser/SerializedPlanParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
#include <Common/Exception.h>
#include <Common/GlutenConfig.h>
#include <Common/JNIUtils.h>
#include <Common/QueryContext.h>
#include <Common/logger_useful.h>
#include <Common/typeid_cast.h>

Expand Down Expand Up @@ -111,8 +110,8 @@ void SerializedPlanParser::adjustOutput(const DB::QueryPlanPtr & query_plan, con
const auto cols = query_plan->getCurrentHeader().getNamesAndTypesList();
if (cols.getNames().size() != static_cast<size_t>(root_rel.root().names_size()))
{
debug::dumpPlan(*query_plan, true, log);
debug::dumpMessage(root_rel, "substrait::PlanRel", true, log);
debug::dumpPlan(*query_plan, true);
debug::dumpMessage(root_rel, "substrait::PlanRel", true);
throw Exception(
ErrorCodes::LOGICAL_ERROR,
"Missmatch result columns size. plan column size {}, subtrait plan name size {}.",
Expand All @@ -135,8 +134,8 @@ void SerializedPlanParser::adjustOutput(const DB::QueryPlanPtr & query_plan, con
const auto & original_cols = original_header.getColumnsWithTypeAndName();
if (static_cast<size_t>(output_schema.types_size()) != original_cols.size())
{
debug::dumpPlan(*query_plan, true, log);
debug::dumpMessage(root_rel, "substrait::PlanRel", true, log);
debug::dumpPlan(*query_plan, true);
debug::dumpMessage(root_rel, "substrait::PlanRel", true);
throw Exception(
ErrorCodes::LOGICAL_ERROR,
"Missmatch result columns size. plan column size {}, subtrait plan output schema size {}, subtrait plan name size {}.",
Expand Down Expand Up @@ -184,7 +183,7 @@ void SerializedPlanParser::adjustOutput(const DB::QueryPlanPtr & query_plan, con

QueryPlanPtr SerializedPlanParser::parse(const substrait::Plan & plan)
{
debug::dumpMessage(plan, "substrait::Plan", false, log);
debug::dumpMessage(plan, "substrait::Plan");
//parseExtensions(plan.extensions());
if (plan.relations_size() != 1)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "too many relations found");
Expand All @@ -205,7 +204,7 @@ QueryPlanPtr SerializedPlanParser::parse(const substrait::Plan & plan)
PlanUtil::checkOuputType(*query_plan);
#endif

debug::dumpPlan(*query_plan, false, log);
debug::dumpPlan(*query_plan);
return query_plan;
}

Expand Down Expand Up @@ -324,7 +323,7 @@ std::unique_ptr<LocalExecutor> SerializedPlanParser::createExecutor(DB::QueryPla
}
catch (...)
{
LOG_ERROR(log, "Invalid plan:\n{}", PlanUtil::explainPlan(*query_plan));
LOG_ERROR(getLogger("SerializedPlanParser"), "Invalid plan:\n{}", PlanUtil::explainPlan(*query_plan));
throw;
}

Expand All @@ -333,9 +332,9 @@ std::unique_ptr<LocalExecutor> SerializedPlanParser::createExecutor(DB::QueryPla
assert(root_rel.has_root());
if (root_rel.root().input().has_write())
addSinkTransform(parser_context->queryContext(), root_rel.root().input().write(), builder);
LOG_INFO(log, "build pipeline {} ms", stopwatch.elapsedMicroseconds() / 1000.0);
LOG_INFO(getLogger("SerializedPlanParser"), "build pipeline {} ms", stopwatch.elapsedMicroseconds() / 1000.0);
LOG_DEBUG(
log,
getLogger("SerializedPlanParser"),
"clickhouse plan [optimization={}]:\n{}",
settings[Setting::query_plan_enable_optimizations],
PlanUtil::explainPlan(*query_plan));
Expand All @@ -347,7 +346,6 @@ std::unique_ptr<LocalExecutor> SerializedPlanParser::createExecutor(DB::QueryPla
SerializedPlanParser::SerializedPlanParser(ParserContextPtr parser_context_) : parser_context(parser_context_)
{
context = parser_context->queryContext();
log = getLogger("SerializedPlanParser(" + QueryContext::instance().currentTaskIdOrEmpty() + ")");
}

NonNullableColumnsResolver::NonNullableColumnsResolver(
Expand Down
1 change: 0 additions & 1 deletion cpp-ch/local-engine/Parser/SerializedPlanParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class SerializedPlanParser
DB::QueryPlanPtr parseOp(const substrait::Rel & rel, std::list<const substrait::Rel *> & rel_stack);
void adjustOutput(const DB::QueryPlanPtr & query_plan, const substrait::PlanRel & root_rel) const;

LoggerPtr log;
std::vector<jobject> input_iters;
std::vector<std::string> split_infos;
int split_info_index = 0;
Expand Down

0 comments on commit c653337

Please sign in to comment.