harsh1231 commented on code in PR #8520:
URL: https://github.com/apache/hudi/pull/8520#discussion_r1172912945
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/transform/ChainedTransformer.java:
##########
@@ -46,9 +52,33 @@ public List<String> getTransformersNames() {
@Override
public Dataset<Row> apply(JavaSparkContext jsc, SparkSession sparkSession,
Dataset<Row> rowDataset, TypedProperties properties) {
Dataset<Row> dataset = rowDataset;
+ boolean isQuarantineEnabled =
properties.getBoolean(QUARANTINE_TABLE_ENABLED.key(),
QUARANTINE_TABLE_ENABLED.defaultValue());
+ if (isQuarantineEnabled && !isCorruptRecordPresent(dataset)) {
+ dataset = dataset.withColumn(QUARANTINE_TABLE_CURRUPT_RECORD_COL_NAME,
lit(null));
+ }
for (Transformer t : transformers) {
dataset = t.apply(jsc, sparkSession, dataset, properties);
+ // validate in every stage to ensure it's not dropped by one of the
transformer and added by next transformer.
+ validate(dataset, isQuarantineEnabled);
}
return dataset;
}
+
+ /**
+ * validates for constraints on corruptRecordColumn when quarantine
enabled/disabled configs are set.
+ * @param dataset
+ * @param isQuarantineEnabled
+ */
+ private void validate(Dataset<Row> dataset, boolean isQuarantineEnabled) {
+ boolean isCorruptRecordColumnPresent = isCorruptRecordPresent(dataset);
+ if (isQuarantineEnabled != isCorruptRecordColumnPresent) {
Review Comment:
should we consider below condition as validation violation ?
if isQuarantineEnabled = false and isCorruptRecordColumnPresent = true
if there is user schema column QUARANTINE_TABLE_CURRUPT_RECORD_COL_NAME ,
this will fail , although user is not using quarantine settings .
@rmahindra123 @xushiyan
--
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]