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 2021/07/20 16:35:19 UTC

[GitHub] [hudi] mkk1490 opened a new issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

mkk1490 opened a new issue #3313:
URL: https://github.com/apache/hudi/issues/3313


   **_Tips before filing an issue_**
   
   - Have you gone through our [FAQs](https://cwiki.apache.org/confluence/display/HUDI/FAQ)?
   
   - Join the mailing list to engage in conversations and get faster support at dev-subscribe@hudi.apache.org.
   
   - If you have triaged this as a bug, then file an [issue](https://issues.apache.org/jira/projects/HUDI/issues) directly.
   
   **Describe the problem you faced**
   
   A batch process with updates to the existing tables in Datalake. These are Hive external partitioned tables with location pointed to a s3 directory. I'm working on PoC to migrate all the tables to Hudi. I did a bulk_insert for IDL and everything went fine. For upserts, I have a problem. My primary key combo has a timestamp field in it. I have added all the required config in my code. Data are getting duplicated because of the timestamp field generating differently in the recordkey.field while upsert operation. Below are my hudi options:
   hudi_options = {
         'hoodie.table.name': 'f_claim_mdcl_hudi_cow',
         'hoodie.datasource.write.recordkey.field': 'claim_id,pat_id,claim_subm_dt,plac_of_srvc_cd,src_pri_psbr_id,src_plan_id'
         'hoodie.datasource.write.partitionpath.field': 'src_sys_nm,yr_mth',
         'hoodie.datasource.write.table.Type': 'COPY_ON_WRITE', 
         'hoodie.datasource.write.table.name': 'f_hudi_cow',
       #   'hoodie.combine.before.insert': 'false',
         'hoodie.combine.before.upsert': 'true',
         'hoodie.datasource.hive_sync.enable': 'true',
         'hoodie.datasource.hive_sync.table': 'f_hudi_cow',
         'hoodie.datasource.hive_sync.partition_fields': 'src_sys_nm,yr_mth',
         'hoodie.datasource.hive_sync.partition_extractor_class': 'org.apache.hudi.hive.MultiPartKeysValueExtractor',
         'hoodie.datasource.write.hive_style_partitioning': 'true',
         'hoodie.datasource.hive_sync.database': 'us_commercial_datalake_app_commons_dev',
         'hoodie.datasource.hive_sync.support_timestamp': 'true',
         'hoodie.datasource.hive_sync.auto_create_db':'false',
         'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.ComplexKeyGenerator',
         'hoodie.datasource.write.row.writer.enable': 'true',
         'hoodie.parquet.small.file.limit': '600000000', 
         'hoodie.parquet.max.file.size': '1000000000',
         'hoodie.upsert.shuffle.parallelism': '10000',
         'hoodie.insert.shuffle.parallelism': '10000',
         'hoodie.clean.automatic': 'false',
         'hoodie.cleaner.commits.retained': 3,
         'hoodie.index.type': 'GLOBAL_SIMPLE',
         'hoodie.simple.index.update.partition.path':'true',
         'hoodie.metadata.enable': 'true'
       }
   
   df.write.format("org.apache.hudi"). \
                                   options(**hudi_options).option('hoodie.datasource.write.operation', 'upsert'). \
                                   mode("APPEND"). \
                                   save("{s3_path}")
   I don't get any errors while processing. My record key for the bulk insert looks like this:
   
   claim_id:10420217599403398158,pat_id:8607357348,**claim_subm_dt:2020-11-21 00:00:00.0**,plac_of_srvc_cd:INPATIENT HOSPITAL,src_pri_psbr_id:7605954,src_plan_id:0009659999
   
   record key for the upsert operation for the same record:
   
   claim_id:10420217599403398158,pat_id:8607357348,**claim_subm_dt:1605916800000000**,plac_of_srvc_cd:INPATIENT HOSPITAL,src_pri_psbr_id:7605954,src_plan_id:0009659999
   
   **To Reproduce**
   
   Steps to reproduce the behavior:
   
   1. Generate a set of records with timestamp as one of the primary keys in Hive external table stored on s3
   2. Load the same set of records with mode("append") and option('hoodie.datasource.write.operation', 'upsert')
   3. Check for duplicates excluding in the data
   
   **Expected behavior**
   
   No duplicates in the data. Recordkey.field to remain the same for timestamp field and not get converted to long
   
   **Environment Description** 
   
   * Hudi version : 0.7.0 installed in EMR 5.33
   
   * Spark version : 2.4.7
   
   * Hive version : 2.3.7
   
   * Hadoop version : Amazon 2.10.1
   
   * Storage (HDFS/S3/GCS..) : s3
   
   * Running on Docker? (yes/no) : No
   
   
   **Additional context**
   
   Add any other context about the problem here.
   
   **Stacktrace**
   
   ```Add the stacktrace of the error.```
   
   


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



[GitHub] [hudi] mkk1490 edited a comment on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
mkk1490 edited a comment on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-884708261


   @nsivabalan during bulk_insert as well as insert for the first time into the table, the hoodie_key value was in timestamp. But during the upsert operation, it was converted into long. I even added a step just before write to convert to timestamp. It still didn't work. But when the field's datatype is date, this issue didn't come up.
   
   Sample data with original code:
   1. Hive external table with location pointing to s3 partitioned by src_sys_nm string(static value) and yr_mth int(dynamic value) both string
   2. This code was executed on EMR 5.33 with hudi 0.7.0
   3. Sample data has 2 different partition values for yr_mth where update is required
   Step 1:
   from pyspark.sql import functions as F
   df = spark.createDataFrame([
   ('10490113453106300000','561295328','2018-02-26 00:00:00','129999','18078735','15889231','OTHER PLACE OF SERVICE','53200900','RESP','201802'),
   ('10490120407605900000','559017519','2018-02-26 00:00:00','24290619','0','','OTHER PLACE OF SERVICE','53214384','RESP','201802'),
   ('10490116725506700000','1275017082','2018-02-27 00:00:00','209999','7875173','56874023','INPATIENT HOSPITAL','53201132','RESP','201802'),
   ('10420113469301100000','1705523399','2018-02-26 00:00:00','20045','7088459','55674640','EMERGENCY ROOM - HOSPITAL','53199046','RESP','201802'),
   ('10419114183800600000','29764982','2018-02-26 00:00:00','11659999','7786313','56694289','OFFICE','53207492','RESP','201802'),
   ('10490115064904900000','5007290360','2018-02-27 00:00:00','11720002','6937467','57968295','INPATIENT HOSPITAL','53207546','RESP','201803'),
   ('10419114186102800000','4968929315','2018-02-27 00:00:00','38930013','7311494','55315237','OFFICE','1002607736','RESP','201803'),
   ('10236114374904400000','320648979','2018-02-26 00:00:00','35160001','0','','INDEPENDENT LABORATORY','53217687','RESP','201803'),
   ('10809131289117500000','505439892','2018-02-28 00:00:00','20860001','2492213','52847481','OTHER PLACE OF SERVICE','53212703','RESP','201803'),
   ('10419123011601800000','3138080815','2018-02-25 00:00:00','32060002','7574212','58923898','INPATIENT HOSPITAL','1002608174','RESP','201803') ],
   ['claim_id','pat_id','claim_subm_dt','src_plan_id','src_pri_psbr_id','pri_az_cust_id','plac_of_srvc_cd','az_plan_id','src_sys_nm','yr_mth'] ).withColumn('claim_subm_dt', F.expr("cast(claim_subm_dt as timestamp)")).withColumn('yr_mth', F.expr("cast(yr_mth as int)"))
   
   hudi_options = {
   'hoodie.table.name': 'f_hudi_cow',
   'hoodie.datasource.write.recordkey.field': 'claim_id,pat_id,claim_subm_dt,plac_of_srvc_cd,src_pri_psbr_id,src_plan_id'
   'hoodie.datasource.write.partitionpath.field': 'src_sys_nm,yr_mth',
   'hoodie.datasource.write.table.Type': 'COPY_ON_WRITE',
   'hoodie.datasource.write.table.name': 'f_hudi_cow',
   'hoodie.combine.before.upsert': 'true',
   'hoodie.datasource.hive_sync.enable': 'true',
   'hoodie.datasource.hive_sync.table': 'f_hudi_cow',
   'hoodie.datasource.hive_sync.partition_fields': 'src_sys_nm,yr_mth',
   'hoodie.datasource.hive_sync.partition_extractor_class': 'org.apache.hudi.hive.MultiPartKeysValueExtractor',
   'hoodie.datasource.write.hive_style_partitioning': 'true',
   'hoodie.datasource.hive_sync.database': 'us_commercial_datalake_app_commons_dev',
   'hoodie.datasource.hive_sync.support_timestamp': 'true',
   'hoodie.datasource.hive_sync.auto_create_db':'false',
   'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.ComplexKeyGenerator',
   'hoodie.datasource.write.row.writer.enable': 'true',
   'hoodie.parquet.small.file.limit': '600000000',
   'hoodie.parquet.max.file.size': '1000000000',
   'hoodie.upsert.shuffle.parallelism': '10000',
   'hoodie.insert.shuffle.parallelism': '10000',
   'hoodie.bulkinsert.shuffle.parallelism': '25',
   'hoodie.clean.automatic': 'false',
   'hoodie.cleaner.commits.retained': 3,
   'hoodie.index.type': 'GLOBAL_SIMPLE',
   'hoodie.simple.index.update.partition.path':'true',
   'hoodie.metadata.enable': 'true'
   }
   
   df.write.format("org.apache.hudi").
   options(**hudi_options).option('hoodie.datasource.write.operation', 'bulk_insert').
   mode("overwrite").
   save("{s3_path}")
   
   Step 2:
   **Upsert has values 0 changed to 100. Updated Field name: src_pri_psbr_id**
   
   df_upsert  =spark.createDataFrame([
   ('10490113453106300000','561295328','2018-02-26 00:00:00','129999','18078735','15889231','OTHER PLACE OF SERVICE','53200900','RESP','201802'),
   ('10490120407605900000','559017519','2018-02-26 00:00:00','24290619','100','','OTHER PLACE OF SERVICE','53214384','RESP','201802'),
   ('10490116725506700000','1275017082','2018-02-27 00:00:00','209999','7875173','56874023','INPATIENT HOSPITAL','53201132','RESP','201802'),
   ('10420113469301100000','1705523399','2018-02-26 00:00:00','20045','7088459','55674640','EMERGENCY ROOM - HOSPITAL','53199046','RESP','201802'),
   ('10419114183800600000','29764982','2018-02-26 00:00:00','11659999','7786313','56694289','OFFICE','53207492','RESP','201802'),
   ('10490115064904900000','5007290360','2018-02-27 00:00:00','11720002','6937467','57968295','INPATIENT HOSPITAL','53207546','RESP','201803'),
   ('10419114186102800000','4968929315','2018-02-27 00:00:00','38930013','7311494','55315237','OFFICE','1002607736','RESP','201803'),
   ('10236114374904400000','320648979','2018-02-26 00:00:00','35160001','100','','INDEPENDENT LABORATORY','53217687','RESP','201803'),
   ('10809131289117500000','505439892','2018-02-28 00:00:00','20860001','2492213','52847481','OTHER PLACE OF SERVICE','53212703','RESP','201803'),
   ('10419123011601800000','3138080815','2018-02-25 00:00:00','32060002','7574212','58923898','INPATIENT HOSPITAL','1002608174','RESP','201803') ],
   ['claim_id','pat_id','claim_subm_dt','src_plan_id','src_pri_psbr_id','pri_az_cust_id','plac_of_srvc_cd','az_plan_id','src_sys_nm','yr_mth'] ).withColumn('claim_subm_dt', F.expr("cast(claim_subm_dt as timestamp)")).withColumn('yr_mth', F.expr("cast(yr_mth as int)"))
   
   hudi_options = {
   'hoodie.table.name': 'f_hudi_cow',
   'hoodie.datasource.write.recordkey.field': 'claim_id,pat_id,claim_subm_dt,plac_of_srvc_cd,src_pri_psbr_id,src_plan_id'
   'hoodie.datasource.write.partitionpath.field': 'src_sys_nm,yr_mth',
   'hoodie.datasource.write.table.Type': 'COPY_ON_WRITE',
   'hoodie.datasource.write.table.name': 'f_hudi_cow',
   'hoodie.combine.before.upsert': 'true',
   'hoodie.datasource.hive_sync.enable': 'true',
   'hoodie.datasource.hive_sync.table': 'f_hudi_cow',
   'hoodie.datasource.hive_sync.partition_fields': 'src_sys_nm,yr_mth',
   'hoodie.datasource.hive_sync.partition_extractor_class': 'org.apache.hudi.hive.MultiPartKeysValueExtractor',
   'hoodie.datasource.write.hive_style_partitioning': 'true',
   'hoodie.datasource.hive_sync.database': 'us_commercial_datalake_app_commons_dev',
   'hoodie.datasource.hive_sync.support_timestamp': 'true',
   'hoodie.datasource.hive_sync.auto_create_db':'false',
   'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.ComplexKeyGenerator',
   'hoodie.datasource.write.row.writer.enable': 'true',
   'hoodie.parquet.small.file.limit': '600000000',
   'hoodie.parquet.max.file.size': '1000000000',
   'hoodie.upsert.shuffle.parallelism': '10000',
   'hoodie.insert.shuffle.parallelism': '10000',
   'hoodie.bulkinsert.shuffle.parallelism': '25',
   'hoodie.clean.automatic': 'false',
   'hoodie.cleaner.commits.retained': 3,
   'hoodie.index.type': 'GLOBAL_SIMPLE',
   'hoodie.simple.index.update.partition.path':'true',
   'hoodie.metadata.enable': 'true'
   }
   
   df.write.format("org.apache.hudi").
   options(**hudi_options).option('hoodie.datasource.write.operation', 'upsert').
   mode("append").
   save("{s3_path}")
   
   Expected output: src_pri_psbr_id field value- 0 to be updated to 100
   


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



[GitHub] [hudi] nsivabalan commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-889903261


   cool. so we know the root cause atleast. @codope is looking into it. we should have a fix soon. 
   @mkk1490 : So, just to summarize, if not for row writer path, things are working fine for you. But bulk_insert perf is not meeting your SLA. So, we need to fix the bulk_insert row writer path for this key gen issue. 


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



[GitHub] [hudi] nsivabalan commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-894482942


   @codope : any updates on this. Can you please follow through.


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



[GitHub] [hudi] mkk1490 commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
mkk1490 commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-886010620


   @nsivabalan I'm so sorry. That's my mistake. I'm trying to update the next field to src_pri_psbr_id which is pri_az_cust_id. Please find the dfs below:
   
   Insert:
   df_ins = spark.createDataFrame([
   ('10490113453106300000','561295328','2018-02-26 00:00:00','129999','18078735','15889231','OTHER PLACE OF SERVICE','53200900','RESP','201802'),
   ('10490120407605900000','559017519','2018-02-26 00:00:00','24290619','100','','OTHER PLACE OF SERVICE','53214384','RESP','201802'),
   ('10490116725506700000','1275017082','2018-02-27 00:00:00','209999','7875173','56874023','INPATIENT HOSPITAL','53201132','RESP','201802'),
   ('10420113469301100000','1705523399','2018-02-26 00:00:00','20045','7088459','55674640','EMERGENCY ROOM - HOSPITAL','53199046','RESP','201802'),
   ('10419114183800600000','29764982','2018-02-26 00:00:00','11659999','7786313','56694289','OFFICE','53207492','RESP','201802'),
   ('10490115064904900000','5007290360','2018-02-27 00:00:00','11720002','6937467','57968295','INPATIENT HOSPITAL','53207546','RESP','201803'),
   ('10419114186102800000','4968929315','2018-02-27 00:00:00','38930013','7311494','55315237','OFFICE','1002607736','RESP','201803'),
   ('10236114374904400000','320648979','2018-02-26 00:00:00','35160001','100','','INDEPENDENT LABORATORY','53217687','RESP','201803'),
   ('10809131289117500000','505439892','2018-02-28 00:00:00','20860001','2492213','52847481','OTHER PLACE OF SERVICE','53212703','RESP','201803'),
   ('10419123011601800000','3138080815','2018-02-25 00:00:00','32060002','7574212','58923898','INPATIENT HOSPITAL','1002608174','RESP','201803') ],
   ['claim_id','pat_id','claim_subm_dt','src_plan_id','src_pri_psbr_id','pri_az_cust_id','plac_of_srvc_cd','az_plan_id','src_sys_nm','yr_mth'] ).withColumn('claim_subm_dt', F.expr("cast(claim_subm_dt as timestamp)")).withColumn('yr_mth', F.expr("cast(yr_mth as int)"))
   
   Update:
   
   df_upd = spark.createDataFrame([
   ('10490113453106300000','561295328','2018-02-26 00:00:00','129999','18078735','15889231','OTHER PLACE OF SERVICE','53200900','RESP','201802'),
   ('10490120407605900000','559017519','2018-02-26 00:00:00','24290619','100','32531','OTHER PLACE OF SERVICE','53214384','RESP','201802'),
   ('10490116725506700000','1275017082','2018-02-27 00:00:00','209999','7875173','56874023','INPATIENT HOSPITAL','53201132','RESP','201802'),
   ('10420113469301100000','1705523399','2018-02-26 00:00:00','20045','7088459','55674640','EMERGENCY ROOM - HOSPITAL','53199046','RESP','201802'),
   ('10419114183800600000','29764982','2018-02-26 00:00:00','11659999','7786313','56694289','OFFICE','53207492','RESP','201802'),
   ('10490115064904900000','5007290360','2018-02-27 00:00:00','11720002','6937467','57968295','INPATIENT HOSPITAL','53207546','RESP','201803'),
   ('10419114186102800000','4968929315','2018-02-27 00:00:00','38930013','7311494','55315237','OFFICE','1002607736','RESP','201803'),
   ('10236114374904400000','320648979','2018-02-26 00:00:00','35160001','100','32531','INDEPENDENT LABORATORY','53217687','RESP','201803'),
   ('10809131289117500000','505439892','2018-02-28 00:00:00','20860001','2492213','52847481','OTHER PLACE OF SERVICE','53212703','RESP','201803'),
   ('10419123011601800000','3138080815','2018-02-25 00:00:00','32060002','7574212','58923898','INPATIENT HOSPITAL','1002608174','RESP','201803') ],
   ['claim_id','pat_id','claim_subm_dt','src_plan_id','src_pri_psbr_id','pri_az_cust_id','plac_of_srvc_cd','az_plan_id','src_sys_nm','yr_mth'] ).withColumn('claim_subm_dt', F.expr("cast(claim_subm_dt as timestamp)")).withColumn('yr_mth', F.expr("cast(yr_mth as int)"))


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



[GitHub] [hudi] nsivabalan commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-928290740






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



[GitHub] [hudi] abhishekshenoy edited a comment on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
abhishekshenoy edited a comment on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-1054225531


   @nsivabalan i see the issue is closed . But in 0.10.1 i still face the duplicate issue when i provide a timestamp column as part of composite key.
   ```
       hoodiConfigs.put("hoodie.insert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.upsert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.bulkinsert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.delete.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.datasource.write.row.writer.enable", "true")
       hoodiConfigs.put("hoodie.table.keygenerator.class", classOf[ComplexKeyGenerator].getName)
       hoodiConfigs.put("hoodie.datasource.write.keygenerator.class", classOf[ComplexKeyGenerator].getName)
       hoodiConfigs.put("hoodie.datasource.write.recordkey.field", "transactionId,storeNbr,transactionTs")
       hoodiConfigs.put("hoodie.datasource.write.precombine.field", "messageMetadata.srcLoadTs")
       hoodiConfigs.put("hoodie.table.precombine.field", "messageMetadata.srcLoadTs")
       hoodiConfigs.put("hoodie.datasource.write.partitionpath.field", "transactionDt")
       hoodiConfigs.put("hoodie.datasource.write.payload.class",classOf[DefaultHoodieRecordPayload].getName)
       hoodiConfigs.put("hoodie.datasource.write.hive_style_partitioning", "true")
       hoodiConfigs.put("hoodie.datasource.write.table.type",COW_TABLE_TYPE_OPT_VAL)
       hoodiConfigs.put("hoodie.combine.before.upsert","true")
       hoodiConfigs.put("hoodie.table.name","huditransaction")
       hoodiConfigs.put("hoodie.datasource.write.keygenerator.consistent.logical.timestamp.enabled","true")
   ```    
   
   With both BULK_INSERT_OPERATION_OPT_VAL 
       
   Output dataset after first Insert does not dedupe records within the batch even on setting combine before insert to true
   Key (abc, 4162 , 2022-02-25 05:08:10.73)
   ```
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |_hoodie_commit_time|_hoodie_commit_seqno |_hoodie_record_key                                                   |_hoodie_partition_path  |_hoodie_file_name                                                      |transactionId|storeNbr|transactionTs          |messageMetadata                                   |prefixes  |dummyInt|dummyLong|dummyObjects    |transactionDt|
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |20220228210614823  |20220228210614823_0_1|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_2|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-26 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_3|transactionId:bcd,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet|bcd          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_4|transactionId:cde,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet|cde          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_5|transactionId:def,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet|def          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   
   ```
   
   Republishing the same data with UPSERT_OPERATION_OPT_VAL will result in duplicates as well as the data in transactionTs and messageMetadata.srcLoadTs for the records loaded using  BULK_INSERT_OPERATION_OPT_VAL has changed.
   
   1. If you see the recordKey field , the transactionTs value is epochTimeStamp for records loaded using UPSERT_OPERATION_OPT_VAL and UnixTimeStamp for records loaded using BULK_INSERT_OPERATION_OPT_VAL.
   2. With UPSERT_OPERATION_OPT_VAL we see Combine before insert work correctly.
   3. The columns transactionTs and messageMetadata.srcLoadTs has its value changed to 1970-01-20 06:39:05.890073
   
   ```
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+------------------------------------------------------------------------+-------------+--------+--------------------------+-----------------------------------------------------+----------+--------+---------+----------------+-------------+
   |_hoodie_commit_time|_hoodie_commit_seqno |_hoodie_record_key                                                   |_hoodie_partition_path  |_hoodie_file_name                                                       |transactionId|storeNbr|transactionTs             |messageMetadata                                      |prefixes  |dummyInt|dummyLong|dummyObjects    |transactionDt|
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+------------------------------------------------------------------------+-------------+--------+--------------------------+-----------------------------------------------------+----------+--------+---------+----------------+-------------+
   |20220228210614823  |20220228210614823_0_1|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet |abc          |4162    |1970-01-20 06:39:05.890073|{key, value, 1, 2, 1970-01-20 06:39:05.95, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_2|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet |abc          |4162    |1970-01-20 06:39:05.890073|{key, value, 1, 2, 1970-01-20 06:40:32.35, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_3|transactionId:bcd,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet |bcd          |4162    |1970-01-20 06:39:05.890073|{key, value, 1, 2, 1970-01-20 06:39:05.95, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_4|transactionId:cde,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet |cde          |4163    |1970-01-20 06:39:05.890073|{key, value, 1, 2, 1970-01-20 06:39:05.95, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_5|transactionId:def,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet |def          |4163    |1970-01-20 06:39:05.890073|{key, value, 1, 2, 1970-01-20 06:39:05.95, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210729355  |20220228210729355_0_1|transactionId:bcd,storeNbr:4162,transactionTs:1645745890073000       |transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-26-20_20220228210729355.parquet|bcd          |4162    |2022-02-25 05:08:10.073   |{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}   |[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210729355  |20220228210729355_0_2|transactionId:cde,storeNbr:4163,transactionTs:1645745890073000       |transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-26-20_20220228210729355.parquet|cde          |4163    |2022-02-25 05:08:10.073   |{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}   |[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210729355  |20220228210729355_0_3|transactionId:def,storeNbr:4163,transactionTs:1645745890073000       |transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-26-20_20220228210729355.parquet|def          |4163    |2022-02-25 05:08:10.073   |{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}   |[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210729355  |20220228210729355_0_4|transactionId:abc,storeNbr:4162,transactionTs:1645745890073000       |transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-26-20_20220228210729355.parquet|abc          |4162    |2022-02-25 05:08:10.073   |{key, value, 1, 2, 2022-02-26 05:09:10, 1, { -> }}   |[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+------------------------------------------------------------------------+-------------+--------+--------------------------+-----------------------------------------------------+----------+--------+---------+----------------+-------------+
   
   ```
   
       


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



[GitHub] [hudi] mkk1490 commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
mkk1490 commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-888248088


   @nsivabalan Update: The timestamp field get converted to long in hoodie_key as below:
   
   ![image](https://user-images.githubusercontent.com/16716227/127317865-04c77073-b950-42cc-80b5-9659481c43c2.png)
   
   This conversion takes place when the write operation is insert/upsert. But when we do a bulk_insert, this value remains as timestamp. I can't say whether this is an issue with insert/upsert or with bulk_insert. 


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



[GitHub] [hudi] codope commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
codope commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-888399624


   @mkk1490 I agree with your observation. I am able to reproduce the issue. Still debugging.


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



[GitHub] [hudi] nsivabalan commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-884649681


   Would you mind giving me steps to reproduce w/ some sample data. guess handful of records should be good enough to reproduce. 


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



[GitHub] [hudi] mkk1490 edited a comment on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
mkk1490 edited a comment on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-884708261


   @nsivabalan during bulk_insert as well as insert for the first time into the table, the hoodie_key value was in timestamp. But during the upsert operation, it was converted into long. I even added a step just before write to convert to timestamp. It still didn't work. But when the field's datatype is date, this issue didn't come up.
   
   Sample data with original code:
   1. Hive external table with location pointing to s3
   2. This code was executed on EMR 5.33 with hudi 0.7.0
   Step 1:
   from pyspark.sql import functions as F
   df = spark.createDataFrame([
   ('10490113453106300000','561295328','2018-02-26 00:00:00','129999','18078735','15889231','OTHER PLACE OF SERVICE','53200900','RESP','201802'),
   ('10490120407605900000','559017519','2018-02-26 00:00:00','24290619','0','','OTHER PLACE OF SERVICE','53214384','RESP','201802'),
   ('10490116725506700000','1275017082','2018-02-27 00:00:00','209999','7875173','56874023','INPATIENT HOSPITAL','53201132','RESP','201802'),
   ('10420113469301100000','1705523399','2018-02-26 00:00:00','20045','7088459','55674640','EMERGENCY ROOM - HOSPITAL','53199046','RESP','201802'),
   ('10419114183800600000','29764982','2018-02-26 00:00:00','11659999','7786313','56694289','OFFICE','53207492','RESP','201802'),
   ('10490115064904900000','5007290360','2018-02-27 00:00:00','11720002','6937467','57968295','INPATIENT HOSPITAL','53207546','RESP','201803'),
   ('10419114186102800000','4968929315','2018-02-27 00:00:00','38930013','7311494','55315237','OFFICE','1002607736','RESP','201803'),
   ('10236114374904400000','320648979','2018-02-26 00:00:00','35160001','0','','INDEPENDENT LABORATORY','53217687','RESP','201803'),
   ('10809131289117500000','505439892','2018-02-28 00:00:00','20860001','2492213','52847481','OTHER PLACE OF SERVICE','53212703','RESP','201803'),
   ('10419123011601800000','3138080815','2018-02-25 00:00:00','32060002','7574212','58923898','INPATIENT HOSPITAL','1002608174','RESP','201803') ],
   ['claim_id','pat_id','claim_subm_dt','src_plan_id','src_pri_psbr_id','pri_az_cust_id','plac_of_srvc_cd','az_plan_id','src_sys_nm','yr_mth'] ).withColumn('claim_subm_dt', F.expr("cast(claim_subm_dt as timestamp)"))
   
   hudi_options = {
   'hoodie.table.name': 'f_hudi_cow',
   'hoodie.datasource.write.recordkey.field': 'claim_id,pat_id,claim_subm_dt,plac_of_srvc_cd,src_pri_psbr_id,src_plan_id'
   'hoodie.datasource.write.partitionpath.field': 'src_sys_nm,yr_mth',
   'hoodie.datasource.write.table.Type': 'COPY_ON_WRITE',
   'hoodie.datasource.write.table.name': 'f_hudi_cow',
   'hoodie.combine.before.upsert': 'true',
   'hoodie.datasource.hive_sync.enable': 'true',
   'hoodie.datasource.hive_sync.table': 'f_hudi_cow',
   'hoodie.datasource.hive_sync.partition_fields': 'src_sys_nm,yr_mth',
   'hoodie.datasource.hive_sync.partition_extractor_class': 'org.apache.hudi.hive.MultiPartKeysValueExtractor',
   'hoodie.datasource.write.hive_style_partitioning': 'true',
   'hoodie.datasource.hive_sync.database': 'us_commercial_datalake_app_commons_dev',
   'hoodie.datasource.hive_sync.support_timestamp': 'true',
   'hoodie.datasource.hive_sync.auto_create_db':'false',
   'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.ComplexKeyGenerator',
   'hoodie.datasource.write.row.writer.enable': 'true',
   'hoodie.parquet.small.file.limit': '600000000',
   'hoodie.parquet.max.file.size': '1000000000',
   'hoodie.upsert.shuffle.parallelism': '10000',
   'hoodie.insert.shuffle.parallelism': '10000',
   'hoodie.bulkinsert.shuffle.parallelism': '25',
   'hoodie.clean.automatic': 'false',
   'hoodie.cleaner.commits.retained': 3,
   'hoodie.index.type': 'GLOBAL_SIMPLE',
   'hoodie.simple.index.update.partition.path':'true',
   'hoodie.metadata.enable': 'true'
   }
   
   df.write.format("org.apache.hudi").
   options(**hudi_options).option('hoodie.datasource.write.operation', 'bulk_insert').
   mode("overwrite").
   save("{s3_path}")
   
   Step 2:
   **Upsert has values 0 changed to 100. Updated Field name: src_pri_psbr_id**
   
   df_upsert  =spark.createDataFrame([
   ('10490113453106300000','561295328','2018-02-26 00:00:00','129999','18078735','15889231','OTHER PLACE OF SERVICE','53200900','RESP','201802'),
   ('10490120407605900000','559017519','2018-02-26 00:00:00','24290619','100','','OTHER PLACE OF SERVICE','53214384','RESP','201802'),
   ('10490116725506700000','1275017082','2018-02-27 00:00:00','209999','7875173','56874023','INPATIENT HOSPITAL','53201132','RESP','201802'),
   ('10420113469301100000','1705523399','2018-02-26 00:00:00','20045','7088459','55674640','EMERGENCY ROOM - HOSPITAL','53199046','RESP','201802'),
   ('10419114183800600000','29764982','2018-02-26 00:00:00','11659999','7786313','56694289','OFFICE','53207492','RESP','201802'),
   ('10490115064904900000','5007290360','2018-02-27 00:00:00','11720002','6937467','57968295','INPATIENT HOSPITAL','53207546','RESP','201803'),
   ('10419114186102800000','4968929315','2018-02-27 00:00:00','38930013','7311494','55315237','OFFICE','1002607736','RESP','201803'),
   ('10236114374904400000','320648979','2018-02-26 00:00:00','35160001','100','','INDEPENDENT LABORATORY','53217687','RESP','201803'),
   ('10809131289117500000','505439892','2018-02-28 00:00:00','20860001','2492213','52847481','OTHER PLACE OF SERVICE','53212703','RESP','201803'),
   ('10419123011601800000','3138080815','2018-02-25 00:00:00','32060002','7574212','58923898','INPATIENT HOSPITAL','1002608174','RESP','201803') ],
   ['claim_id','pat_id','claim_subm_dt','src_plan_id','src_pri_psbr_id','pri_az_cust_id','plac_of_srvc_cd','az_plan_id','src_sys_nm','yr_mth'] ).withColumn('claim_subm_dt', F.expr("cast(claim_subm_dt as timestamp)"))
   
   hudi_options = {
   'hoodie.table.name': 'f_hudi_cow',
   'hoodie.datasource.write.recordkey.field': 'claim_id,pat_id,claim_subm_dt,plac_of_srvc_cd,src_pri_psbr_id,src_plan_id'
   'hoodie.datasource.write.partitionpath.field': 'src_sys_nm,yr_mth',
   'hoodie.datasource.write.table.Type': 'COPY_ON_WRITE',
   'hoodie.datasource.write.table.name': 'f_hudi_cow',
   'hoodie.combine.before.upsert': 'true',
   'hoodie.datasource.hive_sync.enable': 'true',
   'hoodie.datasource.hive_sync.table': 'f_hudi_cow',
   'hoodie.datasource.hive_sync.partition_fields': 'src_sys_nm,yr_mth',
   'hoodie.datasource.hive_sync.partition_extractor_class': 'org.apache.hudi.hive.MultiPartKeysValueExtractor',
   'hoodie.datasource.write.hive_style_partitioning': 'true',
   'hoodie.datasource.hive_sync.database': 'us_commercial_datalake_app_commons_dev',
   'hoodie.datasource.hive_sync.support_timestamp': 'true',
   'hoodie.datasource.hive_sync.auto_create_db':'false',
   'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.ComplexKeyGenerator',
   'hoodie.datasource.write.row.writer.enable': 'true',
   'hoodie.parquet.small.file.limit': '600000000',
   'hoodie.parquet.max.file.size': '1000000000',
   'hoodie.upsert.shuffle.parallelism': '10000',
   'hoodie.insert.shuffle.parallelism': '10000',
   'hoodie.bulkinsert.shuffle.parallelism': '25',
   'hoodie.clean.automatic': 'false',
   'hoodie.cleaner.commits.retained': 3,
   'hoodie.index.type': 'GLOBAL_SIMPLE',
   'hoodie.simple.index.update.partition.path':'true',
   'hoodie.metadata.enable': 'true'
   }
   
   df.write.format("org.apache.hudi").
   options(**hudi_options).option('hoodie.datasource.write.operation', 'upsert').
   mode("append").
   save("{s3_path}")
   
   Expected output: 0 to be updated to 100. 
   


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



[GitHub] [hudi] vinothchandar commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-926271684


   @mkk1490 row writer is fully certified for 0.9.0 and now the default. Could you comment on whether we need this issue around


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



[GitHub] [hudi] mkk1490 commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
mkk1490 commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-928853775


   
   
   > @mkk1490 : sorry the issue got lengthy and I have got a couple of clarifications.
   > Is your issue is with record key fields having one component as timestamp or is it about partition path fields having one component as timestamp. bcoz, for partition path field, hudi has something called CustomKeyGenerator which pretty much in line with your use-case. (1st field can be simple/string and 2nd field can be timestamp).
   > 
   > From what I understand, its record key that you are facing the issue. In the mean time, you respond, I will keep looking in that direction.
   
   @nsivabalan that's right.. timestamp in record_key is where I'm facing this issue


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



[GitHub] [hudi] nsivabalan commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-886006267


   Can you confirm something. 
   I see that you have "src_pri_psbr_id" as part of your record key fields. So, I was expecting to update a record, you will not touch any of the fields that are part of the record key. If not, these are considered as completely different records. But looks like you are updating this field and expect hudi to treat it as an update. 
   
   


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



[GitHub] [hudi] abhishekshenoy commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
abhishekshenoy commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-1054225531


   @nsivabalan i see the issue is closed . But in 0.10.1 i still face the duplicate issue when i provide a timestamp column as part of composite key.


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



[GitHub] [hudi] nsivabalan commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-926318350


   @vinothchandar : I wanna repro myself before we can close this out. Author claims that w/ composite keys, we have some issues w/ timestamp based partition path when row writer is enabled for bulk_insert. I will take a stab at this over the weekend and update the ticket. 


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



[GitHub] [hudi] nsivabalan closed issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan closed issue #3313:
URL: https://github.com/apache/hudi/issues/3313


   


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



[GitHub] [hudi] nsivabalan commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-888404054


   Can you try disabling row writer for bulk_insert. 
   'hoodie.datasource.write.row.writer.enable': 'false'.
   Just to narrow down the issue. 


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



[GitHub] [hudi] nsivabalan commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-928290740


   @mkk1490 : sorry the issue got lengthy and I have got a couple of clarifications. 
   Is your issue is with record key fields having one component as timestamp or is it about partition path fields having one component as timestamp. bcoz, for partition path field, hudi has something called CustomKeyGenerator which pretty much in line with your use-case. (1st field can be simple/string and 2nd field can be timestamp). 
   
   From what I understand, its record key that you are facing the issue. In the mean time, you respond, I will keep looking in that direction. 


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



[GitHub] [hudi] vinothchandar commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-926272005


   @nsivabalan can you confirm fixes releated to the precombining are now done? if so, we can close this and have @mkk1490 reopen as needed


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



[GitHub] [hudi] mkk1490 commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
mkk1490 commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-928853775


   
   
   > @mkk1490 : sorry the issue got lengthy and I have got a couple of clarifications.
   > Is your issue is with record key fields having one component as timestamp or is it about partition path fields having one component as timestamp. bcoz, for partition path field, hudi has something called CustomKeyGenerator which pretty much in line with your use-case. (1st field can be simple/string and 2nd field can be timestamp).
   > 
   > From what I understand, its record key that you are facing the issue. In the mean time, you respond, I will keep looking in that direction.
   
   @nsivabalan that's right.. timestamp in record_key is where I'm facing this issue


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



[GitHub] [hudi] nsivabalan commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-928330326


   I can confirm there is a bug here. GenericRecord based keygen converts the timestamp value, where as Row based one does not convert. 
   
   Have filed a bug https://issues.apache.org/jira/browse/HUDI-2495 We will follow up on this. Will close out this issue as we have a tracking jira. 


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



[GitHub] [hudi] mkk1490 commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
mkk1490 commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-884708261


   @nsivabalan during bulk_insert as well as insert for the first time into the table, the hoodie_key value was in timestamp. But during the upsert operation, it was converted into long. I even added a step just before write to convert to timestamp. It still didn't work. But when the field's datatype is date, this issue didn't come up.
   
   Sample data with original code:
   1. Hive external table with location pointing to s3
   2. This code was executed on EMR 5.33 with hudi 0.7.0
   Step 1:
   from pyspark.sql import functions as F
   df = spark.createDataFrame([
   ('10490113453106300000','561295328','2018-02-26 00:00:00','129999','18078735','15889231','OTHER PLACE OF SERVICE','53200900','RESP','201802'),
   ('10490120407605900000','559017519','2018-02-26 00:00:00','24290619','0','','OTHER PLACE OF SERVICE','53214384','RESP','201802'),
   ('10490116725506700000','1275017082','2018-02-27 00:00:00','209999','7875173','56874023','INPATIENT HOSPITAL','53201132','RESP','201802'),
   ('10420113469301100000','1705523399','2018-02-26 00:00:00','20045','7088459','55674640','EMERGENCY ROOM - HOSPITAL','53199046','RESP','201802'),
   ('10419114183800600000','29764982','2018-02-26 00:00:00','11659999','7786313','56694289','OFFICE','53207492','RESP','201802'),
   ('10490115064904900000','5007290360','2018-02-27 00:00:00','11720002','6937467','57968295','INPATIENT HOSPITAL','53207546','RESP','201803'),
   ('10419114186102800000','4968929315','2018-02-27 00:00:00','38930013','7311494','55315237','OFFICE','1002607736','RESP','201803'),
   ('10236114374904400000','320648979','2018-02-26 00:00:00','35160001','0','','INDEPENDENT LABORATORY','53217687','RESP','201803'),
   ('10809131289117500000','505439892','2018-02-28 00:00:00','20860001','2492213','52847481','OTHER PLACE OF SERVICE','53212703','RESP','201803'),
   ('10419123011601800000','3138080815','2018-02-25 00:00:00','32060002','7574212','58923898','INPATIENT HOSPITAL','1002608174','RESP','201803') ],
   ['claim_id','pat_id','claim_subm_dt','src_plan_id','src_pri_psbr_id','pri_az_cust_id','plac_of_srvc_cd','az_plan_id','src_sys_nm','yr_mth'] ).withColumn('claim_subm_dt', F.expr("cast(claim_subm_dt as timestamp)"))
   
   hudi_options = {
   'hoodie.table.name': 'f_hudi_cow',
   'hoodie.datasource.write.recordkey.field': 'claim_id,pat_id,claim_subm_dt,plac_of_srvc_cd,src_pri_psbr_id,src_plan_id'
   'hoodie.datasource.write.partitionpath.field': 'src_sys_nm,yr_mth',
   'hoodie.datasource.write.table.Type': 'COPY_ON_WRITE',
   'hoodie.datasource.write.table.name': 'f_hudi_cow',
   # 'hoodie.combine.before.insert': 'false',
   'hoodie.combine.before.upsert': 'true',
   'hoodie.datasource.hive_sync.enable': 'true',
   'hoodie.datasource.hive_sync.table': 'f_hudi_cow',
   'hoodie.datasource.hive_sync.partition_fields': 'src_sys_nm,yr_mth',
   'hoodie.datasource.hive_sync.partition_extractor_class': 'org.apache.hudi.hive.MultiPartKeysValueExtractor',
   'hoodie.datasource.write.hive_style_partitioning': 'true',
   'hoodie.datasource.hive_sync.database': 'us_commercial_datalake_app_commons_dev',
   'hoodie.datasource.hive_sync.support_timestamp': 'true',
   'hoodie.datasource.hive_sync.auto_create_db':'false',
   'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.ComplexKeyGenerator',
   'hoodie.datasource.write.row.writer.enable': 'true',
   'hoodie.parquet.small.file.limit': '600000000',
   'hoodie.parquet.max.file.size': '1000000000',
   'hoodie.upsert.shuffle.parallelism': '10000',
   'hoodie.insert.shuffle.parallelism': '10000',
   'hoodie.bulkinsert.shuffle.parallelism': '25',
   'hoodie.clean.automatic': 'false',
   'hoodie.cleaner.commits.retained': 3,
   'hoodie.index.type': 'GLOBAL_SIMPLE',
   'hoodie.simple.index.update.partition.path':'true',
   'hoodie.metadata.enable': 'true'
   }
   
   df.write.format("org.apache.hudi").
   options(**hudi_options).option('hoodie.datasource.write.operation', 'bulk_insert').
   mode("overwrite").
   save("{s3_path}")
   
   Step 2:
   **Upsert has values 0 changed to 100. Updated Field name: src_pri_psbr_id**
   
   df_upsert  =spark.createDataFrame([
   ('10490113453106300000','561295328','2018-02-26 00:00:00','129999','18078735','15889231','OTHER PLACE OF SERVICE','53200900','RESP','201802'),
   ('10490120407605900000','559017519','2018-02-26 00:00:00','24290619','100','','OTHER PLACE OF SERVICE','53214384','RESP','201802'),
   ('10490116725506700000','1275017082','2018-02-27 00:00:00','209999','7875173','56874023','INPATIENT HOSPITAL','53201132','RESP','201802'),
   ('10420113469301100000','1705523399','2018-02-26 00:00:00','20045','7088459','55674640','EMERGENCY ROOM - HOSPITAL','53199046','RESP','201802'),
   ('10419114183800600000','29764982','2018-02-26 00:00:00','11659999','7786313','56694289','OFFICE','53207492','RESP','201802'),
   ('10490115064904900000','5007290360','2018-02-27 00:00:00','11720002','6937467','57968295','INPATIENT HOSPITAL','53207546','RESP','201803'),
   ('10419114186102800000','4968929315','2018-02-27 00:00:00','38930013','7311494','55315237','OFFICE','1002607736','RESP','201803'),
   ('10236114374904400000','320648979','2018-02-26 00:00:00','35160001','100','','INDEPENDENT LABORATORY','53217687','RESP','201803'),
   ('10809131289117500000','505439892','2018-02-28 00:00:00','20860001','2492213','52847481','OTHER PLACE OF SERVICE','53212703','RESP','201803'),
   ('10419123011601800000','3138080815','2018-02-25 00:00:00','32060002','7574212','58923898','INPATIENT HOSPITAL','1002608174','RESP','201803') ],
   ['claim_id','pat_id','claim_subm_dt','src_plan_id','src_pri_psbr_id','pri_az_cust_id','plac_of_srvc_cd','az_plan_id','src_sys_nm','yr_mth'] ).withColumn('claim_subm_dt', F.expr("cast(claim_subm_dt as timestamp)"))
   
   hudi_options = {
   'hoodie.table.name': 'f_hudi_cow',
   'hoodie.datasource.write.recordkey.field': 'claim_id,pat_id,claim_subm_dt,plac_of_srvc_cd,src_pri_psbr_id,src_plan_id'
   'hoodie.datasource.write.partitionpath.field': 'src_sys_nm,yr_mth',
   'hoodie.datasource.write.table.Type': 'COPY_ON_WRITE',
   'hoodie.datasource.write.table.name': 'f_hudi_cow',
   # 'hoodie.combine.before.insert': 'false',
   'hoodie.combine.before.upsert': 'true',
   'hoodie.datasource.hive_sync.enable': 'true',
   'hoodie.datasource.hive_sync.table': 'f_hudi_cow',
   'hoodie.datasource.hive_sync.partition_fields': 'src_sys_nm,yr_mth',
   'hoodie.datasource.hive_sync.partition_extractor_class': 'org.apache.hudi.hive.MultiPartKeysValueExtractor',
   'hoodie.datasource.write.hive_style_partitioning': 'true',
   'hoodie.datasource.hive_sync.database': 'us_commercial_datalake_app_commons_dev',
   'hoodie.datasource.hive_sync.support_timestamp': 'true',
   'hoodie.datasource.hive_sync.auto_create_db':'false',
   'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.ComplexKeyGenerator',
   'hoodie.datasource.write.row.writer.enable': 'true',
   'hoodie.parquet.small.file.limit': '600000000',
   'hoodie.parquet.max.file.size': '1000000000',
   'hoodie.upsert.shuffle.parallelism': '10000',
   'hoodie.insert.shuffle.parallelism': '10000',
   'hoodie.bulkinsert.shuffle.parallelism': '25',
   'hoodie.clean.automatic': 'false',
   'hoodie.cleaner.commits.retained': 3,
   'hoodie.index.type': 'GLOBAL_SIMPLE',
   'hoodie.simple.index.update.partition.path':'true',
   'hoodie.metadata.enable': 'true'
   }
   
   df.write.format("org.apache.hudi").
   options(**hudi_options).option('hoodie.datasource.write.operation', 'upsert').
   mode("append").
   save("{s3_path}")
   
   Expected output: 0 to be updated to 100. 
   


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



[GitHub] [hudi] mkk1490 commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
mkk1490 commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-889627136


   @nsivabalan I set the row_writer property to False and ingested the data. Now, timestamp gets converted to their respective epoch seconds and long datatype in hoodie_key
   ![image](https://user-images.githubusercontent.com/16716227/127602181-65d0075d-4757-4280-aa51-75592fb03fa8.png)
   
   This actually solves my issue since during upsert, the key would be in sync with the IDL key. But bulk_insert with row.writer:False is very slow. It actually takes double the time for the same data ingestion. 


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



[GitHub] [hudi] mkk1490 edited a comment on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
mkk1490 edited a comment on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-888248088


   @nsivabalan Update: The timestamp field get converted to long in hoodie_key as below:
   
   ![image](https://user-images.githubusercontent.com/16716227/127317865-04c77073-b950-42cc-80b5-9659481c43c2.png)
   
   This conversion takes place when the write operation is insert/upsert. But when we do a bulk_insert, this value remains as timestamp. 
   When I do an insert as the first load to the table and then do an upsert, there is no issue
   When I do a bulk_insert as the first load to the table and then do either an insert or update, I run into this conversion issue.
   
   I can't say whether this is an issue with insert/upsert or with bulk_insert. 


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



[GitHub] [hudi] abhishekshenoy edited a comment on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
abhishekshenoy edited a comment on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-1054225531


   @nsivabalan i see the issue is closed . But in 0.10.1 i still face the duplicate issue when i provide a timestamp column as part of composite key.
   ```
       hoodiConfigs.put("hoodie.insert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.upsert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.bulkinsert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.delete.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.datasource.write.row.writer.enable", "true")
       hoodiConfigs.put("hoodie.table.keygenerator.class", classOf[ComplexKeyGenerator].getName)
       hoodiConfigs.put("hoodie.datasource.write.keygenerator.class", classOf[ComplexKeyGenerator].getName)
       hoodiConfigs.put("hoodie.datasource.write.recordkey.field", "transactionId,storeNbr,transactionTs")
       hoodiConfigs.put("hoodie.datasource.write.precombine.field", "messageMetadata.srcLoadTs")
       hoodiConfigs.put("hoodie.table.precombine.field", "messageMetadata.srcLoadTs")
       hoodiConfigs.put("hoodie.datasource.write.partitionpath.field", "transactionDt")
       hoodiConfigs.put("hoodie.datasource.write.payload.class",classOf[DefaultHoodieRecordPayload].getName)
       hoodiConfigs.put("hoodie.datasource.write.hive_style_partitioning", "true")
       hoodiConfigs.put("hoodie.datasource.write.table.type",COW_TABLE_TYPE_OPT_VAL)
       hoodiConfigs.put("hoodie.combine.before.upsert","true")
       hoodiConfigs.put("hoodie.table.name","huditransaction")
       hoodiConfigs.put("hoodie.datasource.write.keygenerator.consistent.logical.timestamp.enabled","true")
   ```    
   
   Tried with both BULK_INSERT_OPERATION_OPT_VAL and UPSERT_OPERATION_OPT_VAL
       
   Output dataset after first Insert , If you see Combine before insert did not work 
   Key (abc, 4162 , 2022-02-25 05:08:10.73)
   ```
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |_hoodie_commit_time|_hoodie_commit_seqno |_hoodie_record_key                                                   |_hoodie_partition_path  |_hoodie_file_name                                                      |transactionId|storeNbr|transactionTs          |messageMetadata                                   |prefixes  |dummyInt|dummyLong|dummyObjects    |transactionDt|
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |20220228183206147  |20220228183206147_0_1|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_2|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_3|transactionId:bcd,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|bcd          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_4|transactionId:cde,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|cde          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_5|transactionId:def,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|def          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   ```
   
   Republishing with an addition record for the same key (abc, 4162 , 2022-02-25 05:08:10.73) does not get deduped
   ```
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |_hoodie_commit_time|_hoodie_commit_seqno |_hoodie_record_key                                                   |_hoodie_partition_path  |_hoodie_file_name                                                      |transactionId|storeNbr|transactionTs          |messageMetadata                                   |prefixes  |dummyInt|dummyLong|dummyObjects    |transactionDt|
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |20220228183206147  |20220228183206147_0_1|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_2|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_3|transactionId:bcd,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|bcd          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_4|transactionId:cde,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|cde          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_5|transactionId:def,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|def          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183821299  |20220228183821299_0_1|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|66ee158e-93f3-4ccc-8b2a-1712c3cdf5cf-0_0-2-0_20220228183821299.parquet |abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   ```
       


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



[GitHub] [hudi] abhishekshenoy edited a comment on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
abhishekshenoy edited a comment on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-1054225531


   @nsivabalan i see the issue is closed . But in 0.10.1 i still face the duplicate issue when i provide a timestamp column as part of composite key.
   ```
       hoodiConfigs.put("hoodie.insert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.upsert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.bulkinsert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.delete.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.datasource.write.row.writer.enable", "true")
       hoodiConfigs.put("hoodie.table.keygenerator.class", classOf[ComplexKeyGenerator].getName)
       hoodiConfigs.put("hoodie.datasource.write.keygenerator.class", classOf[ComplexKeyGenerator].getName)
       hoodiConfigs.put("hoodie.datasource.write.recordkey.field", "transactionId,storeNbr,transactionTs")
       hoodiConfigs.put("hoodie.datasource.write.precombine.field", "messageMetadata.srcLoadTs")
       hoodiConfigs.put("hoodie.table.precombine.field", "messageMetadata.srcLoadTs")
       hoodiConfigs.put("hoodie.datasource.write.partitionpath.field", "transactionDt")
       hoodiConfigs.put("hoodie.datasource.write.payload.class",classOf[DefaultHoodieRecordPayload].getName)
       hoodiConfigs.put("hoodie.datasource.write.hive_style_partitioning", "true")
       hoodiConfigs.put("hoodie.datasource.write.table.type",COW_TABLE_TYPE_OPT_VAL)
       hoodiConfigs.put("hoodie.combine.before.upsert","true")
       hoodiConfigs.put("hoodie.table.name","huditransaction")
       hoodiConfigs.put("hoodie.datasource.write.keygenerator.consistent.logical.timestamp.enabled","true")
   ```    
   
   With BULK_INSERT_OPERATION_OPT_VAL 
       
   Output dataset after first Insert does not dedupe records within the batch even on setting combine before insert to true
   Key (abc, 4162 , 2022-02-25 05:08:10.73)
   ```
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |_hoodie_commit_time|_hoodie_commit_seqno |_hoodie_record_key                                                   |_hoodie_partition_path  |_hoodie_file_name                                                      |transactionId|storeNbr|transactionTs          |messageMetadata                                   |prefixes  |dummyInt|dummyLong|dummyObjects    |transactionDt|
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |20220228210614823  |20220228210614823_0_1|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_2|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-26 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_3|transactionId:bcd,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet|bcd          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_4|transactionId:cde,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet|cde          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_5|transactionId:def,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet|def          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   
   ```
   
   Republishing the same data with UPSERT_OPERATION_OPT_VAL will result in duplicates as well as the data in transactionTs and messageMetadata.srcLoadTs for the records loaded using  BULK_INSERT_OPERATION_OPT_VAL has changed.
   
   1. If you see the recordKey field , the transactionTs value is epochTimeStamp for records loaded using UPSERT_OPERATION_OPT_VAL and UnixTimeStamp for records loaded using BULK_INSERT_OPERATION_OPT_VAL.
   2. With UPSERT_OPERATION_OPT_VAL we see Combine before insert work correctly.
   3. The columns transactionTs and messageMetadata.srcLoadTs has its value changed to 1970-01-20 06:39:05.890073
   
   ```
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+------------------------------------------------------------------------+-------------+--------+--------------------------+-----------------------------------------------------+----------+--------+---------+----------------+-------------+
   |_hoodie_commit_time|_hoodie_commit_seqno |_hoodie_record_key                                                   |_hoodie_partition_path  |_hoodie_file_name                                                       |transactionId|storeNbr|transactionTs             |messageMetadata                                      |prefixes  |dummyInt|dummyLong|dummyObjects    |transactionDt|
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+------------------------------------------------------------------------+-------------+--------+--------------------------+-----------------------------------------------------+----------+--------+---------+----------------+-------------+
   |20220228210614823  |20220228210614823_0_1|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet |abc          |4162    |1970-01-20 06:39:05.890073|{key, value, 1, 2, 1970-01-20 06:39:05.95, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_2|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet |abc          |4162    |1970-01-20 06:39:05.890073|{key, value, 1, 2, 1970-01-20 06:40:32.35, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_3|transactionId:bcd,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet |bcd          |4162    |1970-01-20 06:39:05.890073|{key, value, 1, 2, 1970-01-20 06:39:05.95, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_4|transactionId:cde,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet |cde          |4163    |1970-01-20 06:39:05.890073|{key, value, 1, 2, 1970-01-20 06:39:05.95, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210614823  |20220228210614823_0_5|transactionId:def,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-10-0_20220228210614823.parquet |def          |4163    |1970-01-20 06:39:05.890073|{key, value, 1, 2, 1970-01-20 06:39:05.95, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210729355  |20220228210729355_0_1|transactionId:bcd,storeNbr:4162,transactionTs:1645745890073000       |transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-26-20_20220228210729355.parquet|bcd          |4162    |2022-02-25 05:08:10.073   |{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}   |[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210729355  |20220228210729355_0_2|transactionId:cde,storeNbr:4163,transactionTs:1645745890073000       |transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-26-20_20220228210729355.parquet|cde          |4163    |2022-02-25 05:08:10.073   |{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}   |[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210729355  |20220228210729355_0_3|transactionId:def,storeNbr:4163,transactionTs:1645745890073000       |transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-26-20_20220228210729355.parquet|def          |4163    |2022-02-25 05:08:10.073   |{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}   |[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228210729355  |20220228210729355_0_4|transactionId:abc,storeNbr:4162,transactionTs:1645745890073000       |transactionDt=2022-02-25|d572dc96-ed78-46ae-8560-430d82456941-0_0-26-20_20220228210729355.parquet|abc          |4162    |2022-02-25 05:08:10.073   |{key, value, 1, 2, 2022-02-26 05:09:10, 1, { -> }}   |[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+------------------------------------------------------------------------+-------------+--------+--------------------------+-----------------------------------------------------+----------+--------+---------+----------------+-------------+
   
   ```
   
       


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



[GitHub] [hudi] nsivabalan commented on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan commented on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-884649224


   AFAIK, CustomKeyGenerator does pick field values as is. don't think it does any timestamp related conversion. 
   Can you confirm that during bulk_insert the claim_subm_dt field value was "2020-11-21 00:00:00.0", and while you upserted it was "1605916800000000". I mean in the incoming df. 


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



[GitHub] [hudi] vinothchandar closed issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
vinothchandar closed issue #3313:
URL: https://github.com/apache/hudi/issues/3313


   


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



[GitHub] [hudi] nsivabalan closed issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
nsivabalan closed issue #3313:
URL: https://github.com/apache/hudi/issues/3313


   


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



[GitHub] [hudi] mkk1490 edited a comment on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
mkk1490 edited a comment on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-884708261


   @nsivabalan during bulk_insert as well as insert for the first time into the table, the hoodie_key value was in timestamp. But during the upsert operation, it was converted into long. I even added a step just before write to convert to timestamp. It still didn't work. But when the field's datatype is date, this issue didn't come up.
   
   Sample data with original code:
   1. Hive external table with location pointing to s3 partitioned by src_sys_nm string(static value) and yr_mth int(dynamic value) both string
   2. This code was executed on EMR 5.33 with hudi 0.7.0
   3. Sample data has 2 different partition values for yr_mth where update is required
   Step 1:
   from pyspark.sql import functions as F
   df = spark.createDataFrame([
   ('10490113453106300000','561295328','2018-02-26 00:00:00','129999','18078735','15889231','OTHER PLACE OF SERVICE','53200900','RESP','201802'),
   ('10490120407605900000','559017519','2018-02-26 00:00:00','24290619','0','','OTHER PLACE OF SERVICE','53214384','RESP','201802'),
   ('10490116725506700000','1275017082','2018-02-27 00:00:00','209999','7875173','56874023','INPATIENT HOSPITAL','53201132','RESP','201802'),
   ('10420113469301100000','1705523399','2018-02-26 00:00:00','20045','7088459','55674640','EMERGENCY ROOM - HOSPITAL','53199046','RESP','201802'),
   ('10419114183800600000','29764982','2018-02-26 00:00:00','11659999','7786313','56694289','OFFICE','53207492','RESP','201802'),
   ('10490115064904900000','5007290360','2018-02-27 00:00:00','11720002','6937467','57968295','INPATIENT HOSPITAL','53207546','RESP','201803'),
   ('10419114186102800000','4968929315','2018-02-27 00:00:00','38930013','7311494','55315237','OFFICE','1002607736','RESP','201803'),
   ('10236114374904400000','320648979','2018-02-26 00:00:00','35160001','0','','INDEPENDENT LABORATORY','53217687','RESP','201803'),
   ('10809131289117500000','505439892','2018-02-28 00:00:00','20860001','2492213','52847481','OTHER PLACE OF SERVICE','53212703','RESP','201803'),
   ('10419123011601800000','3138080815','2018-02-25 00:00:00','32060002','7574212','58923898','INPATIENT HOSPITAL','1002608174','RESP','201803') ],
   ['claim_id','pat_id','claim_subm_dt','src_plan_id','src_pri_psbr_id','pri_az_cust_id','plac_of_srvc_cd','az_plan_id','src_sys_nm','yr_mth'] ).withColumn('claim_subm_dt', F.expr("cast(claim_subm_dt as timestamp)")).withColumn('yr_mth', F.expr("cast(yr_mth as int)"))
   
   hudi_options = {
   'hoodie.table.name': 'f_hudi_cow',
   'hoodie.datasource.write.recordkey.field': 'claim_id,pat_id,claim_subm_dt,plac_of_srvc_cd,src_pri_psbr_id,src_plan_id'
   'hoodie.datasource.write.partitionpath.field': 'src_sys_nm,yr_mth',
   'hoodie.datasource.write.table.Type': 'COPY_ON_WRITE',
   'hoodie.datasource.write.table.name': 'f_hudi_cow',
   'hoodie.combine.before.upsert': 'true',
   'hoodie.datasource.hive_sync.enable': 'true',
   'hoodie.datasource.hive_sync.table': 'f_hudi_cow',
   'hoodie.datasource.hive_sync.partition_fields': 'src_sys_nm,yr_mth',
   'hoodie.datasource.hive_sync.partition_extractor_class': 'org.apache.hudi.hive.MultiPartKeysValueExtractor',
   'hoodie.datasource.write.hive_style_partitioning': 'true',
   'hoodie.datasource.hive_sync.database': 'us_commercial_datalake_app_commons_dev',
   'hoodie.datasource.hive_sync.support_timestamp': 'true',
   'hoodie.datasource.hive_sync.auto_create_db':'false',
   'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.ComplexKeyGenerator',
   'hoodie.datasource.write.row.writer.enable': 'true',
   'hoodie.parquet.small.file.limit': '600000000',
   'hoodie.parquet.max.file.size': '1000000000',
   'hoodie.upsert.shuffle.parallelism': '10000',
   'hoodie.insert.shuffle.parallelism': '10000',
   'hoodie.bulkinsert.shuffle.parallelism': '25',
   'hoodie.clean.automatic': 'false',
   'hoodie.cleaner.commits.retained': 3,
   'hoodie.index.type': 'GLOBAL_SIMPLE',
   'hoodie.simple.index.update.partition.path':'true',
   'hoodie.metadata.enable': 'true'
   }
   
   df.write.format("org.apache.hudi").
   options(**hudi_options).option('hoodie.datasource.write.operation', 'bulk_insert').
   mode("overwrite").
   save("{s3_path}")
   
   Step 2:
   **Upsert has values 0 changed to 100. Updated Field name: src_pri_psbr_id**
   
   df_upsert  =spark.createDataFrame([
   ('10490113453106300000','561295328','2018-02-26 00:00:00','129999','18078735','15889231','OTHER PLACE OF SERVICE','53200900','RESP','201802'),
   ('10490120407605900000','559017519','2018-02-26 00:00:00','24290619','100','','OTHER PLACE OF SERVICE','53214384','RESP','201802'),
   ('10490116725506700000','1275017082','2018-02-27 00:00:00','209999','7875173','56874023','INPATIENT HOSPITAL','53201132','RESP','201802'),
   ('10420113469301100000','1705523399','2018-02-26 00:00:00','20045','7088459','55674640','EMERGENCY ROOM - HOSPITAL','53199046','RESP','201802'),
   ('10419114183800600000','29764982','2018-02-26 00:00:00','11659999','7786313','56694289','OFFICE','53207492','RESP','201802'),
   ('10490115064904900000','5007290360','2018-02-27 00:00:00','11720002','6937467','57968295','INPATIENT HOSPITAL','53207546','RESP','201803'),
   ('10419114186102800000','4968929315','2018-02-27 00:00:00','38930013','7311494','55315237','OFFICE','1002607736','RESP','201803'),
   ('10236114374904400000','320648979','2018-02-26 00:00:00','35160001','100','','INDEPENDENT LABORATORY','53217687','RESP','201803'),
   ('10809131289117500000','505439892','2018-02-28 00:00:00','20860001','2492213','52847481','OTHER PLACE OF SERVICE','53212703','RESP','201803'),
   ('10419123011601800000','3138080815','2018-02-25 00:00:00','32060002','7574212','58923898','INPATIENT HOSPITAL','1002608174','RESP','201803') ],
   ['claim_id','pat_id','claim_subm_dt','src_plan_id','src_pri_psbr_id','pri_az_cust_id','plac_of_srvc_cd','az_plan_id','src_sys_nm','yr_mth'] ).withColumn('claim_subm_dt', F.expr("cast(claim_subm_dt as timestamp)")).withColumn('yr_mth', F.expr("cast(yr_mth as int)"))
   
   hudi_options = {
   'hoodie.table.name': 'f_hudi_cow',
   'hoodie.datasource.write.recordkey.field': 'claim_id,pat_id,claim_subm_dt,plac_of_srvc_cd,src_pri_psbr_id,src_plan_id'
   'hoodie.datasource.write.partitionpath.field': 'src_sys_nm,yr_mth',
   'hoodie.datasource.write.table.Type': 'COPY_ON_WRITE',
   'hoodie.datasource.write.table.name': 'f_hudi_cow',
   'hoodie.combine.before.upsert': 'true',
   'hoodie.datasource.hive_sync.enable': 'true',
   'hoodie.datasource.hive_sync.table': 'f_hudi_cow',
   'hoodie.datasource.hive_sync.partition_fields': 'src_sys_nm,yr_mth',
   'hoodie.datasource.hive_sync.partition_extractor_class': 'org.apache.hudi.hive.MultiPartKeysValueExtractor',
   'hoodie.datasource.write.hive_style_partitioning': 'true',
   'hoodie.datasource.hive_sync.database': 'us_commercial_datalake_app_commons_dev',
   'hoodie.datasource.hive_sync.support_timestamp': 'true',
   'hoodie.datasource.hive_sync.auto_create_db':'false',
   'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.ComplexKeyGenerator',
   'hoodie.datasource.write.row.writer.enable': 'true',
   'hoodie.parquet.small.file.limit': '600000000',
   'hoodie.parquet.max.file.size': '1000000000',
   'hoodie.upsert.shuffle.parallelism': '10000',
   'hoodie.insert.shuffle.parallelism': '10000',
   'hoodie.bulkinsert.shuffle.parallelism': '25',
   'hoodie.clean.automatic': 'false',
   'hoodie.cleaner.commits.retained': 3,
   'hoodie.index.type': 'GLOBAL_SIMPLE',
   'hoodie.simple.index.update.partition.path':'true',
   'hoodie.metadata.enable': 'true'
   }
   
   df.write.format("org.apache.hudi").
   options(**hudi_options).option('hoodie.datasource.write.operation', 'upsert').
   mode("append").
   save("{s3_path}")
   
   Expected output: 0 to be updated to 100. 
   


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



[GitHub] [hudi] abhishekshenoy edited a comment on issue #3313: [SUPPORT] CoW: Hudi Upsert not working when there is a timestamp field in the composite key

Posted by GitBox <gi...@apache.org>.
abhishekshenoy edited a comment on issue #3313:
URL: https://github.com/apache/hudi/issues/3313#issuecomment-1054225531


   @nsivabalan i see the issue is closed . But in 0.10.1 i still face the duplicate issue when i provide a timestamp column as part of composite key.
   ```
       hoodiConfigs.put("hoodie.insert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.upsert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.bulkinsert.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.delete.shuffle.parallelism", "1")
       hoodiConfigs.put("hoodie.datasource.write.row.writer.enable", "true")
       hoodiConfigs.put("hoodie.table.keygenerator.class", classOf[ComplexKeyGenerator].getName)
       hoodiConfigs.put("hoodie.datasource.write.keygenerator.class", classOf[ComplexKeyGenerator].getName)
       hoodiConfigs.put("hoodie.datasource.write.recordkey.field", "transactionId,storeNbr,transactionTs")
       hoodiConfigs.put("hoodie.datasource.write.precombine.field", "messageMetadata.srcLoadTs")
       hoodiConfigs.put("hoodie.table.precombine.field", "messageMetadata.srcLoadTs")
       hoodiConfigs.put("hoodie.datasource.write.partitionpath.field", "transactionDt")
       hoodiConfigs.put("hoodie.datasource.write.payload.class",classOf[DefaultHoodieRecordPayload].getName)
       hoodiConfigs.put("hoodie.datasource.write.hive_style_partitioning", "true")
       hoodiConfigs.put("hoodie.datasource.write.table.type",COW_TABLE_TYPE_OPT_VAL)
       hoodiConfigs.put("hoodie.combine.before.upsert","true")
       hoodiConfigs.put("hoodie.table.name","huditransaction")
       hoodiConfigs.put("hoodie.datasource.write.keygenerator.consistent.logical.timestamp.enabled","true")
   ```    
   
   Tried with both BULK_INSERT_OPERATION_OPT_VAL and UPSERT_OPERATION_OPT_VAL
       
   Output dataset after first Insert , If you see Combine before insert did not work 
   Key (abc, 4162 , 2022-02-25T05:08:10.73-05:00)
   ```
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |_hoodie_commit_time|_hoodie_commit_seqno |_hoodie_record_key                                                   |_hoodie_partition_path  |_hoodie_file_name                                                      |transactionId|storeNbr|transactionTs          |messageMetadata                                   |prefixes  |dummyInt|dummyLong|dummyObjects    |transactionDt|
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |20220228183206147  |20220228183206147_0_1|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_2|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_3|transactionId:bcd,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|bcd          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_4|transactionId:cde,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|cde          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_5|transactionId:def,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|def          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   ```
   
   Republishing with an addition record for the same key (abc, 4162 , 2022-02-25T05:08:10.73-05:00) does not get deduped
   ```
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |_hoodie_commit_time|_hoodie_commit_seqno |_hoodie_record_key                                                   |_hoodie_partition_path  |_hoodie_file_name                                                      |transactionId|storeNbr|transactionTs          |messageMetadata                                   |prefixes  |dummyInt|dummyLong|dummyObjects    |transactionDt|
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   |20220228183206147  |20220228183206147_0_1|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_2|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_3|transactionId:bcd,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|bcd          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_4|transactionId:cde,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|cde          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183206147  |20220228183206147_0_5|transactionId:def,storeNbr:4163,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|f86d9a60-8465-410d-bca6-c478bf3a48e9-0_0-10-0_20220228183206147.parquet|def          |4163    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   |20220228183821299  |20220228183821299_0_1|transactionId:abc,storeNbr:4162,transactionTs:2022-02-25 05:08:10.073|transactionDt=2022-02-25|66ee158e-93f3-4ccc-8b2a-1712c3cdf5cf-0_0-2-0_20220228183821299.parquet |abc          |4162    |2022-02-25 05:08:10.073|{key, value, 1, 2, 2022-02-25 05:09:10, 1, { -> }}|[abc, def]|1       |1        |[{a, 1}, {a, 1}]|2022-02-25   |
   +-------------------+---------------------+---------------------------------------------------------------------+------------------------+-----------------------------------------------------------------------+-------------+--------+-----------------------+--------------------------------------------------+----------+--------+---------+----------------+-------------+
   ```
       


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