nsivabalan commented on code in PR #8574:
URL: https://github.com/apache/hudi/pull/8574#discussion_r1189384384
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/transform/ChainedTransformer.java:
##########
@@ -109,6 +123,29 @@ private void validateIdentifier(String id, Set<String>
identifiers, String confi
}
}
+ private Option<Schema> validateAndGetTransformedSchema(TransformerInfo
transformerInfo, Dataset<Row> dataset, Option<Schema> incomingSchemaOpt,
+ JavaSparkContext jsc,
SparkSession sparkSession, TypedProperties properties) {
+ if (!incomingSchemaOpt.isPresent()) {
+ throw new HoodieSchemaException(String.format("Source schema not
available for transformer %s", transformerInfo));
+ }
+ Schema incomingSchema = incomingSchemaOpt.get();
+
+ // Get expected target schema from transformer and actual target schema
from struct
+ Schema targetSchema =
AvroConversionUtils.convertStructTypeToAvroSchema(dataset.schema(),
incomingSchema.getName(),
+ incomingSchema.getNamespace());
+ Option<Schema> expectedTargetSchemaOpt =
transformerInfo.getTransformer().transformedSchema(jsc, sparkSession,
incomingSchema, properties);
+ if (!expectedTargetSchemaOpt.isPresent()) {
+ throw new HoodieSchemaException(String.format("Expected target schema
not provided for transformer %s", transformerInfo));
+ }
+
+ Schema expectedTargetSchema = expectedTargetSchemaOpt.get();
+ if (!AvroSchemaUtils.isSchemaCompatible(expectedTargetSchema,
targetSchema, false, false)) {
Review Comment:
are we looking for schema equality or compatability?
if its equality, then probably you should do
```
!AvroSchemaUtils.isSchemaCompatible(expectedTargetSchema, targetSchema,
false, false) || !AvroSchemaUtils.isSchemaCompatible(targetSchema,
expectedTargetSchema, false, false)
```
##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/transform/ChainedTransformer.java:
##########
@@ -109,6 +123,29 @@ private void validateIdentifier(String id, Set<String>
identifiers, String confi
}
}
+ private Option<Schema> validateAndGetTransformedSchema(TransformerInfo
transformerInfo, Dataset<Row> dataset, Option<Schema> incomingSchemaOpt,
+ JavaSparkContext jsc,
SparkSession sparkSession, TypedProperties properties) {
+ if (!incomingSchemaOpt.isPresent()) {
+ throw new HoodieSchemaException(String.format("Source schema not
available for transformer %s", transformerInfo));
+ }
+ Schema incomingSchema = incomingSchemaOpt.get();
+
+ // Get expected target schema from transformer and actual target schema
from struct
+ Schema targetSchema =
AvroConversionUtils.convertStructTypeToAvroSchema(dataset.schema(),
incomingSchema.getName(),
+ incomingSchema.getNamespace());
+ Option<Schema> expectedTargetSchemaOpt =
transformerInfo.getTransformer().transformedSchema(jsc, sparkSession,
incomingSchema, properties);
+ if (!expectedTargetSchemaOpt.isPresent()) {
Review Comment:
we can move this to L 130 may be. just to fail fast.
--
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]