This is an automated email from the ASF dual-hosted git repository. mblow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 17ca94a0eea4d0a460bbe39e59481a4ea3aefd2d Author: preetham0202 <[email protected]> AuthorDate: Fri Aug 8 17:17:43 2025 +0530 [NO ISSUE] Reset operators after join selectivity estimation - user model changes: no - storage format changes: no - interface changes: no Ext-ref: MB-68047 During join selectivity estimation using sampled queries, the logical operators involved are modified to use the sampled dataset. To prevent side effects, this change ensures that modified operators are reset to their original state after the sampling-based estimation is complete. Change-Id: Ib7c1220740c2b5f025f60bec0378eaf253533f66 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20170 Reviewed-by: Murtadha Hubail <[email protected]> Tested-by: Murtadha Hubail <[email protected]> Integration-Tests: Murtadha Hubail <[email protected]> --- .../src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java index 52566efc9b..49a0aa844d 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java @@ -254,6 +254,8 @@ public class Stats { AbstractFunctionCallExpression joinExpr, JoinOperator join) throws AlgebricksException { AbstractBinaryJoinOperator abjoin = join.getAbstractJoinOp(); Pair<ILogicalOperator, Double> leftOutput = replaceDataSourceWithSample(left, index1); + ILogicalOperator originalLeft = abjoin.getInputs().get(0).getValue(); + ILogicalOperator originalRight = abjoin.getInputs().get(1).getValue(); abjoin.getInputs().get(0).setValue(leftOutput.getFirst()); Pair<ILogicalOperator, Double> rightOutput = replaceDataSourceWithSample(right, index2); abjoin.getInputs().get(1).setValue(rightOutput.getFirst()); @@ -261,6 +263,9 @@ public class Stats { List<List<IAObject>> result = runSamplingQuery(optCtx, abjoin); double estCardSample = findPredicateCardinality(result, false); double sel = estCardSample / leftOutput.getSecond() / rightOutput.getSecond(); + + abjoin.getInputs().get(0).setValue(originalLeft); + abjoin.getInputs().get(1).setValue(originalRight); return sel; }
