hudi-agent commented on code in PR #19655:
URL: https://github.com/apache/hudi/pull/19655#discussion_r3845836092


##########
hudi-flink-datasource/hudi-flink2.2.x/src/main/java/org/apache/hudi/table/format/cow/vector/reader/Int64TimestampColumnReader.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.table.format.cow.vector.reader;
+
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.table.data.columnar.vector.writable.WritableIntVector;
+import 
org.apache.flink.table.data.columnar.vector.writable.WritableTimestampVector;
+import org.apache.parquet.column.ColumnDescriptor;
+import org.apache.parquet.column.page.PageReader;
+import org.apache.parquet.schema.PrimitiveType;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.sql.Timestamp;
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+
+/**
+ * Timestamp {@link 
org.apache.flink.formats.parquet.vector.reader.ColumnReader} that supports 
INT64 8 bytes,
+ * TIMESTAMP_MILLIS is the deprecated ConvertedType counterpart of a TIMESTAMP 
logical type
+ * that is UTC normalized and has MILLIS precision.
+ *
+ * <p>See 
https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#timestamp
+ * TIMESTAMP_MILLIS and TIMESTAMP_MICROS are the deprecated ConvertedType.
+ */
+public class Int64TimestampColumnReader extends 
AbstractColumnReader<WritableTimestampVector> {
+
+  private final boolean utcTimestamp;
+
+  private final ChronoUnit chronoUnit;
+
+  public Int64TimestampColumnReader(
+      boolean utcTimestamp,
+      ColumnDescriptor descriptor,
+      PageReader pageReader,
+      int precision) throws IOException {
+    super(descriptor, pageReader);
+    this.utcTimestamp = utcTimestamp;
+    if (precision <= 3) {
+      this.chronoUnit = ChronoUnit.MILLIS;
+    } else if (precision <= 6) {
+      this.chronoUnit = ChronoUnit.MICROS;
+    } else {
+      throw new IllegalArgumentException(
+          "Avro does not support TIMESTAMP type with precision: "

Review Comment:
   🤖 nit: the error message says "Avro does not support TIMESTAMP" but this is 
a Parquet column reader — could you swap "Avro" for "Parquet" (or drop the 
technology reference altogether) so the message doesn't mislead whoever hits 
this at runtime?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink2.2.x/src/main/java/org/apache/hudi/utils/RuntimeContextUtils.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.utils;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.api.common.functions.RuntimeContext;
+
+import java.util.Map;
+
+import static 
org.apache.flink.configuration.PipelineOptions.AUTO_WATERMARK_INTERVAL;
+
+/**
+ * Adapter utils for {@code RuntimeContext} to solve API compatibilities issue.
+ */
+public class RuntimeContextUtils {
+
+  public static JobID getJobId(RuntimeContext runtimeContext) {
+    return runtimeContext.getJobInfo().getJobId();
+  }
+
+  public static int getAttemptNumber(RuntimeContext runtimeContext) {
+    return runtimeContext.getTaskInfo().getAttemptNumber();
+  }
+
+  public static int getIndexOfThisSubtask(RuntimeContext runtimeContext) {
+    return runtimeContext.getTaskInfo().getIndexOfThisSubtask();
+  }
+
+  public static int getMaxNumberOfParallelSubtasks(RuntimeContext 
runtimeContext) {
+    return runtimeContext.getTaskInfo().getMaxNumberOfParallelSubtasks();
+  }
+
+  public static int getNumberOfParallelSubtasks(RuntimeContext runtimeContext) 
{
+    return runtimeContext.getTaskInfo().getNumberOfParallelSubtasks();
+  }
+
+  public static long getWatermarkInternal(RuntimeContext runtimeContext) {

Review Comment:
   🤖 nit: `getWatermarkInternal` is a bit opaque — `Internal` doesn't describe 
what's being returned. Something like `getAutoWatermarkIntervalMs` would make 
it immediately clear this returns the configured auto-watermark interval in 
milliseconds.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink2.2.x/src/main/java/org/apache/hudi/adapter/Utils.java:
##########
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.adapter;
+
+import org.apache.hudi.common.schema.internal.InternalSchema;
+import org.apache.hudi.common.schema.internal.Type;
+import 
org.apache.hudi.common.schema.internal.action.InternalSchemaChangeApplier;
+import org.apache.hudi.common.util.collection.Pair;
+import org.apache.hudi.exception.HoodieNotSupportedException;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.core.memory.ManagedMemoryUseCase;
+import org.apache.flink.runtime.execution.Environment;
+import org.apache.flink.runtime.io.disk.iomanager.IOManager;
+import org.apache.flink.runtime.memory.MemoryManager;
+import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
+import org.apache.flink.table.api.config.ExecutionConfigOptions;
+import org.apache.flink.table.catalog.Column;
+import org.apache.flink.table.catalog.ObjectIdentifier;
+import org.apache.flink.table.catalog.ResolvedCatalogTable;
+import org.apache.flink.table.catalog.TableChange;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.factories.FactoryUtil;
+import org.apache.flink.table.runtime.generated.NormalizedKeyComputer;
+import org.apache.flink.table.runtime.generated.RecordComparator;
+import org.apache.flink.table.runtime.operators.sort.BinaryExternalSorter;
+import org.apache.flink.table.runtime.typeutils.AbstractRowDataSerializer;
+import org.apache.flink.table.runtime.typeutils.BinaryRowDataSerializer;
+import org.apache.flink.table.types.logical.LogicalType;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Function;
+
+import static 
org.apache.hudi.common.schema.internal.action.TableChange.ColumnPositionChange.ColumnPositionType.AFTER;
+import static 
org.apache.hudi.common.schema.internal.action.TableChange.ColumnPositionChange.ColumnPositionType.FIRST;
+import static 
org.apache.hudi.common.schema.internal.action.TableChange.ColumnPositionChange.ColumnPositionType.NO_OPERATION;
+
+/**
+ * Adapter utils.
+ */
+public class Utils {
+  public static FactoryUtil.DefaultDynamicTableContext getTableContext(

Review Comment:
   🤖 nit: `Utils` is too generic for a class name — it doesn't hint at what 
kind of utilities it holds. Could you rename it to something like 
`FlinkAdapterUtils` or `Flink22AdapterUtils` to match the package intent and 
the Hudi convention of specific utility class names?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink2.2.x/src/main/java/org/apache/hudi/adapter/MaskingOutputAdapter.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.adapter;
+
+import org.apache.flink.runtime.event.WatermarkEvent;
+import org.apache.flink.streaming.api.operators.Output;
+import org.apache.flink.streaming.api.watermark.Watermark;
+import org.apache.flink.streaming.runtime.streamrecord.LatencyMarker;
+import org.apache.flink.streaming.runtime.streamrecord.RecordAttributes;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.runtime.watermarkstatus.WatermarkStatus;
+import org.apache.flink.util.OutputTag;
+
+/** Adapter class for {@code Output} to handle async compaction/clustering 
service thread safe issues */
+public class MaskingOutputAdapter<OUT> implements Output<StreamRecord<OUT>> {
+
+  private final Output<StreamRecord<OUT>> output;
+
+  public MaskingOutputAdapter(Output<StreamRecord<OUT>> output) {
+    this.output = output;
+  }
+
+  @Override
+  public void emitWatermark(Watermark watermark) {
+    // For thread safe, not to propagate the watermark
+  }
+
+  @Override
+  public void emitLatencyMarker(LatencyMarker latencyMarker) {
+    // For thread safe, not to propagate latency marker
+  }
+
+  @Override
+  public void emitRecordAttributes(RecordAttributes recordAttributes) {

Review Comment:
   🤖 nit: the comment says "not to propagate watermark status" but this method 
is `emitRecordAttributes` — looks like a copy-paste from `emitWatermarkStatus`. 
Could you update it to say something like "not to propagate record attributes"?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



##########
hudi-flink-datasource/hudi-flink2.2.x/src/main/java/org/apache/hudi/adapter/TableFunctionProviderAdapter.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.adapter;
+
+import org.apache.flink.table.functions.TableFunction;
+import org.apache.flink.table.legacy.connector.source.TableFunctionProvider;
+
+/**
+ * Adapter clazz for {@link TableFunctionProvider}.
+ */
+public interface TableFunctionProviderAdapter<T> extends 
TableFunctionProvider<T> {
+  static <T> TableFunctionProvider<T> of(TableFunction<T> tableFunction) {
+    return () -> {

Review Comment:
   🤖 nit: the block lambda `() -> { return tableFunction; }` can be simplified 
to `() -> tableFunction` — a bit cleaner to read.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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