You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/04/20 17:08:38 UTC

[GitHub] [incubator-hudi] afilipchik commented on a change in pull request #1524: [HUDI-801] Adding a way to post process schema after it is fetched

afilipchik commented on a change in pull request #1524:
URL: https://github.com/apache/incubator-hudi/pull/1524#discussion_r411546036



##########
File path: hudi-utilities/src/test/java/org/apache/hudi/utilities/TestSchemaPostProcessor.java
##########
@@ -0,0 +1,61 @@
+package org.apache.hudi.utilities;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import org.apache.avro.Schema;
+import org.apache.avro.Schema.Type;
+import org.apache.avro.SchemaBuilder;
+import org.apache.hudi.common.config.TypedProperties;
+import org.apache.hudi.common.util.collection.Pair;
+import org.apache.hudi.utilities.schema.SchemaPostProcessor;
+import org.apache.hudi.utilities.schema.SchemaProvider;
+import org.apache.hudi.utilities.schema.SchemaProvider.Config;
+import org.apache.spark.api.java.JavaSparkContext;
+import org.junit.Test;
+
+public class TestSchemaPostProcessor {
+
+  private TypedProperties properties = new TypedProperties();
+
+  @Test
+  public void testPostProcessor() throws IOException {
+    properties.put(Config.SCHEMA_POST_PROCESSOR_PROP, DummySchemaPostProcessor.class.getName());
+
+    JavaSparkContext jsc =
+        UtilHelpers.buildSparkContext(this.getClass().getName() + "-hoodie", "local[2]");
+    SchemaProvider provider =
+        UtilHelpers.createSchemaProvider(DummySchemaProvider.class.getName(), properties, jsc);
+
+    Schema schema = provider.getSourceSchema();
+    assertEquals(schema.getType(), Type.RECORD);
+    assertEquals(schema.getName(), "test");
+    assertNotNull(schema.getField("testString"));
+  }
+
+  public static class DummySchemaProvider extends SchemaProvider {

Review comment:
       done




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org