zstan commented on code in PR #1982:
URL: https://github.com/apache/ignite-3/pull/1982#discussion_r1180290737
##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/AbstractPlannerTest.java:
##########
@@ -1318,4 +1344,48 @@ public Publisher<BinaryRow> lookup(int partId,
HybridTimestamp timestamp, Cluste
Predicate<SearchBounds> empty() {
return Objects::isNull;
}
+
+ /**
+ * Wrapper for RelOptListener with empty realization for each of their
methods. Good choice in case you need implement just one or few
+ * methods for listener.
+ */
+ static class RelOptListenerWrapper implements RelOptListener {
+
+ @Override
+ public void relEquivalenceFound(RelEquivalenceEvent event) {}
+
+ @Override
+ public void ruleAttempted(RuleAttemptedEvent event) {}
+
+ @Override
+ public void ruleProductionSucceeded(RuleProductionEvent event) {}
+
+ @Override
+ public void relDiscarded(RelDiscardedEvent event) {}
+
+ @Override
+ public void relChosen(RelChosenEvent event) {}
+ }
+
+ /**
+ * Listener which keeps information about attempts of applying
optimization rules.
+ */
+ public class RuleAttemptListener extends RelOptListenerWrapper {
+ Set<String> attemptedRules = new HashSet<>();
+
+ @Override
+ public void ruleAttempted(final RuleAttemptedEvent event) {
+ if (event.isBefore()) {
+ attemptedRules.add(event.getRuleCall().getRule().toString());
+ }
+ }
+
+ public boolean isApplied(String rule) {
+ return attemptedRules.stream().anyMatch(r -> r.contains(rule));
+ }
+
+ public void resetStatistics() {
Review Comment:
statistic - confusing, probably simple - **reset** is enough ?
##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/JoinCommutePlannerTest.java:
##########
@@ -76,13 +79,44 @@ public static void init() {
.add("ID",
TYPE_FACTORY.createJavaType(Integer.class))
.build(), 10) {
- @Override public IgniteDistribution distribution() {
+ @Override
+ public IgniteDistribution distribution() {
return IgniteDistributions.affinity(0,
UUID.randomUUID(), DEFAULT_ZONE_ID);
}
}
);
}
+ @Test
+ public void testEnforceJoinOrderHint() throws Exception {
+ String sqlJoinCommuteWithNoHint = "SELECT COUNT(*) FROM SMALL s, HUGE
h, HUGE h1 WHERE h.id = s.id and h1.id=s.id";
+ String sqlJoinCommuteWithHint =
+ "SELECT /*+ ENFORCE_JOIN_ORDER */ COUNT(*) FROM SMALL s, HUGE
h, HUGE h1 WHERE h.id = s.id and h1.id=s.id";
+ String sqlJoinCommuteOuterWithNoHint = "SELECT COUNT(*) FROM SMALL s
RIGHT JOIN HUGE h on h.id = s.id";
+ String sqlJoinCommuteOuterWithHint = "SELECT /*+ ENFORCE_JOIN_ORDER */
COUNT(*) FROM SMALL s RIGHT JOIN HUGE h on h.id = s.id";
+
+ RuleAttemptListener listener = new RuleAttemptListener();
+
+ physicalPlan(sqlJoinCommuteWithNoHint, publicSchema, listener);
Review Comment:
i suggest to use real rule names instead of hadcoded, one change for rule
namings will broke huge amount of tests :
JoinConditionPushRuleConfig rule = JoinConditionPushRuleConfig.DEFAULT;
String ruleName = rule.toRule().toString();
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]