Search in sources :

Example 1 with DropColumnSchemaPostProcessor

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

the class TestSchemaPostProcessor method testDeleteColumn.

@Test
public void testDeleteColumn() {
    // remove column ums_id_ from source schema
    properties.put(DropColumnSchemaPostProcessor.Config.DELETE_COLUMN_POST_PROCESSOR_COLUMN_PROP, "rider");
    DropColumnSchemaPostProcessor processor = new DropColumnSchemaPostProcessor(properties, null);
    Schema schema = new Schema.Parser().parse(ORIGINAL_SCHEMA);
    Schema targetSchema = processor.processSchema(schema);
    assertNull(targetSchema.getField("rider"));
    assertNotNull(targetSchema.getField("_row_key"));
}
Also used : DropColumnSchemaPostProcessor(org.apache.hudi.utilities.schema.DropColumnSchemaPostProcessor) Schema(org.apache.avro.Schema) Test(org.junit.jupiter.api.Test)

Example 2 with DropColumnSchemaPostProcessor

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

the class TestSchemaPostProcessor method testDeleteColumnThrows.

@Test
public void testDeleteColumnThrows() {
    // remove all columns from source schema
    properties.put(DropColumnSchemaPostProcessor.Config.DELETE_COLUMN_POST_PROCESSOR_COLUMN_PROP, "timestamp,_row_key,rider,driver,fare");
    DropColumnSchemaPostProcessor processor = new DropColumnSchemaPostProcessor(properties, null);
    Schema schema = new Schema.Parser().parse(ORIGINAL_SCHEMA);
    Assertions.assertThrows(HoodieSchemaPostProcessException.class, () -> processor.processSchema(schema));
}
Also used : DropColumnSchemaPostProcessor(org.apache.hudi.utilities.schema.DropColumnSchemaPostProcessor) Schema(org.apache.avro.Schema) Test(org.junit.jupiter.api.Test)

Aggregations

Schema (org.apache.avro.Schema)2 DropColumnSchemaPostProcessor (org.apache.hudi.utilities.schema.DropColumnSchemaPostProcessor)2 Test (org.junit.jupiter.api.Test)2