This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 84f57398d9 [Improvement] set debug string for VExpressions (#10166)
84f57398d9 is described below
commit 84f57398d93ace306155224312ee610beaa4995d
Author: Gabriel <[email protected]>
AuthorDate: Tue Jun 21 07:43:25 2022 +0800
[Improvement] set debug string for VExpressions (#10166)
---
be/src/vec/exprs/vcase_expr.cpp | 16 ++++++++
be/src/vec/exprs/vcase_expr.h | 1 +
be/src/vec/exprs/vcast_expr.cpp | 17 ++++++++
be/src/vec/exprs/vcast_expr.h | 1 +
be/src/vec/exprs/vcompound_pred.h | 8 ++++
be/src/vec/exprs/vin_predicate.cpp | 13 ++++++
be/src/vec/exprs/vin_predicate.h | 2 +
be/src/vec/exprs/vliteral.cpp | 59 +++++++++++++++++++++++++++
be/src/vec/exprs/vliteral.h | 2 +
be/src/vec/exprs/vtuple_is_null_predicate.cpp | 17 ++++++++
be/src/vec/exprs/vtuple_is_null_predicate.h | 2 +
11 files changed, 138 insertions(+)
diff --git a/be/src/vec/exprs/vcase_expr.cpp b/be/src/vec/exprs/vcase_expr.cpp
index 2683e33bba..ba45fafa64 100644
--- a/be/src/vec/exprs/vcase_expr.cpp
+++ b/be/src/vec/exprs/vcase_expr.cpp
@@ -115,4 +115,20 @@ const std::string& VCaseExpr::expr_name() const {
return _expr_name;
}
+std::string VCaseExpr::debug_string() const {
+ std::stringstream out;
+ out << "CaseExpr(has_case_expr=" << _has_case_expr << " has_else_expr=" <<
_has_else_expr
+ << " function=" << _function_name << "){";
+ bool first = true;
+ for (VExpr* input_expr : children()) {
+ if (first) {
+ first = false;
+ } else {
+ out << ",";
+ }
+ out << input_expr->debug_string();
+ }
+ out << "}";
+ return out.str();
+}
} // namespace doris::vectorized
diff --git a/be/src/vec/exprs/vcase_expr.h b/be/src/vec/exprs/vcase_expr.h
index af6d74a2b0..a6ca9d6808 100644
--- a/be/src/vec/exprs/vcase_expr.h
+++ b/be/src/vec/exprs/vcase_expr.h
@@ -38,6 +38,7 @@ public:
return pool->add(new VCaseExpr(*this));
}
virtual const std::string& expr_name() const override;
+ virtual std::string debug_string() const override;
private:
bool _is_prepare;
diff --git a/be/src/vec/exprs/vcast_expr.cpp b/be/src/vec/exprs/vcast_expr.cpp
index 24fd9f566a..f268b12ec7 100644
--- a/be/src/vec/exprs/vcast_expr.cpp
+++ b/be/src/vec/exprs/vcast_expr.cpp
@@ -95,4 +95,21 @@ doris::Status VCastExpr::execute(VExprContext* context,
doris::vectorized::Block
const std::string& VCastExpr::expr_name() const {
return _expr_name;
}
+
+std::string VCastExpr::debug_string() const {
+ std::stringstream out;
+ out << "CastExpr(CAST " << _cast_param_data_type->get_name() << " to "
+ << _target_data_type->get_name() << "){";
+ bool first = true;
+ for (VExpr* input_expr : children()) {
+ if (first) {
+ first = false;
+ } else {
+ out << ",";
+ }
+ out << input_expr->debug_string();
+ }
+ out << "}";
+ return out.str();
+}
} // namespace doris::vectorized
\ No newline at end of file
diff --git a/be/src/vec/exprs/vcast_expr.h b/be/src/vec/exprs/vcast_expr.h
index 7f62a4c1de..9ac0dfe9db 100644
--- a/be/src/vec/exprs/vcast_expr.h
+++ b/be/src/vec/exprs/vcast_expr.h
@@ -36,6 +36,7 @@ public:
return pool->add(new VCastExpr(*this));
}
virtual const std::string& expr_name() const override;
+ virtual std::string debug_string() const override;
private:
FunctionBasePtr _function;
diff --git a/be/src/vec/exprs/vcompound_pred.h
b/be/src/vec/exprs/vcompound_pred.h
index 723e6013e0..94b7a7292b 100644
--- a/be/src/vec/exprs/vcompound_pred.h
+++ b/be/src/vec/exprs/vcompound_pred.h
@@ -38,5 +38,13 @@ public:
break;
}
}
+
+ virtual std::string debug_string() const override {
+ std::stringstream out;
+ out << "CompoundPredicate {(";
+ out << _children[0]->debug_string() << ") " << _fn.name.function_name
<< " (";
+ out << _children[1]->debug_string() << ")}";
+ return out.str();
+ }
};
} // namespace doris::vectorized
diff --git a/be/src/vec/exprs/vin_predicate.cpp
b/be/src/vec/exprs/vin_predicate.cpp
index ca21787ca9..b2fa7ed053 100644
--- a/be/src/vec/exprs/vin_predicate.cpp
+++ b/be/src/vec/exprs/vin_predicate.cpp
@@ -103,4 +103,17 @@ const std::string& VInPredicate::expr_name() const {
return _expr_name;
}
+std::string VInPredicate::debug_string() const {
+ std::stringstream out;
+ out << "InPredicate(" << children()[0]->debug_string() << " " <<
_is_not_in << ",[";
+ int num_children = children().size();
+
+ for (int i = 1; i < num_children; ++i) {
+ out << (i == 1 ? "" : " ") << children()[i]->debug_string();
+ }
+
+ out << "])";
+ return out.str();
+}
+
} // namespace doris::vectorized
\ No newline at end of file
diff --git a/be/src/vec/exprs/vin_predicate.h b/be/src/vec/exprs/vin_predicate.h
index 2a63827f7e..64cc9acefa 100644
--- a/be/src/vec/exprs/vin_predicate.h
+++ b/be/src/vec/exprs/vin_predicate.h
@@ -39,6 +39,8 @@ public:
}
virtual const std::string& expr_name() const override;
+ virtual std::string debug_string() const override;
+
private:
FunctionBasePtr _function;
std::string _expr_name;
diff --git a/be/src/vec/exprs/vliteral.cpp b/be/src/vec/exprs/vliteral.cpp
index 2edbf5519a..73f7f231fd 100644
--- a/be/src/vec/exprs/vliteral.cpp
+++ b/be/src/vec/exprs/vliteral.cpp
@@ -131,5 +131,64 @@ Status VLiteral::execute(VExprContext* context,
vectorized::Block* block, int* r
*result_column_id = VExpr::insert_param(block, {_column_ptr, _data_type,
_expr_name}, row_size);
return Status::OK();
}
+
+std::string VLiteral::debug_string() const {
+ std::stringstream out;
+ out << "VLiteral (type = " << _data_type->get_name();
+ out << ", value = ";
+ if (_column_ptr.get()->size() > 0) {
+ StringRef ref = _column_ptr.get()->get_data_at(0);
+ switch (_type.type) {
+ case TYPE_BOOLEAN:
+ case TYPE_TINYINT:
+ case TYPE_SMALLINT:
+ case TYPE_INT: {
+ out << *(reinterpret_cast<const int32_t*>(ref.data));
+ break;
+ }
+ case TYPE_BIGINT: {
+ out << *(reinterpret_cast<const int64_t*>(ref.data));
+ break;
+ }
+ case TYPE_LARGEINT: {
+ out << fmt::format("{}", *(reinterpret_cast<const
__int128_t*>(ref.data)));
+ break;
+ }
+ case TYPE_FLOAT: {
+ out << *(reinterpret_cast<const float*>(ref.data));
+ break;
+ }
+ case TYPE_TIME:
+ case TYPE_DOUBLE: {
+ out << *(reinterpret_cast<const double_t*>(ref.data));
+ break;
+ }
+ case TYPE_DATE:
+ case TYPE_DATETIME: {
+ auto value = *(reinterpret_cast<const int64_t*>(ref.data));
+ auto date_value = (VecDateTimeValue*)&value;
+ out << date_value;
+ break;
+ }
+ case TYPE_STRING:
+ case TYPE_CHAR:
+ case TYPE_VARCHAR: {
+ out << ref;
+ break;
+ }
+ case TYPE_DECIMALV2: {
+ DecimalV2Value value(*(reinterpret_cast<const
int128_t*>(ref.data)));
+ out << value;
+ break;
+ }
+ default: {
+ out << "UNKNOWN TYPE: " << int(_type.type);
+ break;
+ }
+ }
+ }
+ out << ")";
+ return out.str();
+}
} // namespace vectorized
} // namespace doris
diff --git a/be/src/vec/exprs/vliteral.h b/be/src/vec/exprs/vliteral.h
index b694ab565f..3a34ff397f 100644
--- a/be/src/vec/exprs/vliteral.h
+++ b/be/src/vec/exprs/vliteral.h
@@ -41,6 +41,8 @@ public:
return pool->add(new VLiteral(*this));
}
+ virtual std::string debug_string() const override;
+
protected:
ColumnPtr _column_ptr;
std::string _expr_name;
diff --git a/be/src/vec/exprs/vtuple_is_null_predicate.cpp
b/be/src/vec/exprs/vtuple_is_null_predicate.cpp
index ad339e4ff3..eb5679ec6f 100644
--- a/be/src/vec/exprs/vtuple_is_null_predicate.cpp
+++ b/be/src/vec/exprs/vtuple_is_null_predicate.cpp
@@ -83,4 +83,21 @@ const std::string& VTupleIsNullPredicate::expr_name() const {
return _expr_name;
}
+std::string VTupleIsNullPredicate::debug_string() const {
+ std::stringstream out;
+ out << "TupleIsNullPredicate(_column_to_check=[";
+
+ bool first = true;
+ for (int i = 0; i < _column_to_check.size(); ++i) {
+ if (first) {
+ out << _column_to_check[i];
+ first = false;
+ } else {
+ out << ", " << _column_to_check[i];
+ }
+ }
+ out << "])";
+ return out.str();
+}
+
} // namespace doris::vectorized
\ No newline at end of file
diff --git a/be/src/vec/exprs/vtuple_is_null_predicate.h
b/be/src/vec/exprs/vtuple_is_null_predicate.h
index c05693e393..3690b52898 100644
--- a/be/src/vec/exprs/vtuple_is_null_predicate.h
+++ b/be/src/vec/exprs/vtuple_is_null_predicate.h
@@ -37,6 +37,8 @@ public:
[[nodiscard]] const std::string& expr_name() const override;
+ virtual std::string debug_string() const override;
+
private:
std::string _expr_name;
std::vector<TupleId> _tuple_ids;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]