pengzhiwei2018 commented on a change in pull request #3393:
URL: https://github.com/apache/hudi/pull/3393#discussion_r682235910
##########
File path:
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/analysis/HoodieAnalysis.scala
##########
@@ -268,7 +269,25 @@ case class HoodieResolveReferences(sparkSession:
SparkSession) extends Rule[Logi
} else {
l
}
-
+ // Fill schema for Create Table without specify schema info
+ case c @ CreateTable(tableDesc, _, _)
+ if isHoodieTable(tableDesc) =>
+ val tablePath = getTableLocation(c.tableDesc, sparkSession)
+ .getOrElse(s"Missing location defined in table
${c.tableDesc.identifier}")
+ val metaClient = HoodieTableMetaClient.builder()
+ .setBasePath(tablePath)
+ .setConf(sparkSession.sessionState.newHadoopConf())
+ .build()
+ val tableSchema =
HoodieSqlUtils.getTableSqlSchema(metaClient).map(HoodieSqlUtils.addMetaFields)
+ if (tableSchema.isDefined && tableDesc.schema.isEmpty) {
+ // Fill the schema with the schema from the table
+ c.copy(tableDesc.copy(schema = tableSchema.get))
+ } else if (tableSchema.isDefined && tableDesc.schema !=
tableSchema.get) {
Review comment:
well, In scala, we usually use "=" or "!=" test compile two object.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]