Skip to content

Commit

Permalink
fix bugs of empty results
Browse files Browse the repository at this point in the history
  • Loading branch information
shirly121 committed Jan 21, 2025
1 parent 95f34ab commit 86fe502
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,27 @@ public StatementResult run(
statusCallback
.getQueryLogger()
.info("logical IR plan \n\n {} \n\n", planSummary.getLogicalPlan().explain());
statusCallback
.getQueryLogger()
.debug("physical IR plan {}", planSummary.getPhysicalPlan().explain());
if (planSummary.getLogicalPlan().isReturnEmpty()) {
return StatementResults.initial();
boolean returnEmpty = planSummary.getLogicalPlan().isReturnEmpty();
if (!returnEmpty) {
statusCallback
.getQueryLogger()
.debug("physical IR plan {}", planSummary.getPhysicalPlan().explain());
}
QueryTimeoutConfig timeoutConfig = getQueryTimeoutConfig();
GraphPlanExecutor executor;
if (cacheValue.result != null && cacheValue.result.isCompleted) {
if (returnEmpty) {
executor =
new GraphPlanExecutor() {
@Override
public void execute(
GraphPlanner.Summary summary,
IrMeta irMeta,
ExecutionResponseListener listener)
throws Exception {
listener.onCompleted();
}
};
} else if (cacheValue.result != null && cacheValue.result.isCompleted) {
executor =
new GraphPlanExecutor() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.alibaba.graphscope.common.ir.planner.GraphIOProcessor;
import com.alibaba.graphscope.common.ir.planner.GraphRelOptimizer;
import com.alibaba.graphscope.common.ir.tools.GraphBuilder;
import com.alibaba.graphscope.common.ir.tools.LogicalPlan;
import com.google.common.collect.ImmutableMap;

import org.apache.calcite.rel.RelNode;
Expand Down Expand Up @@ -105,4 +106,18 @@ public void scan_early_stop_1_test() {
+ " 10>}])",
after.explain().trim());
}

@Test
public void scan_early_stop_2_test() {
GraphBuilder builder = Utils.mockGraphBuilder(optimizer, irMeta);
RelNode before =
com.alibaba.graphscope.cypher.antlr4.Utils.eval(
"Match (:PERSON)-[n:KNOWS]->(b) Where n.creationDate > $date Return"
+ " n Limit 0",
builder)
.build();
RelNode after = optimizer.optimize(before, new GraphIOProcessor(builder, irMeta));
LogicalPlan plan = new LogicalPlan(after);
Assert.assertTrue(plan.isReturnEmpty());
}
}

0 comments on commit 86fe502

Please sign in to comment.