hudi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [hudi] nsivabalan commented on a change in pull request #3137: [HUDI-2061] Incorrect Schema Inference For Schema Evolved Table
Date Thu, 24 Jun 2021 03:39:31 GMT

nsivabalan commented on a change in pull request #3137:
URL: https://github.com/apache/hudi/pull/3137#discussion_r657598480



##########
File path: hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/DefaultSource.scala
##########
@@ -213,11 +214,27 @@ class DefaultSource extends RelationProvider
         classOf[HoodieROTablePathFilter],
         classOf[org.apache.hadoop.fs.PathFilter])
 
+      val specifySchema = if (schema == null) {
+        // Load the schema from the commit meta data.
+        // Here we should specify the schema to the latest commit schema since
+        // the table schema evolution.
+        val schemaUtil = new TableSchemaResolver(metaClient)

Review comment:
       can we name the variable as "tableSchemaResolver". 

##########
File path: hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/DefaultSource.scala
##########
@@ -213,11 +214,27 @@ class DefaultSource extends RelationProvider
         classOf[HoodieROTablePathFilter],
         classOf[org.apache.hadoop.fs.PathFilter])
 
+      val specifySchema = if (schema == null) {
+        // Load the schema from the commit meta data.
+        // Here we should specify the schema to the latest commit schema since
+        // the table schema evolution.
+        val schemaUtil = new TableSchemaResolver(metaClient)
+        try {
+          Some(SchemaConverters.toSqlType(schemaUtil.getTableAvroSchema)
+            .dataType.asInstanceOf[StructType])
+        } catch {
+          case _: Throwable =>
+            None // If there is no commit in the table, we can not get the schema
+                 // with schemaUtil, return None here.
+        }
+      } else {
+        None

Review comment:
       shouldn't this be Option.of(schema) ? 

##########
File path: hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/DefaultSource.scala
##########
@@ -213,11 +214,27 @@ class DefaultSource extends RelationProvider
         classOf[HoodieROTablePathFilter],
         classOf[org.apache.hadoop.fs.PathFilter])
 
+      val specifySchema = if (schema == null) {
+        // Load the schema from the commit meta data.
+        // Here we should specify the schema to the latest commit schema since
+        // the table schema evolution.
+        val schemaUtil = new TableSchemaResolver(metaClient)
+        try {
+          Some(SchemaConverters.toSqlType(schemaUtil.getTableAvroSchema)

Review comment:
       Ideally getTableAvroSchema should return Option<Schema> and callers should check
if present and proceed accordingly. But in the interest of unblocking others, I am ok with
this change. 




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



Mime
View raw message