This is an automated email from the ASF dual-hosted git repository. yihua pushed a commit to branch branch-0.x in repository https://gitbox.apache.org/repos/asf/hudi.git
commit 1360b821ac6555c954862cc0e7f794825b360acf Author: majian <[email protected]> AuthorDate: Thu Feb 29 19:22:52 2024 +0800 [HUDI-7456] Set 'hudi' as the explicit provider for new table properties when create table by spark (#10776) --- .../apache/spark/sql/hudi/command/CreateHoodieTableCommand.scala | 7 ++++++- .../src/test/scala/org/apache/spark/sql/hudi/TestCreateTable.scala | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/command/CreateHoodieTableCommand.scala b/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/command/CreateHoodieTableCommand.scala index 3db9742aaf0..a857c3a5ded 100644 --- a/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/command/CreateHoodieTableCommand.scala +++ b/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/command/CreateHoodieTableCommand.scala @@ -145,12 +145,17 @@ object CreateHoodieTableCommand { val partitionColumnNames = hoodieCatalogTable.partitionSchema.map(_.name) // Remove some properties should not be used;append pk, preCombineKey, type to the properties of table - val newTblProperties = + var newTblProperties = hoodieCatalogTable.catalogProperties.--(needFilterProps) ++ HoodieOptionConfig.extractSqlOptions(properties) + + // Add provider -> hudi as a table property + newTblProperties = newTblProperties + ("provider" -> "hudi") + val newTable = table.copy( identifier = newTableIdentifier, storage = newStorage, schema = hoodieCatalogTable.tableSchema, + provider = Some("hudi"), partitionColumnNames = partitionColumnNames, createVersion = SPARK_VERSION, properties = newTblProperties diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestCreateTable.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestCreateTable.scala index 937d11af6be..52290ae48b1 100644 --- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestCreateTable.scala +++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestCreateTable.scala @@ -535,9 +535,10 @@ class TestCreateTable extends HoodieSparkSqlTestBase { )(table.schema.fields) // Should not include non.hoodie.property - assertResult(2)(table.properties.size) + assertResult(3)(table.properties.size) assertResult("cow")(table.properties("type")) assertResult("id,name")(table.properties("primaryKey")) + assertResult("hudi")(table.properties("provider")) } } }
