Gustavo de Morais created FLINK-41712:
-----------------------------------------

             Summary: Drop retractions early below PTFs that ignore retractions
                 Key: FLINK-41712
                 URL: https://issues.apache.org/jira/browse/FLINK-41712
             Project: Flink
          Issue Type: Improvement
          Components: Table SQL / Planner
            Reporter: Gustavo de Morais
            Assignee: Gustavo de Morais


PTFs that declare {{IGNORE_RETRACTIONS}}, such as {{TO_APPEND}}, never read 
UPDATE_BEFORE or DELETE rows, but these rows still flow through the plan up to 
the function. Keyless Calcs therefore forward key-only deletes as all-NULL 
rows, and a {{ChangelogNormalize}} is still needed for filters on non-key 
columns over sources with key-only deletes.

We should add a generic {{ChangelogFilter}} node that keeps only a given set of 
row kinds, and let the planner put it below such functions as low as possible: 
below Calcs and Unions, on top of sources and stateful operators. The function 
then never receives retractions, and the operators in between only see INSERT 
and UPDATE_AFTER rows.

{code:sql}
-- orders: upsert source with key-only deletes, e.g. upsert-kafka
CREATE VIEW paid_orders AS SELECT * FROM orders WHERE status = 'PAID';
SELECT * FROM TO_APPEND(input => TABLE paid_orders);
-- today: TableSourceScan -> Exchange -> ChangelogNormalize(condition=[status = 
'PAID']) -> ProcessTableFunction
-- after: TableSourceScan -> ChangelogFilter(keep=[I,UA]) -> Calc(status = 
'PAID') -> ProcessTableFunction
{code}



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

Reply via email to