lincoln-lil commented on code in PR #23047:
URL: https://github.com/apache/flink/pull/23047#discussion_r1271293985


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/common/CommonPhysicalTableSourceScan.scala:
##########
@@ -51,9 +52,21 @@ abstract class CommonPhysicalTableSourceScan(
   }
 
   override def explainTerms(pw: RelWriter): RelWriter = {
+    val version = extractSnapshotVersion()
     super
       .explainTerms(pw)
       .item("fields", getRowType.getFieldNames.asScala.mkString(", "))
       .itemIf("hints", RelExplainUtil.hintsToString(getHints), 
!getHints.isEmpty)
+      .itemIf("version", version.get, version.isDefined)
+  }
+
+  private def extractSnapshotVersion(): Option[String] = {
+    val originTable: CatalogBaseTable =
+      relOptTable.contextResolvedTable.getTable.asInstanceOf[CatalogBaseTable]
+    originTable match {
+      case catalogTable: CatalogTable if catalogTable.getSnapshot.isPresent =>
+        Option(catalogTable.getSnapshot.get().toString)
+      case _ => Option("")

Review Comment:
   Because the term `version.get` will be executed even though `version` is 
empty during `explainTerms` ( see `.itemIf("version", version.get, 
version.isDefined)`), and use `version.getOrElse("")` doesn’t seem much 
difference compared to the current approach, WDYT?



##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/common/CommonPhysicalTableSourceScan.scala:
##########
@@ -51,9 +52,21 @@ abstract class CommonPhysicalTableSourceScan(
   }
 
   override def explainTerms(pw: RelWriter): RelWriter = {
+    val version = extractSnapshotVersion()
     super
       .explainTerms(pw)
       .item("fields", getRowType.getFieldNames.asScala.mkString(", "))
       .itemIf("hints", RelExplainUtil.hintsToString(getHints), 
!getHints.isEmpty)
+      .itemIf("version", version.get, version.isDefined)
+  }
+
+  private def extractSnapshotVersion(): Option[String] = {
+    val originTable: CatalogBaseTable =
+      relOptTable.contextResolvedTable.getTable.asInstanceOf[CatalogBaseTable]
+    originTable match {
+      case catalogTable: CatalogTable if catalogTable.getSnapshot.isPresent =>
+        Option(catalogTable.getSnapshot.get().toString)
+      case _ => Option("")

Review Comment:
   Because the term `version.get` will be executed even though `version` is 
empty during `explainTerms` ( see `.itemIf("version", version.get, 
version.isDefined)`), and use `version.getOrElse("")` doesn’t seem much 
difference compared to the current approach, WDYT?



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to