Skip to content

Commit

Permalink
fix(interactive): Fix Bugs of Count Estimation When Feasible Plan Is …
Browse files Browse the repository at this point in the history
…Unavailable in Equivalent Set (#4181)
  • Loading branch information
shirly121 authored Sep 3, 2024
1 parent 2d3268e commit 73c1f6c
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,19 @@ public Double getRowCount(RelNode node, RelMetadataQuery mq) {
}
}
}
throw new UnsupportedOperationException(
"estimate count for pattern " + pattern + " is unsupported yet");
double totalRowCount = 1.0d;
for (PatternEdge edge : pattern.getEdgeSet()) {
totalRowCount *= countEstimator.estimate(edge);
}
for (PatternVertex vertex : pattern.getVertexSet()) {
int degree = pattern.getEdgesOf(vertex).size();
if (degree > 0) {
double vertexCount = countEstimator.estimate(vertex);
vertexCount = Double.compare(vertexCount, 0.0d) == 0 ? 1.0d : vertexCount;
totalRowCount /= Math.pow(vertexCount, degree - 1);
}
}
return totalRowCount;
} else if (node instanceof TableScan) {
return getRowCount((TableScan) node, mq);
} else if (node instanceof Filter) {
Expand All @@ -131,6 +142,12 @@ public Double getRowCount(RelNode node, RelMetadataQuery mq) {
return mq.getRowCount(subset);
}
}
Pattern original =
(node instanceof GraphExtendIntersect)
? ((GraphExtendIntersect) node).getGlogueEdge().getDstPattern()
: ((GraphJoinDecomposition) node).getParentPatten();
return mq.getRowCount(
new GraphPattern(node.getCluster(), node.getTraitSet(), original));
} else if (node instanceof Join) {
return mdRowCount.getRowCount((Join) node, mq);
} else if (node instanceof Union) {
Expand Down

0 comments on commit 73c1f6c

Please sign in to comment.