nsivabalan commented on a change in pull request #4921: URL: https://github.com/apache/hudi/pull/4921#discussion_r818108395
########## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/schema/processor/DeleteSupportSchemaPostProcessor.java ########## @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hudi.utilities.schema.processor; + +import org.apache.hudi.AvroConversionUtils; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.utilities.schema.RowBasedSchemaProvider; + +import org.apache.avro.Schema; +import org.apache.spark.api.java.JavaSparkContext; +import org.apache.spark.sql.types.StructType; + +/** + * An implementation of {@link SchemaPostProcessor} which will add a column named "_hoodie_is_deleted" to the end of + * a given schema. + */ +public class DeleteSupportSchemaPostProcessor extends SchemaPostProcessor { + + public DeleteSupportSchemaPostProcessor(TypedProperties props, JavaSparkContext jssc) { + super(props, jssc); + } + + @Override + public Schema processSchema(Schema schema) { + if (schema == null) { + return null; + } + StructType targetSchema = AvroConversionUtils.convertAvroSchemaToStructType(schema) + .add("_hoodie_is_deleted", "boolean", true); + return AvroConversionUtils.convertStructTypeToAvroSchema( Review comment: do you strictly need the two way conversion? we actually plan to deprecate SparkAvroPostProcessor since the nullable is already fixed elsewhere. can you directly add the field to incoming avro schema and return it ? ########## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/schema/processor/SchemaPostProcessor.java ########## @@ -16,11 +16,12 @@ * limitations under the License. */ -package org.apache.hudi.utilities.schema; +package org.apache.hudi.utilities.schema.processor; Review comment: This class is a public class. unless we have strong reasons, would prefer to keep it that way. Just incase someone has their own impl out there in the open (it may break when they upgrade) -- 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]
