taiyang-li commented on code in PR #8284:
URL: https://github.com/apache/incubator-gluten/pull/8284#discussion_r1897766396
##########
cpp-ch/local-engine/Parser/ExpressionParser.cpp:
##########
@@ -843,4 +868,88 @@ ExpressionParser::parseJsonTuple(const
substrait::Expression_ScalarFunction & fu
}
return res_nodes;
}
+
+bool ExpressionParser::areEqualNodes(NodeRawConstPtr a, NodeRawConstPtr b)
+{
+ if (a == b)
+ return true;
+
+ if (a->type != b->type || !a->result_type->equals(*(b->result_type)) ||
a->children.size() != b->children.size()
+ || !a->isDeterministic() || !b->isDeterministic())
+ return false;
+
+ switch (a->type)
+ {
+ case DB::ActionsDAG::ActionType::INPUT: {
+ if (a->result_name != b->result_name)
+ return false;
+ break;
+ }
+ case DB::ActionsDAG::ActionType::ALIAS: {
+ if (a->result_name != b->result_name)
+ return false;
+ break;
+ }
+ case DB::ActionsDAG::ActionType::COLUMN: {
+ // dummpy columns cannot be compared
+ if (typeid_cast<const DB::ColumnSet *>(a->column.get()))
+ return a->result_name == b->result_name;
+ if (a->column->compareAt(0, 0, *(b->column), 1) != 0)
+ return false;
+ break;
+ }
+ case DB::ActionsDAG::ActionType::ARRAY_JOIN: {
+ return false;
+ }
+ case DB::ActionsDAG::ActionType::FUNCTION: {
+ if (!a->function_base->isDeterministic() ||
a->function_base->getName() != b->function_base->getName())
+ return false;
+
+ break;
+ }
+ default: {
+ LOG_DEBUG(getLogger("ExpressionParser"), "Unknow node type:
{}|{}|{}", a->type, a->result_type->getName(), a->result_name);
+ return false;
+ }
+ }
+
+ for (size_t i = 0; i < a->children.size(); ++i)
+ if (!areEqualNodes(a->children[i], b->children[i]))
+ return false;
+ LOG_TRACE(
+ getLogger("ExpressionParser"),
+ "Nodes are equal:\ntype:{},data type:{},name:{}\ntype:{},data
type:{},name:{}",
+ a->type,
+ a->result_type->getName(),
+ a->result_name,
+ b->type,
+ b->result_type->getName(),
+ b->result_name);
+ return true;
+}
+
+// since each new node is added at the end of ActionsDAG::nodes, we expect to
find the previous node and the new node will be dropped later.
+ExpressionParser::NodeRawConstPtr
+ExpressionParser::findFirstStructureEqualNode(NodeRawConstPtr node_, const
DB::ActionsDAG & actions_dag) const
Review Comment:
maybe rename node_ to target is clearer
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]