Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

[NSE-100]Fix an incorrect result error when using SHJ in Q45 #105

Merged
merged 2 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ case class ColumnarWholeStageCodegenExec(child: SparkPlan)(val codegenStageId: I
var idx = metrics.output_length_list.size - 1
var child_process_time: Long = 0
while (idx >= 0 && curChild.isInstanceOf[ColumnarCodegenSupport]) {
if (curChild.isInstanceOf[ColumnarConditionProjectExec]) {
// see if this condition projector did filter, if so, we need to skip metrics
val condProj = curChild.asInstanceOf[ColumnarConditionProjectExec]
if (condProj.condition != null && (condProj.projectList != null && condProj.projectList.size != 0)) {
idx -= 1
}
}
curChild
.asInstanceOf[ColumnarCodegenSupport]
.updateMetrics(
Expand Down
73 changes: 47 additions & 26 deletions cpp/src/codegen/arrow_compute/ext/expression_codegen_visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,11 @@ arrow::Status ExpressionCodegenVisitor::Visit(const gandiva::FunctionNode& node)
codes_str_ = "substr_" + std::to_string(cur_func_id);
check_str_ = GetValidityName(codes_str_);
std::stringstream prepare_ss;
prepare_ss << "auto " << codes_str_ << " = " << ss.str() << ";" << std::endl;
prepare_ss << "bool " << check_str_ << " = true;" << std::endl;
prepare_ss << "std::string " << codes_str_ << ";" << std::endl;
prepare_ss << "bool " << check_str_ << " = " << child_visitor_list[0]->GetPreCheck()
<< ";" << std::endl;
prepare_ss << "if (" << check_str_ << ")" << std::endl;
prepare_ss << codes_str_ << " = " << ss.str() << ";" << std::endl;
prepare_str_ += prepare_ss.str();
} else if (func_name.compare("upper") == 0) {
std::stringstream prepare_ss;
Expand Down Expand Up @@ -884,15 +887,21 @@ arrow::Status ExpressionCodegenVisitor::Visit(
}
prepare_ss << "};" << std::endl;

std::stringstream ss;
ss << child_visitor->GetPreCheck() << " && "
<< "std::find(in_list_" << cur_func_id << ".begin(), in_list_" << cur_func_id
<< ".end(), " << child_visitor->GetResult() << ") != "
<< "in_list_" << cur_func_id << ".end()";
codes_str_ = ss.str();
prepare_str_ = prepare_ss.str();
prepare_ss << child_visitor->GetPrepare();
codes_str_ = "is_in_list_" + std::to_string(cur_func_id);
check_str_ = GetValidityName(codes_str_);

prepare_ss << "bool " << check_str_ << " = " << child_visitor->GetPreCheck() << ";"
<< std::endl;
prepare_ss << "bool " << codes_str_ << " = false;" << std::endl;
prepare_ss << "if (" << check_str_ << ") " << std::endl;
prepare_ss << codes_str_ << " = std::find(in_list_" << cur_func_id
<< ".begin(), in_list_" << cur_func_id << ".end(), "
<< child_visitor->GetResult() << ") != "
<< "in_list_" << cur_func_id << ".end();";
prepare_str_ += prepare_ss.str();

field_type_ = child_visitor->GetFieldType();
prepare_str_ += child_visitor->GetPrepare();
for (auto header : child_visitor->GetHeaders()) {
if (std::find(header_list_.begin(), header_list_.end(), header) ==
header_list_.end()) {
Expand Down Expand Up @@ -924,15 +933,21 @@ arrow::Status ExpressionCodegenVisitor::Visit(
}
prepare_ss << "};" << std::endl;

std::stringstream ss;
ss << child_visitor->GetPreCheck() << " && "
<< "std::find(in_list_" << cur_func_id << ".begin(), in_list_" << cur_func_id
<< ".end(), " << child_visitor->GetResult() << ") != "
<< "in_list_" << cur_func_id << ".end()";
codes_str_ = ss.str();
prepare_str_ = prepare_ss.str();
prepare_ss << child_visitor->GetPrepare();
codes_str_ = "is_in_list_" + std::to_string(cur_func_id);
check_str_ = GetValidityName(codes_str_);

prepare_ss << "bool " << check_str_ << " = " << child_visitor->GetPreCheck() << ";"
<< std::endl;
prepare_ss << "bool " << codes_str_ << " = false;" << std::endl;
prepare_ss << "if (" << check_str_ << ") " << std::endl;
prepare_ss << codes_str_ << " = std::find(in_list_" << cur_func_id
<< ".begin(), in_list_" << cur_func_id << ".end(), "
<< child_visitor->GetResult() << ") != "
<< "in_list_" << cur_func_id << ".end();";
prepare_str_ += prepare_ss.str();

field_type_ = child_visitor->GetFieldType();
prepare_str_ += child_visitor->GetPrepare();
for (auto header : child_visitor->GetHeaders()) {
if (std::find(header_list_.begin(), header_list_.end(), header) ==
header_list_.end()) {
Expand Down Expand Up @@ -964,15 +979,21 @@ arrow::Status ExpressionCodegenVisitor::Visit(
}
prepare_ss << "};" << std::endl;

std::stringstream ss;
ss << child_visitor->GetPreCheck() << " && "
<< "std::find(in_list_" << cur_func_id << ".begin(), in_list_" << cur_func_id
<< ".end(), " << child_visitor->GetResult() << ") != "
<< "in_list_" << cur_func_id << ".end()";
codes_str_ = ss.str();
prepare_str_ = prepare_ss.str();
prepare_ss << child_visitor->GetPrepare();
codes_str_ = "is_in_list_" + std::to_string(cur_func_id);
check_str_ = GetValidityName(codes_str_);

prepare_ss << "bool " << check_str_ << " = " << child_visitor->GetPreCheck() << ";"
<< std::endl;
prepare_ss << "bool " << codes_str_ << " = false;" << std::endl;
prepare_ss << "if (" << check_str_ << ") " << std::endl;
prepare_ss << codes_str_ << " = std::find(in_list_" << cur_func_id
<< ".begin(), in_list_" << cur_func_id << ".end(), "
<< child_visitor->GetResult() << ") != "
<< "in_list_" << cur_func_id << ".end();";
prepare_str_ += prepare_ss.str();

field_type_ = child_visitor->GetFieldType();
prepare_str_ += child_visitor->GetPrepare();
for (auto header : child_visitor->GetHeaders()) {
if (std::find(header_list_.begin(), header_list_.end(), header) ==
header_list_.end()) {
Expand Down