New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Null-safe equal operator from cross join to hash join #2156
Conversation
be/src/exec/hash_table.cpp
Outdated
@@ -42,12 +42,18 @@ const char* HashTable::_s_llvm_class_name = "class.doris::HashTable"; | |||
|
|||
HashTable::HashTable(const vector<ExprContext*>& build_expr_ctxs, | |||
const vector<ExprContext*>& probe_expr_ctxs, | |||
int num_build_tuples, bool stores_nulls, int32_t initial_seed, | |||
int num_build_tuples, bool null_preserved, | |||
const std::vector<bool> finds_nulls, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const std::vector<bool> finds_nulls, | |
const std::vector<bool>& finds_nulls, |
be/src/exec/hash_table.h
Outdated
@@ -98,7 +98,9 @@ class HashTable { | |||
HashTable( | |||
const std::vector<ExprContext*>& build_exprs, | |||
const std::vector<ExprContext*>& probe_exprs, | |||
int num_build_tuples, bool stores_nulls, int32_t initial_seed, | |||
int num_build_tuples, bool stores_nulls, | |||
const std::vector<bool> finds_nulls, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const std::vector<bool> finds_nulls, | |
const std::vector<bool>& finds_nulls, |
be/src/exec/olap_scan_node.cpp
Outdated
@@ -194,8 +194,10 @@ Status OlapScanNode::open(RuntimeState* state) { | |||
RETURN_IF_CANCELLED(state); | |||
RETURN_IF_ERROR(ExecNode::open(state)); | |||
|
|||
LOG(INFO) << "olap scan node conjunct in open " << Expr::debug_string(_conjunct_ctxs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be VLOG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove it.
@@ -53,8 +54,8 @@ | |||
|
|||
private final TableRef innerRef; | |||
private final JoinOperator joinOp; | |||
// conjuncts of the form "<lhs> = <rhs>", recorded as Pair(<lhs>, <rhs>) | |||
private List<Pair<Expr, Expr>> eqJoinConjuncts; | |||
// predicates of the form "<lhs> = <rhs>", recorded as Pair(<lhs>, <rhs>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you change conjuncts to predicates?
Better to keep it conjuncts, becuase it means and
and same with otherJoinConjuncts
be/src/exec/hash_table.h
Outdated
// the row in hash table is preserved such as RIGHT_OUTER_JOIN | ||
const bool _null_preserved; | ||
// true: the null value should be keep in | ||
// false: the null value should be filter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what keep in means? and what filter means?
@@ -384,13 +384,13 @@ private PlanFragment createHashJoinFragment(HashJoinNode node, PlanFragment righ | |||
// TODO: create equivalence classes based on equality predicates | |||
|
|||
// first, extract join exprs | |||
List<Pair<Expr, Expr>> eqJoinConjuncts = node.getEqJoinConjuncts(); | |||
List<BinaryPredicate> eqJoinPredicates = node.getEqJoinConjuncts(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
ISSUE-2136 This commit change the join method from cross join to hash join when the equal operator is Null-safe '<=>'. It will improve the speed of query which has the Null-safe equal operator. The finds_nulls field is used to save if there is Null-safe operator. The finds_nulls[i] is true means that the i-th equal operator is Null-safe. The equal function in hash table will return true, if both val and loc are NULL when finds_nulls[i] is true.
4d477ea
to
b88d542
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…2156) * Change Null-safe equal operator from cross join to hash join ISSUE-2136 This commit change the join method from cross join to hash join when the equal operator is Null-safe '<=>'. It will improve the speed of query which has the Null-safe equal operator. The finds_nulls field is used to save if there is Null-safe operator. The finds_nulls[i] is true means that the i-th equal operator is Null-safe. The equal function in hash table will return true, if both val and loc are NULL when finds_nulls[i] is true.
ISSUE-2136
This commit change the join method from cross join to hash join when the equal operator is Null-safe '<=>'.
It will improve the speed of query which has the Null-safe equal operator.
The finds_nulls field is used to save if there is Null-safe operator.
The finds_nulls[i] is true means that the i-th equal operator is Null-safe.
The equal function in hash table will return true, if both val and loc are NULL when finds_nulls[i] is true.