diff --git a/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/ProvidesHoodieConfig.scala b/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/ProvidesHoodieConfig.scala index ffc4079824ffd..200e5327f7373 100644 --- a/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/ProvidesHoodieConfig.scala +++ b/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/ProvidesHoodieConfig.scala @@ -145,13 +145,14 @@ trait ProvidesHoodieConfig extends Logging { (enableBulkInsert, isOverwritePartition, isOverwriteTable, dropDuplicate, isNonStrictMode, isPartitionedTable) match { case (true, _, _, _, false, _) => throw new IllegalArgumentException(s"Table with primaryKey can not use bulk insert in ${insertMode.value()} mode.") - case (true, true, _, _, _, true) => - throw new IllegalArgumentException(s"Insert Overwrite Partition can not use bulk insert.") + // if enableBulkInsert is true, use bulk insert for the insert overwrite non-partitioned table. + case (true, _, true, _, _, _) => + throw new IllegalArgumentException(s"Insert Overwrite can not use bulk insert.") + case (true, true, _, _, _, _) => + throw new IllegalArgumentException(s"Insert Overwrite can not use bulk insert.") case (true, _, _, true, _, _) => throw new IllegalArgumentException(s"Bulk insert cannot support drop duplication." + s" Please disable $INSERT_DROP_DUPS and try again.") - // if enableBulkInsert is true, use bulk insert for the insert overwrite non-partitioned table. - case (true, false, true, _, _, false) => BULK_INSERT_OPERATION_OPT_VAL // insert overwrite table case (false, false, true, _, _, _) => INSERT_OVERWRITE_TABLE_OPERATION_OPT_VAL // insert overwrite partition diff --git a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestInsertTable.scala b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestInsertTable.scala index b33deebdf722f..a8bd0b5d69a20 100644 --- a/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestInsertTable.scala +++ b/hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestInsertTable.scala @@ -17,7 +17,6 @@ package org.apache.spark.sql.hudi -import org.apache.hudi.DataSourceReadOptions.SCHEMA_EVOLUTION_ENABLED import org.apache.hudi.DataSourceWriteOptions._ import org.apache.hudi.HoodieSparkUtils import org.apache.hudi.common.table.{HoodieTableMetaClient, TableSchemaResolver} @@ -568,8 +567,11 @@ class TestInsertTable extends HoodieSparkSqlTestBase { | tblproperties (primaryKey = 'id') | partitioned by (dt) """.stripMargin) - checkException(s"insert overwrite table $tableName3 partition(dt = '2021-07-18') values(1, 'a1', 10, '2021-07-18')")( - "Insert Overwrite Partition can not use bulk insert." + checkException(s"insert overwrite table $tableName3 partition(dt = '2021-07-18') values(1, 'a1', 10)")( + "Insert Overwrite can not use bulk insert." + ) + checkException(s"insert overwrite table $tableName3 values(1, 'a1', 10, '2021-07-18')")( + "Insert Overwrite can not use bulk insert." ) } } @@ -703,10 +705,6 @@ class TestInsertTable extends HoodieSparkSqlTestBase { checkAnswer(s"select id, name, price from $nonPartitionedTable")( Seq(1, "a1", 10.0) ) - spark.sql(s"insert overwrite table $nonPartitionedTable values(2, 'a2', 10)") - checkAnswer(s"select id, name, price from $nonPartitionedTable")( - Seq(2, "a2", 10.0) - ) spark.sql("set hoodie.sql.bulk.insert.enable = false") // Test CTAS for bulk insert