[GitHub] [hudi] nsivabalan commented on a change in pull request #3137: [HUDI-2061] Incorrect Schema Inference For Schema Evolved Table

2021-06-23 Thread GitBox


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



##
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:
   basically can we have a test which hits this else block(231). I assume 
all tests hit line 223. schema evol tests hits 227. 




-- 
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:
us...@infra.apache.org




[GitHub] [hudi] nsivabalan commented on a change in pull request #3137: [HUDI-2061] Incorrect Schema Inference For Schema Evolved Table

2021-06-23 Thread GitBox


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 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:
us...@infra.apache.org