You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2022/12/10 00:17:34 UTC
[GitHub] [hudi] jonvex commented on issue #7294: [SUPPORT] Different keygen class assigned by Hudi in 0.11.1 and 0.12.1 while creating a table with multiple primary keys
jonvex commented on issue #7294:
URL: https://github.com/apache/hudi/issues/7294#issuecomment-1344934173
I put this test in TestCreateTable.scala and it succeeds without error
```
test("Test Multiple Primary Key Default Keygen") {
withTempDir { tmp =>
val tableName = generateTableName
spark.sql(
s"""
|create table $tableName (
| id int,
| name string,
| price double,
| ts long
|) using hudi
| partitioned by (name)
| tblproperties (
| primaryKey = 'id,price',
| preCombineField = 'ts',
| type = 'cow'
| )
| location '${tmp.getCanonicalPath}'
""".stripMargin)
val table = spark.sessionState.catalog.getTableMetadata(TableIdentifier(tableName))
val tablePath = table.storage.properties("path")
val metaClient = HoodieTableMetaClient.builder()
.setBasePath(tablePath)
.setConf(spark.sessionState.newHadoopConf())
.build()
val tableConfig = metaClient.getTableConfig.getProps.asScala.toMap
assertResult("org.apache.hudi.keygen.ComplexKeyGenerator")(tableConfig(HoodieTableConfig.KEY_GENERATOR_CLASS_NAME.key()))
val source = scala.io.Source.fromFile(tmp.getCanonicalPath + "/.hoodie/hoodie.properties")
val lines = try source.mkString finally source.close()
assertResult(lines.contains("hoodie.table.recordkey.fields=id,price"))(true)
assertResult(lines.contains("hoodie.table.keygenerator.class=org.apache.hudi.keygen.ComplexKeyGenerator"))(true)
}
}
```
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org