leesf commented on a change in pull request #2125:
URL: https://github.com/apache/hudi/pull/2125#discussion_r497482277
##########
File path: hudi-spark/src/main/scala/org/apache/hudi/IncrementalRelation.scala
##########
@@ -82,11 +81,11 @@ class IncrementalRelation(val sqlContext: SQLContext,
optParams.getOrElse(DataSourceReadOptions.END_INSTANTTIME_OPT_KEY,
lastInstant.getTimestamp))
.getInstants.iterator().toList
- // use schema from a file produced in the latest instant
- val latestSchema: StructType = {
+ // use schema from a file produced in the end instant
+ val endInstantSchema: StructType = {
log.info("Inferring schema..")
val schemaResolver = new TableSchemaResolver(metaClient)
- val tableSchema = schemaResolver.getTableAvroSchemaWithoutMetadataFields
+ val tableSchema =
schemaResolver.getTableAvroSchemaWithoutMetadataFields(commitsToReturn.last)
Review comment:
when `commitsToReturn` is empty (in case that user pass the end time
less than smallest commit in timeline), `commitsToReturn.last` will throw the
following exception
```java
java.util.NoSuchElementException
at
scala.collection.LinearSeqOptimized$class.last(LinearSeqOptimized.scala:148)
at scala.collection.immutable.List.last(List.scala:84)
at
org.apache.hudi.IncrementalRelation.<init>(IncrementalRelation.scala:88)
at org.apache.hudi.DefaultSource.createRelation(DefaultSource.scala:95)
at org.apache.hudi.DefaultSource.createRelation(DefaultSource.scala:51)
at
org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:318)
at
org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:223)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:211)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:178)
```
I think we would use the same behavior as before that use the latest commit
schema when `commitsToReturn` is empty, and there is no data returned since the
there is no commits between start and end time . @lw309637554 WDYT?
----------------------------------------------------------------
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:
[email protected]