jiegzhan opened a new issue #2051:
URL: https://github.com/apache/hudi/issues/2051


   **Step 1: I created a hudi table and inserted 4 records with this query:**
   ```
   val hudiConfig = Map[String, String](
     "hoodie.datasource.write.table.type" -> "COPY_ON_WRITE",
     "hoodie.datasource.write.recordkey.field" -> "word",
     "hoodie.datasource.write.precombine.field" -> "word",
     "hoodie.datasource.write.partitionpath.field" -> "",
     "hoodie.datasource.write.keygenerator.class" -> 
"org.apache.hudi.keygen.NonpartitionedKeyGenerator",
     "hoodie.datasource.write.hive_style_partitioning" -> "true",
     "hoodie.datasource.hive_sync.database" -> "default",
     "hoodie.datasource.hive_sync.table" -> tableName,
     "hoodie.datasource.hive_sync.username" -> "hadoop",
     "hoodie.datasource.hive_sync.partition_fields" -> "",
     "hoodie.datasource.hive_sync.enable" -> "true",
     "hoodie.datasource.hive_sync.partition_extractor_class" -> 
classOf[NonPartitionedExtractor].getCanonicalName,
     "hoodie.combine.before.insert" -> "false",
     "hoodie.combine.before.upsert" -> "false",
     "hoodie.parquet.max.file.size" -> "2000000000",
     "hoodie.parquet.block.size" -> "2000000000",
     "hoodie.parquet.small.file.limit" -> "512000000",
     "hoodie.cleaner.commits.retained" -> "1"
   )
   
   val insertRecords = Seq(
     ("java", 3),
     ("java", 56),
     ("python", 19),
     ("scala", -28)
   ).toDF("word", "number")
   
   insertRecords.
     write.format("org.apache.hudi").
     option(HoodieWriteConfig.TABLE_NAME, tableName).
     option("hoodie.datasource.write.operation", "insert").
     options(hudiConfig).
     mode(SaveMode.Append).
     save(tablePath)
   ```
   
   Result looks like this:
   ```
   
+-------------------+--------------------+------------------+----------------------+--------------------+------+------+
   
|_hoodie_commit_time|_hoodie_commit_seqno|_hoodie_record_key|_hoodie_partition_path|
   _hoodie_file_name|  word|number|
   
+-------------------+--------------------+------------------+----------------------+--------------------+------+------+
   |     20200829004101|  20200829004101_0_1|              java|                
      |fd94def5-1ecd-453...|  java|     3|
   |     20200829004101|  20200829004101_0_2|              java|                
      |fd94def5-1ecd-453...|  java|    56|
   |     20200829004101|  20200829004101_0_3|            python|                
      |fd94def5-1ecd-453...|python|    19|
   |     20200829004101|  20200829004101_0_4|             scala|                
      |fd94def5-1ecd-453...| scala|   -28|
   
+-------------------+--------------------+------------------+----------------------+--------------------+------+------+
   ```
   
   **Step 2: I tried to insert a new record with this query:**
   ```
   val insertNewRecords = Seq(("java", 999999)).toDF("word", "number")
   
   insertNewRecords.
     write.format("org.apache.hudi").
     option(HoodieWriteConfig.TABLE_NAME, tableName).
     option("hoodie.datasource.write.operation", "insert").
     options(hudiConfig).
     mode(SaveMode.Append).
     save(tablePath)
   ```
   Result looks like this:
   ```
   
+-------------------+--------------------+------------------+----------------------+--------------------+------+------+
   
|_hoodie_commit_time|_hoodie_commit_seqno|_hoodie_record_key|_hoodie_partition_path|
   _hoodie_file_name|  word|number|
   
+-------------------+--------------------+------------------+----------------------+--------------------+------+------+
   |     20200829004331|  20200829004331_0_5|              java|                
      |fd94def5-1ecd-453...|  java|999999|
   |     20200829004331|  20200829004331_0_6|              java|                
      |fd94def5-1ecd-453...|  java|999999|
   |     20200829004101|  20200829004101_0_3|            python|                
      |fd94def5-1ecd-453...|python|    19|
   |     20200829004101|  20200829004101_0_4|             scala|                
      |fd94def5-1ecd-453...| scala|   -28|
   
+-------------------+--------------------+------------------+----------------------+--------------------+------+------+
   ```
   
   How come `insert operation didn't insert a new row, but updated existing 
records`? `upsert operation` should do this.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to