wombatu-kun commented on code in PR #18914:
URL: https://github.com/apache/hudi/pull/18914#discussion_r3411386423
##########
hudi-utilities/src/test/java/org/apache/hudi/utilities/functional/TestErrorTableAwareChainedTransformer.java:
##########
@@ -86,7 +87,45 @@ public void testForErrorRecordColumn() {
TypedProperties properties = new TypedProperties();
properties.setProperty(ERROR_TABLE_ENABLED.key(), "true");
ErrorTableAwareChainedTransformer transformer = new
ErrorTableAwareChainedTransformer(Arrays.asList(t1, t2, t3));
- assertThrows(HoodieValidationException.class, () ->
transformer.apply(jsc(), spark(), original, properties));
+ Dataset<Row> transformed = transformer.apply(jsc(), spark(), original,
properties);
+
+ assertArrayEquals(new String[]{"foo",
ERROR_TABLE_CURRUPT_RECORD_COL_NAME}, transformed.columns());
+ assertEquals(2, transformed.count());
+ }
+
+ @Test
+ void testCustomColumnProjectionPreservesCorruptRecord() {
+ // Single custom transformer doing column projection — drops
_corrupt_record.
+ Dataset<Row> original = getTestDataset();
+
+ Transformer columnFilter = (jsc, sparkSession, dataset, props) ->
dataset.select("foo");
+ TypedProperties properties = new TypedProperties();
+ properties.setProperty(ERROR_TABLE_ENABLED.key(), "true");
+ ErrorTableAwareChainedTransformer transformer =
+ new ErrorTableAwareChainedTransformer(Arrays.asList(columnFilter));
+ Dataset<Row> transformed = transformer.apply(jsc(), spark(), original,
properties);
+
+ assertArrayEquals(new String[]{"foo",
ERROR_TABLE_CURRUPT_RECORD_COL_NAME}, transformed.columns());
+ assertEquals(2, transformed.count());
+ assertEquals(2, transformed.filter(new
Column(ERROR_TABLE_CURRUPT_RECORD_COL_NAME).isNull()).count());
+ }
+
+ @Test
+ void testTransformerPreservingCorruptRecordIsNoOp() {
+ // Transformer that keeps all columns — re-injection is a no-op.
+ Dataset<Row> original = getTestDataset();
+
+ Transformer keepAll = (jsc, sparkSession, dataset, properties) ->
dataset.withColumn("foo",
+ dataset.col("foo").cast(IntegerType));
+ TypedProperties properties = new TypedProperties();
Review Comment:
+1
--
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]