www2388258980 opened a new issue, #891:
URL: https://github.com/apache/incubator-paimon/issues/891

   ### Search before asking
   
   - [X] I searched in the 
[issues](https://github.com/apache/incubator-paimon/issues) and found nothing 
similar.
   
   
   ### Paimon version
   
   paimon0.4(paimon-flink-1.16-0.4-20230331.003039-13.jar)
   
   ### Compute Engine
   
   flink1.16.0
   
   ### Minimal reproduce step
   
   **table schema**
   ods_ticket_fees ingest data from pgsql(flink cdc,cdc -> ods_ticket_fees )
   `
   create table ods_ticket_fees(
        id int,
        ticket_id int,
        `type` string,
        `data` string,
        total decimal(11,2),
        primary key(id) not enforced
   )
   with (
        'changelog-producer' = 'input',
        'snapshot.time-retained' = '24h'
   );
   create table dwa_ticket_fees(
     ticket_id int,
     labor_cost decimal(12,2) ,
     accessory_cost decimal(12,2) ,
     consumable_cost decimal(12,2),
     primary key(ticket_id) not enforced
   )
   with (
     'merge-engine' = 'aggregation',
     'changelog-producer' = 'full-compaction',
     'snapshot.time-retained' = '24h',
     'fields.labor_cost.aggregate-function' = 'sum',
     'fields.accessory_cost.aggregate-function' = 'sum',
     'fields.consumable_cost.aggregate-function' = 'sum'
   );
   
   SQL A:
   insert into 
dwa_ticket_fees(ticket_id,labor_cost,accessory_cost,consumable_cost)
   select a.ticket_id,
       case when type='fee' then total else 0 end labor_cost,
       case when type='accessory' then total else 0 end accessory_cost,
       case when type='material' then total else 0 end consumable_cost
   from ods_ticket_fees a;
   
   SQL B:
   select a.ticket_id,
     sum(case when type='fee' then total else 0 end) labor_cost,
     sum(case when type='accessory' then total else 0 end) accessory_cost,
     sum(case when type='material' then total else 0 end) consumable_cost
   from catalog_paimon.ods_medatc_fts.src_public_ticket_fees a
   group by ticket_id;
   `
   **Preparin data int Postgres** \\
   `
   INSERT INTO ticket_fees(id, ticket_id, "type", "data", total, )
   VALUES(40, 1352, 'fee', '平板', 1.00);
   INSERT INTO ticket_fees(id, ticket_id, "type", "data", total, )
   VALUES(1, 1352, 'accessory', '电脑', 1111.00);
   `
   ** Result** \\
   SQL A and SQL B are equal. for updates,SQL A and SQL B should equal(Only sum 
supports retraction (UPDATE_BEFORE and DELETE), others aggregate functions do 
not support retraction) and ods_ticket_fees produce the correctness of 
changelog(-U,+U). However,the value of SQL A keeps adding up.
   **update sql**
   `
   update ticket_fees set "data"='平板1' where id=40;
   update ticket_fees set "total"=2  where id=40;
   `
   
   ### What doesn't meet your expectations?
   
   aggragation model produce right result
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
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: [email protected]

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

Reply via email to