pratyakshsharma commented on a change in pull request #5031: URL: https://github.com/apache/hudi/pull/5031#discussion_r830484809
########## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/schema/AddColumnSchemaPostProcessor.java ########## @@ -0,0 +1,172 @@ +/* + * 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; + +import org.apache.hudi.common.config.ConfigProperty; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.model.HoodieRecord; +import org.apache.hudi.utilities.exception.HoodieSchemaPostProcessException; + +import org.apache.avro.LogicalTypes; +import org.apache.avro.Schema; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.api.java.JavaSparkContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +/** + * A {@link SchemaPostProcessor} use to add column to given schema. Currently. only supports adding one column at a time. + * Users can specify the position of new column by config {@link Config#SCHEMA_POST_PROCESSOR_ADD_COLUMN_NEXT_PROP}, + * the new column will be added before this column. + * <p> + * Currently supported types : bytes, string, int, long, float, double, boolean, decimal + */ +public class AddColumnSchemaPostProcessor extends SchemaPostProcessor { + + private static final Logger LOG = LogManager.getLogger(AddColumnSchemaPostProcessor.class); + + public AddColumnSchemaPostProcessor(TypedProperties props, JavaSparkContext jssc) { + super(props, jssc); + } + + /** + * Configs supported. + */ + public static class Config { + public static final ConfigProperty<String> SCHEMA_POST_PROCESSOR_ADD_COLUMN_NAME_PROP = ConfigProperty + .key("hoodie.deltastreamer.schemaprovider.schema_post_processor.add.column.name") + .noDefaultValue() + .withDocumentation("New column's name"); + + public static final ConfigProperty<String> SCHEMA_POST_PROCESSOR_ADD_COLUMN_TYPE_PROP = ConfigProperty + .key("hoodie.deltastreamer.schemaprovider.schema_post_processor.add.column.type") + .noDefaultValue() + .withDocumentation("New column's type"); + + public static final ConfigProperty<String> SCHEMA_POST_PROCESSOR_ADD_COLUMN_DOC_PROP = ConfigProperty + .key("hoodie.deltastreamer.schemaprovider.schema_post_processor.add.column.doc") + .noDefaultValue() + .withDocumentation("New column's doc"); + + public static final ConfigProperty<String> SCHEMA_POST_PROCESSOR_ADD_COLUMN_DEFAULT_PROP = ConfigProperty + .key("hoodie.deltastreamer.schemaprovider.schema_post_processor.add.column.default") + .noDefaultValue() + .withDocumentation("New column's default value"); + + public static final ConfigProperty<String> SCHEMA_POST_PROCESSOR_ADD_COLUMN_SIZE_PROP = ConfigProperty + .key("hoodie.deltastreamer.schemaprovider.schema_post_processor.add.column.size") + .noDefaultValue() + .withDocumentation("New column's size, used in decimal type"); + + public static final ConfigProperty<String> SCHEMA_POST_PROCESSOR_ADD_COLUMN_PRECISION_PROP = ConfigProperty + .key("hoodie.deltastreamer.schemaprovider.schema_post_processor.add.column.precision") + .noDefaultValue() + .withDocumentation("New column's precision, used in decimal type"); + + public static final ConfigProperty<String> SCHEMA_POST_PROCESSOR_ADD_COLUMN_SCALE_PROP = ConfigProperty + .key("hoodie.deltastreamer.schemaprovider.schema_post_processor.add.column.scale") + .noDefaultValue() + .withDocumentation("New column's precision, used in decimal type"); Review comment: what is the difference between SCHEMA_POST_PROCESSOR_ADD_COLUMN_SCALE_PROP and SCHEMA_POST_PROCESSOR_ADD_COLUMN_PRECISION_PROP? Both have the same documentation. -- 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]
