Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Nov 27, 2023
1 parent 4d6d4af commit 0c29e7c
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,21 +322,24 @@ private double skewPenalty(PhysicalHashJoin<? extends Plan, ? extends Plan> phys
int totalInstanceNumber) {
double penalty = 1.0;
for (Expression conj : physicalHashJoin.getHashJoinConjuncts()) {
EqualTo eq = (EqualTo) JoinUtils.swapEqualToForChildrenOrder(
(EqualTo) conj, physicalHashJoin.left().getOutputSet());
ColumnStatistic leftColStats = probeStats.findColumnStatistics(eq.left());
if (leftColStats != null && !leftColStats.isUnKnown()) {
if (leftColStats.ndv < beNumber) {
penalty = Math.max(totalInstanceNumber / Math.max(1.0, leftColStats.ndv), penalty);
break;
// TODO: NullSafeEqualTo need refactor
if (conj instanceof EqualTo) {
EqualTo eq = (EqualTo) JoinUtils.swapEqualToForChildrenOrder(
(EqualTo) conj, physicalHashJoin.left().getOutputSet());
ColumnStatistic leftColStats = probeStats.findColumnStatistics(eq.left());
if (leftColStats != null && !leftColStats.isUnKnown()) {
if (leftColStats.ndv < beNumber) {
penalty = Math.max(totalInstanceNumber / Math.max(1.0, leftColStats.ndv), penalty);
break;
}
}
}

ColumnStatistic rightColStats = buildStats.findColumnStatistics(eq.right());
if (rightColStats != null && !rightColStats.isUnKnown()) {
if (rightColStats.ndv < beNumber) {
penalty = Math.max(totalInstanceNumber / Math.max(1.0, rightColStats.ndv), penalty);
break;
ColumnStatistic rightColStats = buildStats.findColumnStatistics(eq.right());
if (rightColStats != null && !rightColStats.isUnKnown()) {
if (rightColStats.ndv < beNumber) {
penalty = Math.max(totalInstanceNumber / Math.max(1.0, rightColStats.ndv), penalty);
break;
}
}
}
}
Expand Down

0 comments on commit 0c29e7c

Please sign in to comment.