wombatu-kun commented on code in PR #18375: URL: https://github.com/apache/hudi/pull/18375#discussion_r3205806620
########## hudi-common/src/main/java/org/apache/hudi/common/engine/ExtractedData.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.common.engine; + +import org.apache.avro.generic.GenericRecord; + +import javax.annotation.Nullable; + +/** + * Result of {@link RecordContext#extractDataFromRecord} carrying the engine-native row plus, + * when extraction went through an Avro payload (e.g. {@code ExpressionPayload} in SQL MERGE INTO), + * the original Avro record produced by {@code HoodieRecord#toIndexedRecord}. + * + * <p>The original Avro record is propagated to {@link org.apache.hudi.common.table.read.BufferedRecord} + * so downstream code (e.g. {@code UpdateProcessor}) can decode the payload bytes with the correct + * source schema instead of re-serializing the engine-native row through a possibly-mismatched schema. + */ +public final class ExtractedData<T> { + + private final T data; + @Nullable + private final GenericRecord originalAvroRecord; + + private ExtractedData(T data, @Nullable GenericRecord originalAvroRecord) { + this.data = data; + this.originalAvroRecord = originalAvroRecord; + } + + public static <T> ExtractedData<T> of(T data) { + return new ExtractedData<>(data, null); + } + + public static <T> ExtractedData<T> of(T data, @Nullable GenericRecord originalAvroRecord) { Review Comment: Of the four current call sites three pass no avro hint (`RecordContext`, `AvroRecordContext`, two paths in `SparkFileFormatInternalRecordContext`) and only the COW/ExpressionPayload path passes one. Keeping the no-hint overload so those three sites read as `ExtractedData.of(data)` — the explicit `null` at the cache-miss / sentinel sites would just be noise. -- 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]
