cheddar commented on code in PR #12715:
URL: https://github.com/apache/druid/pull/12715#discussion_r910964965
##########
sql/src/main/java/org/apache/druid/sql/calcite/planner/Rules.java:
##########
@@ -234,7 +242,11 @@ private static Program buildHepProgram(Iterable<? extends
RelOptRule> rules,
return Programs.of(builder.build(), noDag, metadataProvider);
}
- private static List<RelOptRule> druidConventionRuleSet(final PlannerContext
plannerContext)
+ @VisibleForTesting
Review Comment:
OCD Religious Crusader: Does this annotation really add anything? If you
move it to public and someone is like "why is this public" they are gonna do a
usages check and see where it is used. If you are trying to deter people from
using it, a little annotation doesn't provide any context on why it's a bad
idea for someone to use it if they think that it's good to use it. Just delete
the annotation.
##########
sql/src/main/java/org/apache/druid/sql/calcite/rule/DruidExtensionCalciteRuleManager.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.druid.sql.calcite.rule;
+
+import com.google.inject.Inject;
+
+import java.util.Set;
+
+/**
+ * Manages the custom calcite rules coming from extensions
+ */
+public class DruidExtensionCalciteRuleManager
+{
+ private final Set<DruidExtensionCalciteRuleProvider>
druidExtensionCalciteRuleProviderSet;
+
+ @Inject
+ public DruidExtensionCalciteRuleManager(
+ @ExtensionCalciteRuleProvider Set<DruidExtensionCalciteRuleProvider>
druidExtensionCalciteRuleProviderSet
+ )
+ {
+ this.druidExtensionCalciteRuleProviderSet =
druidExtensionCalciteRuleProviderSet;
+ }
+
+ public Set<DruidExtensionCalciteRuleProvider>
getDruidExtensionCalciteRuleProviderSet()
Review Comment:
Having this have a getter that returns a Set makes for a really weird
contract. This thing exists to add rules to the set of rules, so you could
instead have a
```
fromEach(Consumer<DruidExtensionCalciteRuleProvider>)
```
Or some other semantically meaningful function signature instead of just
"give me a data structure".
##########
sql/src/main/java/org/apache/druid/sql/calcite/rule/ExtensionCalciteRuleProvider.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.druid.sql.calcite.rule;
+
+import com.google.inject.BindingAnnotation;
+import org.apache.druid.guice.annotations.UnstableApi;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to use while binding custom calcite rules from extensions to
{@link DruidExtensionCalciteRuleProvider}
+ */
+@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD,
ElementType.PARAMETER})
+@Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+@UnstableApi
+public @interface ExtensionCalciteRuleProvider
Review Comment:
I'm like 95% certain you can just bind the
`Set<DruidExtensionCalciteRuleProvider>` without an annotation, I think. In
which case, you don't need this annotation at all.
--
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]