pengzhiwei2018 commented on a change in pull request #2485:
URL: https://github.com/apache/hudi/pull/2485#discussion_r565127786
##########
File path:
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/DefaultSource.scala
##########
@@ -181,4 +184,35 @@ class DefaultSource extends RelationProvider
.resolveRelation()
}
}
+
+ override def sourceSchema(sqlContext: SQLContext,
+ schema: Option[StructType],
+ providerName: String,
+ parameters: Map[String, String]): (String,
StructType) = {
+ val path = parameters.get("path")
+ if (path.isEmpty || path.get == null) {
+ throw new HoodieException(s"'path' must be specified.")
+ }
+ val metaClient = new HoodieTableMetaClient(
+ sqlContext.sparkSession.sessionState.newHadoopConf(), path.get)
+ val schemaResolver = new TableSchemaResolver(metaClient)
+ val sqlSchema =
+ try {
+ val avroSchema = schemaResolver.getTableAvroSchema
+
SchemaConverters.toSqlType(avroSchema).dataType.asInstanceOf[StructType]
Review comment:
That's all right. I will have a try.
----------------------------------------------------------------
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]