danny0405 commented on a change in pull request #1354: [CALCITE-482] Implement 
sql and planner hints
URL: https://github.com/apache/calcite/pull/1354#discussion_r335296075
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/rel/hint/ExplicitHintMatcher.java
 ##########
 @@ -0,0 +1,41 @@
+/*
+ * 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.calcite.rel.hint;
+
+import org.apache.calcite.linq4j.function.Function2;
+import org.apache.calcite.rel.RelNode;
+
+/**
+ * A function to customize whether a relational expression should match a hint.
+ *
+ * <p>Usually you may not need to implement this function, a {@link 
NodeTypeHintStrategy} is enough
+ * for most of the {@link RelHint}s.
+ *
+ * <p>Some of the hints can only be matched to the relational
+ * expression with special match conditions(not only the relational expression 
type).
+ * i.e. "hash_join(r, st)", this hint can only be applied to JOIN expression 
that
+ * has "r" and "st" as the input table names. To implement this, you may need 
to customize an
+ * {@link ExplicitHintStrategy} with an {@link ExplicitHintMatcher}.
 
 Review comment:
   There is no way to figurate out the hint strategy during sql node parsing. 
During sql-to-rel conversion, we have information like:
   1. What the hint arguments is, for `hash_join(r, st)`, the arguments are "r" 
and "st"
   2. What kind of node this hint want to apply for, for `hash_join(r, st)`, it 
is a `JOIN` node
   
   So i passed all these info to use and let them customize the strategies. Of 
cause we can have some default `ExplicitHintMatcher` implementations, but i 
don't think we can cover all the impls by default, the join node maybe very 
complex, such as multi-join, join with subQuery.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to