Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lgbo-ustc committed Dec 26, 2024
1 parent 4068fbd commit da19d03
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -863,12 +863,15 @@ class GlutenFunctionValidateSuite extends GlutenClickHouseWholeStageTransformerS

test("Test transform_keys/transform_values") {
val sql = """
|select id, sort_array(map_entries(m1)), sort_array(map_entries(m2)) from(
|select
| id,
| transform_keys(map_from_arrays(array(id+1, id+2, id+3),
| array(1, id+2, 3)), (k, v) -> k + 1),
| array(1, id+2, 3)), (k, v) -> k + 1) as m1,
| transform_values(map_from_arrays(array(id+1, id+2, id+3),
| array(1, id+2, 3)), (k, v) -> v + 1)
| array(1, id+2, 3)), (k, v) -> v + 1) as m2
|from range(10)
|) order by id
|""".stripMargin
compareResultsAgainstVanillaSpark(sql, true, { _ => })
}
Expand Down
26 changes: 25 additions & 1 deletion cpp-ch/local-engine/Parser/ExpressionParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,11 @@ ExpressionParser::parseJsonTuple(const substrait::Expression_ScalarFunction & fu

bool ExpressionParser::areEqualNodes(const DB::ActionsDAG::Node * a, const ActionsDAG::Node * b)
{
if (a->type != b->type || !a->result_type->equals(*(b->result_type)) || a->children.size() != b->children.size())
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)
Expand Down Expand Up @@ -908,6 +912,15 @@ bool ExpressionParser::areEqualNodes(const DB::ActionsDAG::Node * a, const Actio
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;
}

Expand All @@ -920,7 +933,18 @@ ExpressionParser::findOneStructureEqualNode(const DB::ActionsDAG::Node * node_,
if (node_ == &node)
continue;
if (areEqualNodes(node_, &node))
{
LOG_TRACE(
getLogger("ExpressionParser"),
"Two nodes are equal:\ntype:{},data type:{},name:{}\ntype:{},data type:{},name:{}",
node_->type,
node_->result_type->getName(),
node_->result_name,
node.type,
node.result_type->getName(),
node.result_name);
return &node;
}
}
return nullptr;
}
Expand Down

0 comments on commit da19d03

Please sign in to comment.