You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "nsivabalan (via GitHub)" <gi...@apache.org> on 2023/05/02 18:26:43 UTC
[GitHub] [hudi] nsivabalan commented on a diff in pull request #8520: [HUDI-6115] Hardening expectation of corruptRecordColumn in ChainedTransformer.
nsivabalan commented on code in PR #8520:
URL: https://github.com/apache/hudi/pull/8520#discussion_r1182901309
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer/ErrorTableUtils.java:
##########
@@ -28,32 +28,39 @@
import org.apache.hudi.exception.HoodieException;
import org.apache.hadoop.fs.FileSystem;
+import org.apache.hudi.exception.HoodieValidationException;
import org.apache.spark.api.java.JavaSparkContext;
+import org.apache.spark.sql.Dataset;
+import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
+import static org.apache.spark.sql.functions.lit;
+
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
+import java.util.stream.Collectors;
import static org.apache.hudi.config.HoodieErrorTableConfig.ERROR_TABLE_WRITE_CLASS;
import static org.apache.hudi.config.HoodieErrorTableConfig.ERROR_TABLE_WRITE_FAILURE_STRATEGY;
+import static org.apache.hudi.utilities.deltastreamer.BaseErrorTableWriter.ERROR_TABLE_CURRUPT_RECORD_COL_NAME;
Review Comment:
So this is like a reserved column for any hudi table then?
should we check if incoming dataset has this column and fail may be? what in case we have a data column w/ the same name?
how happens incase of incremental consumer? it might have this column as a data column right ?
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer/ErrorTableUtils.java:
##########
@@ -63,4 +70,27 @@ public static HoodieErrorTableConfig.ErrorWriteFailureStrategy getErrorWriteFail
String writeFailureStrategy = props.getString(ERROR_TABLE_WRITE_FAILURE_STRATEGY.key());
return HoodieErrorTableConfig.ErrorWriteFailureStrategy.valueOf(writeFailureStrategy);
}
+
+ /**
+ * validates for constraints on ErrorRecordColumn when ErrorTable enabled configs are set.
+ * @param dataset
+ */
+ public static void validate(Dataset<Row> dataset) {
+ if (!isErrorTableCorruptRecordColumnPresent(dataset)) {
+ throw new HoodieValidationException(String.format("Invalid condition, columnName=%s "
+ + "is not present in transformer " + "output schema", ERROR_TABLE_CURRUPT_RECORD_COL_NAME));
+ }
+ }
+
+ public static Dataset<Row> addNullValueErrorTableCorruptRecordColumn(Dataset<Row> dataset) {
+ if (!isErrorTableCorruptRecordColumnPresent(dataset)) {
+ dataset = dataset.withColumn(ERROR_TABLE_CURRUPT_RECORD_COL_NAME, lit(null));
+ }
+ return dataset;
+ }
+
+ private static boolean isErrorTableCorruptRecordColumnPresent(Dataset<Row> dataset) {
+ return Arrays.stream(dataset.columns()).collect(Collectors.toList())
Review Comment:
can we simplify this
```
df.columns.contains(ERROR_TABLE_CURRUPT_RECORD_COL_NAME)
```
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org