Gustavo de Morais created FLINK-41677:
-----------------------------------------

             Summary: Skip retractions in TO_CHANGELOG if op_mapping forwards 
only inserts and updates
                 Key: FLINK-41677
                 URL: https://issues.apache.org/jira/browse/FLINK-41677
             Project: Flink
          Issue Type: Improvement
          Components: Table SQL / Planner
            Reporter: Gustavo de Morais
            Assignee: Gustavo de Morais


{{TO_CHANGELOG}} with an {{op_mapping}} that maps only INSERT and UPDATE_AFTER 
never reads UPDATE_BEFORE or DELETE rows. The planner still keeps a 
{{ChangelogNormalize}} below it in the same cases as for {{TO_APPEND}}, for 
example when the input has no upsert key:

{code:sql}
CREATE VIEW order_status AS SELECT status, amount FROM orders;
SELECT * FROM TO_CHANGELOG(
  input => TABLE order_status,
  op_mapping => MAP['INSERT', 'INSERT', 'UPDATE_AFTER', 'UPDATE_AFTER']);
{code}

We should declare {{SKIP_RETRACTIONS}} for {{TO_CHANGELOG}} with such an 
{{op_mapping}}, so it benefits from the same optimizations. Without the 
{{ChangelogNormalize}}, the op column shows the row kinds of the source, as it 
already does for inputs with an upsert key.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to