danny0405 commented on code in PR #20660:
URL: https://github.com/apache/hudi/pull/20660#discussion_r4703478409


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/HoodieSource.java:
##########
@@ -101,6 +104,9 @@ public HoodieSource(
     this.tableName = metaClient == null
         ? scanContext.getConf().get(FlinkOptions.TABLE_NAME)
         : metaClient.getTableConfig().getTableName();
+    this.timelineTimeZone = metaClient == null
+        ? HoodieTableConfig.TIMELINE_TIMEZONE.defaultValue()

Review Comment:
   Source V2 supports planning a streaming read before the table exists 
(#20866). In that case this final field captures `LOCAL`, and both the 
enumerator and reader keep using it after discovery finds a UTC table. I 
reproduced this with a reader in `Asia/Shanghai`: a `10:00Z` commit was 
reported as `02:00Z`. Could we leave the zone unresolved until the table is 
available and use its persisted value in both paths?



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/StreamReadMonitoringFunction.java:
##########
@@ -333,10 +335,20 @@ public void snapshotState(FunctionSnapshotContext 
context) throws Exception {
 
   private void registerMetrics() {
     MetricGroup metrics = getRuntimeContext().getMetricGroup();
-    readMetrics = new FlinkStreamReadMetrics(metrics, tableName);
+    readMetrics = new FlinkStreamReadMetrics(metrics, tableName, 
this::getTimelineTimeZone);
     readMetrics.registerMetrics();
   }
 
+  /**
+   * The metrics are registered before the table is guaranteed to exist, so 
the timezone comes from
+   * the meta client, which is created once the table does.
+   */
+  private HoodieTimelineTimeZone getTimelineTimeZone() {
+    return metaClient == null
+        ? HoodieTableConfig.TIMELINE_TIMEZONE.defaultValue()

Review Comment:
   After checkpoint restore, `issuedInstant` can already be populated while 
`metaClient` is still null. If `snapshotState()` runs before the first 
directory scan, `setIssuedInstant()` takes this `LOCAL` fallback even for an 
existing UTC table. Restoring the operator harness and taking a snapshot before 
scanning reproduced an epoch 28,800 seconds too early in `Asia/Shanghai`. Could 
we checkpoint the restored string as usual and defer the gauge update until the 
table timezone is available?



##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/format/mor/MergeOnReadInputFormat.java:
##########
@@ -257,6 +265,22 @@ public void close() throws IOException {
     this.closed = true;
   }
 
+  /**
+   * Returns the timeline timezone of the table. A streaming read can start 
before the table exists, so
+   * the table config is read on first use, and the default is returned while 
there is no table yet.
+   */
+  public HoodieTimelineTimeZone getTimelineTimeZone() {
+    if (timelineTimeZone == null) {
+      Option<HoodieTableConfig> tableConfig = StreamerUtil.getTableConfig(

Review Comment:
   On the first split, each legacy reader subtask checks storage and loads 
`hoodie.properties` here. `format.open(split)` immediately creates a meta 
client that reads the same properties again. Could we initialize the split’s 
meta client once and reuse it for both timezone resolution and opening the 
split? That would remove the extra object-store requests and the separate 
timezone cache while still letting `startSplit()` cover a slow open.



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