gortiz commented on code in PR #18387: URL: https://github.com/apache/pinot/pull/18387#discussion_r3275199683
########## pinot-query-planner-spi/src/main/java/org/apache/pinot/query/planner/spi/Phase.java: ########## @@ -0,0 +1,64 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.query.planner.spi; + + +/// HEP phases the multi-stage planner exposes to plugin +/// [RuleSetCustomizer]s. Every phase corresponds to one slot in the rule +/// programs built by `QueryEnvironment#getOptProgram` / +/// `QueryEnvironment#getTraitProgram`. +/// +/// **Stability**: this enum is append-only — new phases may be added at the +/// end without breaking plugins compiled against an older version. Existing +/// phases must never be reordered or removed. +public enum Phase { + /// Basic logical-rewrite phase. HEP, depth-first. + /// OSS defaults: `DefaultRuleSetCustomizer.BASIC_RULES`. + BASIC, + + /// Filter pushdown rules. The HEP program runs this phase twice (around the + /// project pushdown phase). OSS defaults: + /// `DefaultRuleSetCustomizer.FILTER_PUSHDOWN_RULES`. + FILTER_PUSHDOWN, + + /// Project pushdown rules. + /// OSS defaults: `DefaultRuleSetCustomizer.PROJECT_PUSHDOWN_RULES`. + PROJECT_PUSHDOWN, + + /// Top-down pruning rules. + /// OSS defaults: `DefaultRuleSetCustomizer.PRUNE_RULES`. + PRUNE, + + /// Post-logical rules used when the physical optimizer is **not** enabled. + /// OSS defaults: `DefaultRuleSetCustomizer.POST_LOGICAL_RULES`. The list + /// includes `PinotSortExchangeCopyRule.SORT_EXCHANGE_COPY` configured with + /// the rule's hard-coded default `fetchLimitThreshold`. Per-query overrides + /// (and broker-config overrides) are applied by `QueryEnvironment` swapping + /// the rule on a per-query copy of this list. + POST_LOGICAL, + + /// Post-logical rules used when the physical optimizer **is** enabled. + /// OSS defaults: `DefaultRuleSetCustomizer.POST_LOGICAL_PHYSICAL_RULES`. + POST_LOGICAL_PHYSICAL, Review Comment: Done — renamed to `POST_LOGICAL_PHYSICAL_OPT`. ########## pinot-query-planner-spi/src/main/java/org/apache/pinot/query/planner/spi/Phase.java: ########## @@ -0,0 +1,64 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.query.planner.spi; + + +/// HEP phases the multi-stage planner exposes to plugin +/// [RuleSetCustomizer]s. Every phase corresponds to one slot in the rule +/// programs built by `QueryEnvironment#getOptProgram` / +/// `QueryEnvironment#getTraitProgram`. +/// +/// **Stability**: this enum is append-only — new phases may be added at the +/// end without breaking plugins compiled against an older version. Existing +/// phases must never be reordered or removed. +public enum Phase { + /// Basic logical-rewrite phase. HEP, depth-first. + /// OSS defaults: `DefaultRuleSetCustomizer.BASIC_RULES`. + BASIC, + + /// Filter pushdown rules. The HEP program runs this phase twice (around the + /// project pushdown phase). OSS defaults: + /// `DefaultRuleSetCustomizer.FILTER_PUSHDOWN_RULES`. + FILTER_PUSHDOWN, + + /// Project pushdown rules. + /// OSS defaults: `DefaultRuleSetCustomizer.PROJECT_PUSHDOWN_RULES`. + PROJECT_PUSHDOWN, + + /// Top-down pruning rules. + /// OSS defaults: `DefaultRuleSetCustomizer.PRUNE_RULES`. + PRUNE, + + /// Post-logical rules used when the physical optimizer is **not** enabled. + /// OSS defaults: `DefaultRuleSetCustomizer.POST_LOGICAL_RULES`. The list + /// includes `PinotSortExchangeCopyRule.SORT_EXCHANGE_COPY` configured with + /// the rule's hard-coded default `fetchLimitThreshold`. Per-query overrides + /// (and broker-config overrides) are applied by `QueryEnvironment` swapping + /// the rule on a per-query copy of this list. + POST_LOGICAL, + + /// Post-logical rules used when the physical optimizer **is** enabled. + /// OSS defaults: `DefaultRuleSetCustomizer.POST_LOGICAL_PHYSICAL_RULES`. + POST_LOGICAL_PHYSICAL, + + /// Conditional enriched-join rules applied after the post-logical phase + /// when the `JOIN_TO_ENRICHED_JOIN` rule is not skipped. + /// OSS defaults: `PinotEnrichedJoinRule.PINOT_ENRICHED_JOIN_RULES`. + POST_LOGICAL_ENRICHED_JOIN Review Comment: Good question — on reflection, enriched join was an experimental feature that didn't pan out well, so I removed `POST_LOGICAL_ENRICHED_JOIN` from the enum and `QueryEnvironment` entirely rather than keeping a phase we'd likely remove soon anyway. ########## pinot-query-planner-spi/src/test/java/org/apache/pinot/spi/plugin/PluginRealmExportTest.java: ########## @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.spi.plugin; + +import java.io.File; +import java.io.FileOutputStream; +import java.nio.file.Files; +import java.util.Set; +import java.util.jar.JarOutputStream; +import org.apache.pinot.query.planner.spi.RuleSetCustomizer; +import org.testng.Assert; +import org.testng.annotations.Test; + + +/// Verifies that {@link PluginManager} exports the SPI packages from the pinot +/// realm into each plugin realm, so plugin JARs can implement +/// {@link RuleSetCustomizer} without bundling or shading those classes. +/// +/// This test lives in the {@code org.apache.pinot.spi.plugin} package (in a +/// different Maven module) to access the package-private {@link PluginManager} +/// constructor. +public class PluginRealmExportTest { + + @Test + public void pluginRealmCanLoadRuleSetCustomizer() + throws Exception { + File tempDir = Files.createTempDirectory("pinot-spi-export-test").toFile(); + try { + // Minimal new-style plugin: just pinot-plugin.properties + an empty JAR. + Files.createFile(tempDir.toPath().resolve("pinot-plugin.properties")); + try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(new File(tempDir, "dummy.jar")))) { + // intentionally empty + } + + PluginManager pm = new PluginManager(); + pm.load("spi-export-test-plugin", tempDir); + + Set<ClassLoader> loaders = pm.getPluginClassLoaders(); + Assert.assertEquals(loaders.size(), 1, "Exactly one plugin realm should be registered"); + + ClassLoader pluginRealm = loaders.iterator().next(); + + // RuleSetCustomizer is in org.apache.pinot.query.planner.rules, which PluginManager Review Comment: Fixed. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
