This is an automated email from the ASF dual-hosted git repository.

biyan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 38e412da32 [spark] Add currentSnapshotId to the description in paimon 
scan (#6318)
38e412da32 is described below

commit 38e412da323fb758f899a3198a8203dea9e45e0d
Author: Kerwin Zhang <[email protected]>
AuthorDate: Fri Oct 10 16:44:29 2025 +0800

    [spark] Add currentSnapshotId to the description in paimon scan (#6318)
---
 .../org/apache/paimon/spark/PaimonBaseScan.scala   | 40 ++++++++++++++++++++--
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git 
a/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/PaimonBaseScan.scala
 
b/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/PaimonBaseScan.scala
index baeec1aa68..70fffc4d37 100644
--- 
a/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/PaimonBaseScan.scala
+++ 
b/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/PaimonBaseScan.scala
@@ -26,6 +26,9 @@ import org.apache.paimon.spark.sources.PaimonMicroBatchStream
 import org.apache.paimon.spark.statistics.StatisticsHelper
 import org.apache.paimon.table.{DataTable, InnerTable}
 import org.apache.paimon.table.source.{InnerTableScan, Split}
+import org.apache.paimon.table.source.snapshot.TimeTravelUtil
+import org.apache.paimon.table.system.FilesTable
+import org.apache.paimon.utils.{SnapshotManager, TagManager}
 
 import org.apache.spark.sql.connector.metric.{CustomMetric, CustomTaskMetric}
 import org.apache.spark.sql.connector.read.{Batch, Scan, Statistics, 
SupportsReportStatistics}
@@ -132,12 +135,43 @@ abstract class PaimonBaseScan(
     } else {
       ""
     }
-    val latestSnapshotIdStr = if (table.latestSnapshot().isPresent) {
-      s", LatestSnapshotId: [${table.latestSnapshot().get.id}],"
+
+    val latestSnapshotId = if (table.latestSnapshot().isPresent) {
+      Some(table.latestSnapshot().get.id)
+    } else {
+      None
+    }
+
+    val latestSnapshotIdStr = if (latestSnapshotId.isDefined) {
+      s", LatestSnapshotId: [${latestSnapshotId.get}]"
     } else {
       ""
     }
-    s"PaimonScan: [${table.name}]" + latestSnapshotIdStr + pushedFiltersStr + 
pushedTopNFilterStr +
+
+    val currentSnapshot =
+      try {
+        table match {
+          case dataTable: DataTable =>
+            TimeTravelUtil.tryTravelToSnapshot(
+              coreOptions.toConfiguration,
+              dataTable.snapshotManager(),
+              dataTable.tagManager())
+          case _ =>
+            Optional.empty()
+        }
+      } catch {
+        case _: Exception => Optional.empty()
+      }
+
+    val currentSnapshotIdStr = if (currentSnapshot.isPresent) {
+      s", currentSnapshotId: [${currentSnapshot.get().id}]"
+    } else if (latestSnapshotId.isDefined) {
+      s", currentSnapshotId: [${latestSnapshotId.get}]"
+    } else {
+      ""
+    }
+
+    s"PaimonScan: [${table.name}]" + latestSnapshotIdStr + 
currentSnapshotIdStr + pushedFiltersStr + pushedTopNFilterStr +
       pushDownLimit.map(limit => s", Limit: [$limit]").getOrElse("")
   }
 }

Reply via email to