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/05/05 07:41:17 UTC

[GitHub] [incubator-hudi] xushiyan commented on a change in pull request #1584: fix schema provider issue

xushiyan commented on a change in pull request #1584:
URL: https://github.com/apache/incubator-hudi/pull/1584#discussion_r419919337



##########
File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer/SourceFormatAdapter.java
##########
@@ -64,19 +64,22 @@ public SourceFormatAdapter(Source source) {
       }
       case ROW: {
         InputBatch<Dataset<Row>> r = ((RowSource) source).fetchNext(lastCkptStr, sourceLimit);
-        return new InputBatch<>(Option.ofNullable(r.getBatch().map(
-            rdd -> (
-                (r.getSchemaProvider() instanceof FilebasedSchemaProvider)
-                    // If the source schema is specified through Avro schema,
-                    // pass in the schema for the Row-to-Avro conversion
-                    // to avoid nullability mismatch between Avro schema and Row schema
-                    ? AvroConversionUtils.createRdd(
-                        rdd, r.getSchemaProvider().getSourceSchema(),
-                        HOODIE_RECORD_STRUCT_NAME, HOODIE_RECORD_NAMESPACE).toJavaRDD()
-                    : AvroConversionUtils.createRdd(
-                        rdd, HOODIE_RECORD_STRUCT_NAME, HOODIE_RECORD_NAMESPACE).toJavaRDD()
-                ))
-            .orElse(null)), r.getCheckpointForNextBatch(), r.getSchemaProvider());
+        if (r.getBatch().isPresent()) {

Review comment:
       > If I understand correctly, not specifying schema provider should be feasible in case of row based sources when you try to fetch the data in row format (i.e when using transformers).
   
   hi @pratyakshsharma I don't quite get this point. I'm referring to`fetchNewDataInAvroFormat()` being called when transformer is not set
   https://github.com/apache/incubator-hudi/blob/14d4fea8339913c0df8ea829036a45a187c55208/hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer/DeltaSync.java#L305-L306
   in case of ROW type source and no new data, `r.getSchemaProvider()` will throw an exception. 
   
   An example use case: reading a parquet source (ROW format) without setting either transformer or schemaprovider class, it works when new data keeps coming. But an exception will be thrown when no new data detected, calling `r.getSchemaProvider()` in this switch case will ask user to set schemaprovider.
   
   If in this example we still require users to set schema provider, then it conflicts with ROW source getting implicit schema. It seems like a usability issue.
   
   Could you confirm this understanding is accurate please?




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