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/17 12:09:23 UTC

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

pratyakshsharma commented on a change in pull request #1524: Adding a way to post process schema after it is fetched
URL: https://github.com/apache/incubator-hudi/pull/1524#discussion_r410180045
 
 

 ##########
 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:
   Can we try to use the one from TestHoodieDeltaStreamer? That would help avoid code duplication. 

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


With regards,
Apache Git Services