You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "lincoln-lil (via GitHub)" <gi...@apache.org> on 2023/07/22 13:02:00 UTC
[GitHub] [flink] lincoln-lil commented on a diff in pull request #23047: [FLINK-32646][table-planner] Fix TestTimeTravelCatalog missing snapshot version properties and add version to source table's digest
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org