diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/meta/glogue/calcite/handler/GraphRowCountHandler.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/meta/glogue/calcite/handler/GraphRowCountHandler.java index 3e8d1dd88cbe..0ca70a7c7a3f 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/meta/glogue/calcite/handler/GraphRowCountHandler.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/meta/glogue/calcite/handler/GraphRowCountHandler.java @@ -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) { @@ -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) {