lokeshj1703 commented on code in PR #8574:
URL: https://github.com/apache/hudi/pull/8574#discussion_r1178997841
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/transform/ChainedTransformer.java:
##########
@@ -46,9 +110,40 @@ public List<String> getTransformersNames() {
@Override
public Dataset<Row> apply(JavaSparkContext jsc, SparkSession sparkSession,
Dataset<Row> rowDataset, TypedProperties properties) {
Dataset<Row> dataset = rowDataset;
+ Schema incomingSchema = enableSchemaValidation ? sourceSchemaOpt.get() :
null;
Review Comment:
Addressed
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/transform/ChainedTransformer.java:
##########
@@ -46,9 +110,40 @@ public List<String> getTransformersNames() {
@Override
public Dataset<Row> apply(JavaSparkContext jsc, SparkSession sparkSession,
Dataset<Row> rowDataset, TypedProperties properties) {
Dataset<Row> dataset = rowDataset;
+ Schema incomingSchema = enableSchemaValidation ? sourceSchemaOpt.get() :
null;
for (Transformer t : transformers) {
- dataset = t.apply(jsc, sparkSession, dataset, properties);
+ String suffix = transformerToPropKeySuffix.get(t);
+ TypedProperties transformerProps = properties;
+ if (StringUtils.nonEmpty(suffix)) {
+ transformerProps = new TypedProperties(properties);
+ Map<String, Object> overrideKeysMap = new HashMap<>();
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ String key = (String) entry.getKey();
+ if (key.endsWith("." + suffix)) {
+ overrideKeysMap.put(key.substring(0, key.length() -
(suffix.length() + 1)), entry.getValue());
+ }
+ }
+ transformerProps.putAll(overrideKeysMap);
+ }
+ dataset = t.apply(jsc, sparkSession, dataset, transformerProps);
+ if (enableSchemaValidation) {
+ incomingSchema = validateAndGetTransformedSchema(t, dataset,
incomingSchema, jsc, sparkSession, properties);
+ }
}
return dataset;
}
+
+ private Schema validateAndGetTransformedSchema(Transformer transformer,
Dataset<Row> dataset, Schema incomingSchema,
+ JavaSparkContext jsc,
SparkSession sparkSession, TypedProperties properties) {
+ Schema targetSchema =
AvroConversionUtils.convertStructTypeToAvroSchema(dataset.schema(),
incomingSchema.getName(),
+ incomingSchema.getNamespace());
+ Schema expectedTargetSchema = transformer.schemaTransform(jsc,
sparkSession, incomingSchema, properties);
+ // TODO: Check the API arguments below
Review Comment:
Addressed
--
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]