Au-Miner commented on code in PR #28681:
URL: https://github.com/apache/flink/pull/28681#discussion_r3557806923


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/RelTreeWriterImpl.scala:
##########
@@ -279,6 +240,122 @@ class RelTreeWriterImpl(
     pw.println()
   }
 
+  override def item(term: String, value: AnyRef): RelWriter = {
+    if (withQueryHint || withQueryBlockAlias) {
+      value match {
+        case rexNode: RexNode if containsSubQuery(rexNode) =>
+          return super.item(term, toHintAwareSubQueryString(rexNode))
+        case _ =>
+      }
+    }
+    super.item(term, value)
+  }
+
+  private def containsSubQuery(node: RexNode): Boolean = {
+    var found = false
+    node.accept(new RexVisitorImpl[Void](true) {
+      override def visitSubQuery(subQuery: RexSubQuery): Void = {
+        found = true
+        null
+      }
+    })
+    found
+  }
+
+  private def addHintItems(rel: RelNode, addItem: (String, AnyRef) => Unit): 
Unit = {
+    addQueryHintItems(rel, addItem)
+    addQueryBlockAliasHintItems(rel, addItem)
+  }
+
+  private def addQueryHintItems(rel: RelNode, addItem: (String, AnyRef) => 
Unit): Unit = {
+    if (withQueryHint) {
+      rel match {
+        case hintable: Hintable if rel.isInstanceOf[Join] || 
rel.isInstanceOf[Correlate] =>
+          val hints = hintable.getHints
+          addJoinHintItems(hints, addItem)
+          addStateTtlHintItems(hints, addItem)
+        case aggregate: Aggregate =>
+          addStateTtlHintItems(aggregate.getHints, addItem)
+        case aggregate: StreamPhysicalGroupAggregateBase =>

Review Comment:
   In fact, the RelWriterImpl.item method will be called. I have changed it to 
super.item to more intuitively reflect the method being called, so it will not 
cause an infinite loop.



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

Reply via email to