[HUDI-4051] Allow nested field as primary key and preCombineField in spark sql (#5517)
* [HUDI-4051] Allow nested field as preCombineField in spark sql * relax validation for primary key
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package org.apache.spark.sql.hudi
|
||||
|
||||
import org.apache.hudi.DataSourceWriteOptions
|
||||
import org.apache.hudi.avro.HoodieAvroUtils.getRootLevelFieldName
|
||||
import org.apache.hudi.common.model.DefaultHoodieRecordPayload
|
||||
import org.apache.hudi.common.table.HoodieTableConfig
|
||||
import org.apache.hudi.common.util.ValidationUtils
|
||||
@@ -198,14 +199,14 @@ object HoodieOptionConfig {
|
||||
.map(_.split(",").filter(_.length > 0))
|
||||
ValidationUtils.checkArgument(primaryKeys.nonEmpty, "No `primaryKey` is specified.")
|
||||
primaryKeys.get.foreach { primaryKey =>
|
||||
ValidationUtils.checkArgument(schema.exists(f => resolver(f.name, primaryKey)),
|
||||
ValidationUtils.checkArgument(schema.exists(f => resolver(f.name, getRootLevelFieldName(primaryKey))),
|
||||
s"Can't find primaryKey `$primaryKey` in ${schema.treeString}.")
|
||||
}
|
||||
|
||||
// validate preCombine key
|
||||
val preCombineKey = sqlOptions.get(SQL_KEY_PRECOMBINE_FIELD.sqlKeyName)
|
||||
if (preCombineKey.isDefined && preCombineKey.get.nonEmpty) {
|
||||
ValidationUtils.checkArgument(schema.exists(f => resolver(f.name, preCombineKey.get)),
|
||||
ValidationUtils.checkArgument(schema.exists(f => resolver(f.name, getRootLevelFieldName(preCombineKey.get))),
|
||||
s"Can't find preCombineKey `${preCombineKey.get}` in ${schema.treeString}.")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user