godfreyhe commented on a change in pull request #11674: 
[FLINK-16887][table-planner-blink] Refactor retraction rules to support 
inferring ChangelogMode
URL: https://github.com/apache/flink/pull/11674#discussion_r407137103
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/trait/UpdateKindTrait.scala
 ##########
 @@ -0,0 +1,79 @@
+/*
+ * 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.flink.table.planner.plan.`trait`
+
+import org.apache.calcite.plan.{RelOptPlanner, RelTrait, RelTraitDef}
+
+/**
+ * UpdateKindTrait is used to describe the kind of update operation.
+ */
+class UpdateKindTrait(val updateKind: UpdateKind) extends RelTrait {
+
+  override def satisfies(relTrait: RelTrait): Boolean = relTrait match {
+    case other: UpdateKindTrait =>
+      // should totally match
+      other.updateKind == this.updateKind
+    case _ => false
+  }
+
+  override def getTraitDef: RelTraitDef[_ <: RelTrait] = 
UpdateKindTraitDef.INSTANCE
+
+  override def register(planner: RelOptPlanner): Unit = {}
+
+  override def hashCode(): Int = updateKind.hashCode()
+
+  override def equals(obj: Any): Boolean = obj match {
+    case t: UpdateKindTrait => this.updateKind.equals(t.updateKind)
+    case _ => false
+  }
+
+  override def toString: String = s"[${updateKind.toString}]"
+}
+
+object UpdateKindTrait {
+  val NO_UPDATE = new UpdateKindTrait(UpdateKind.NO_UPDATE)
 
 Review comment:
   Now a complete change mode is represented by two `Trait`s, `NO_UPDATE` is 
just a placeholder which also means `ModifyKindSetTrait` does not contain 
`UPDATE`.  
   Another idea is that we can treat `ONLY_UPDATE_AFTER` and `BEFORE_AND_AFTER` 
as a sub-attribute of `ModifyKind.UPDATE` (`BEFORE_AND_AFTER` is default), then 
we can use only one trait to represent changelog mode. The optimization we want 
to apply is whether `BEFORE_AND_AFTER` can be changed to `ONLY_UPDATE_AFTER`.
   It's better we can also give some comments here.

----------------------------------------------------------------
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