Search in sources :

Example 1 with SchemaPostProcessor

use of org.apache.hudi.utilities.schema.SchemaPostProcessor in project hudi by apache.

the class TestSchemaPostProcessor method testChainedSchemaPostProcessor.

@Test
public void testChainedSchemaPostProcessor() {
    // DeleteSupportSchemaPostProcessor first, DummySchemaPostProcessor second
    properties.put(Config.SCHEMA_POST_PROCESSOR_PROP, "org.apache.hudi.utilities.schema.DeleteSupportSchemaPostProcessor,org.apache.hudi.utilities.DummySchemaPostProcessor");
    SchemaPostProcessor processor = UtilHelpers.createSchemaPostProcessor(properties.getString(Config.SCHEMA_POST_PROCESSOR_PROP), properties, jsc);
    Schema schema = new Schema.Parser().parse(ORIGINAL_SCHEMA);
    Schema targetSchema = processor.processSchema(schema);
    assertNull(targetSchema.getField("_row_key"));
    assertNull(targetSchema.getField("_hoodie_is_deleted"));
    assertNotNull(targetSchema.getField("testString"));
    // DummySchemaPostProcessor first, DeleteSupportSchemaPostProcessor second
    properties.put(Config.SCHEMA_POST_PROCESSOR_PROP, "org.apache.hudi.utilities.DummySchemaPostProcessor,org.apache.hudi.utilities.schema.DeleteSupportSchemaPostProcessor");
    processor = UtilHelpers.createSchemaPostProcessor(properties.getString(Config.SCHEMA_POST_PROCESSOR_PROP), properties, jsc);
    schema = new Schema.Parser().parse(ORIGINAL_SCHEMA);
    targetSchema = processor.processSchema(schema);
    assertNull(targetSchema.getField("_row_key"));
    assertNotNull(targetSchema.getField("_hoodie_is_deleted"));
    assertNotNull(targetSchema.getField("testString"));
}
Also used : Schema(org.apache.avro.Schema) DropColumnSchemaPostProcessor(org.apache.hudi.utilities.schema.DropColumnSchemaPostProcessor) DeleteSupportSchemaPostProcessor(org.apache.hudi.utilities.schema.DeleteSupportSchemaPostProcessor) SchemaPostProcessor(org.apache.hudi.utilities.schema.SchemaPostProcessor) Test(org.junit.jupiter.api.Test)

Aggregations

Schema (org.apache.avro.Schema)1 DeleteSupportSchemaPostProcessor (org.apache.hudi.utilities.schema.DeleteSupportSchemaPostProcessor)1 DropColumnSchemaPostProcessor (org.apache.hudi.utilities.schema.DropColumnSchemaPostProcessor)1 SchemaPostProcessor (org.apache.hudi.utilities.schema.SchemaPostProcessor)1 Test (org.junit.jupiter.api.Test)1