linliu-code commented on code in PR #19707:
URL: https://github.com/apache/hudi/pull/19707#discussion_r3832479427


##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/helpers/KinesisDeaggregator.java:
##########
@@ -44,36 +59,137 @@ public static List<Record> deaggregate(List<Record> 
records) {
     if (records == null || records.isEmpty()) {
       return new ArrayList<>();
     }
-    List<com.amazonaws.services.kinesis.model.Record> v1Records = new 
ArrayList<>(records.size());
-    for (Record r : records) {
-      v1Records.add(toV1Record(r));
-    }
-    List<UserRecord> userRecords = UserRecord.deaggregate(v1Records);
-    List<Record> result = new ArrayList<>(userRecords.size());
-    for (UserRecord ur : userRecords) {
-      result.add(toV2Record(ur));
+    List<Record> result = new ArrayList<>(records.size());
+    for (Record record : records) {
+      byte[] data = record.data() == null ? null : record.data().asByteArray();
+      if (!isAggregated(data)) {
+        result.add(record);

Review Comment:
   Since the KPL frame format is AWS-owned and the magic number is its only 
version discriminator, this pass-through is now our sole defense against a 
future format change -- and I think it's silent today: `append.offsets` 
defaults to false, so `recordToJsonStatic` returns the raw frame bytes as a 
string, and `SourceFormatAdapter` reads them with 
`spark.read().schema(dataType).json(rdd)` in Spark's default PERMISSIVE mode, 
landing an all-null row in the table.
   
   Could an undecodable frame that carries the KPL magic be raised, or routed 
to the error table, instead of falling back to "treat as a plain record"? A 
frame with the magic but a digest we can't verify feels qualitatively different 
from a record that simply isn't aggregated.



##########
hudi-utilities/src/test/java/org/apache/hudi/utilities/sources/helpers/TestKinesisDeaggregator.java:
##########
@@ -0,0 +1,276 @@
+/*
+ * 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.utilities.sources.helpers;
+
+import com.google.protobuf.CodedOutputStream;
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.core.SdkBytes;
+import software.amazon.awssdk.services.kinesis.model.Record;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.time.Instant;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Unit tests for {@link KinesisDeaggregator}, covering KPL aggregate decoding 
and the pass-through
+ * paths taken by non-aggregated, corrupt or invalid records.
+ */
+class TestKinesisDeaggregator {
+
+  private static final byte[] MAGIC = new byte[] {(byte) 0xF3, (byte) 0x89, 
(byte) 0x9A, (byte) 0xC2};
+  private static final String PARENT_SEQ = "49590";
+  private static final Instant PARENT_ARRIVAL = 
Instant.ofEpochMilli(1700000000000L);
+
+  // -------------------------------------------------------------------------
+  // Encoding helpers - independent of the decoder under test

Review Comment:
   The differential-test evidence is strong, but it compares two decoders 
against fixtures from a hand-written encoder -- if the encoder ever drifts from 
the real format, both implementations reject the input identically and the test 
still passes vacuously, pinning us to KCL's decoder rather than to the KPL's 
output.
   
   Would it be worth checking in one or two byte-array fixtures captured from a 
real KPL producer, so at least one test is anchored to actual producer output?



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