gustavodemorais commented on code in PR #30123:
URL: https://github.com/apache/flink/pull/30123#discussion_r4718580352


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinitions.java:
##########
@@ -3650,6 +3647,17 @@ ANY, and(logical(LogicalTypeRoot.BOOLEAN), LITERAL)
                     .outputTypeStrategy(TypeStrategies.MISSING)
                     .build();
 
+    /** True when the {@code op_mapping} argument maps only INSERT and 
UPDATE_AFTER. */
+    @SuppressWarnings("unchecked")
+    private static TraitCondition forwardsOnlyInsertsAndUpdates() {

Review Comment:
   Done, the TO_CHANGELOG trait conditions now live in `ToChangelogDefinition`.



##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/ToAppendTest.xml:
##########
@@ -81,6 +102,53 @@ LogicalProject(id=[$0], name=[$1], offset=[$2])
       <![CDATA[
 ProcessTableFunction(invocation=[TO_APPEND(TABLE(#0), DEFAULT(), DEFAULT())], 
uid=[null], select=[id,name,offset], rowType=[RecordType(INTEGER id, 
VARCHAR(2147483647) name, BIGINT offset)], changelogMode=[I])
 +- TableSourceScan(table=[[default_catalog, default_database, 
upsert_source_with_metadata, metadata=[offset]]], fields=[id, name, offset], 
changelogMode=[I,UA,PD])
+]]>
+    </Resource>
+  </TestCase>
+  <TestCase name="testNonKeyFilterWithFullDeletes">
+    <Resource name="sql">
+      <![CDATA[SELECT * FROM TO_APPEND(input => TABLE a_names)]]>
+    </Resource>
+    <Resource name="ast">
+      <![CDATA[
+LogicalProject(id=[$0], name=[$1])
++- LogicalTableFunctionScan(invocation=[TO_APPEND(TABLE(#0), DEFAULT(), 
DEFAULT())], rowType=[RecordType(INTEGER id, VARCHAR(2147483647) name)])
+   +- LogicalProject(id=[$0], name=[$1])
+      +- LogicalProject(id=[$0], name=[$1])
+         +- LogicalFilter(condition=[=($1, _UTF-16LE'a')])
+            +- LogicalTableScan(table=[[default_catalog, default_database, 
upsert_source_with_full_deletes]])
+]]>
+    </Resource>
+    <Resource name="optimized rel plan">
+      <![CDATA[
+ProcessTableFunction(invocation=[TO_APPEND(TABLE(#0), DEFAULT(), DEFAULT())], 
uid=[null], select=[id,name], rowType=[RecordType(INTEGER id, 
VARCHAR(2147483647) name)], changelogMode=[I])
++- Calc(select=[id, CAST('a' AS VARCHAR(2147483647)) AS name], 
changelogMode=[I,UA,D])
+   +- Calc(select=[id, name], where=[=(name, 'a')], changelogMode=[I,UA,D])
+      +- TableSourceScan(table=[[default_catalog, default_database, 
upsert_source_with_full_deletes]], fields=[id, name], changelogMode=[I,UA,D])

Review Comment:
   Agreed. I have a prototype with a `DropRetractions` node that is pushed down 
below Calcs and Unions; I'll open it as a follow-up right after this PR.



##########
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/ToAppendTest.xml:
##########
@@ -81,6 +102,53 @@ LogicalProject(id=[$0], name=[$1], offset=[$2])
       <![CDATA[
 ProcessTableFunction(invocation=[TO_APPEND(TABLE(#0), DEFAULT(), DEFAULT())], 
uid=[null], select=[id,name,offset], rowType=[RecordType(INTEGER id, 
VARCHAR(2147483647) name, BIGINT offset)], changelogMode=[I])
 +- TableSourceScan(table=[[default_catalog, default_database, 
upsert_source_with_metadata, metadata=[offset]]], fields=[id, name, offset], 
changelogMode=[I,UA,PD])
+]]>
+    </Resource>
+  </TestCase>
+  <TestCase name="testNonKeyFilterWithFullDeletes">
+    <Resource name="sql">
+      <![CDATA[SELECT * FROM TO_APPEND(input => TABLE a_names)]]>
+    </Resource>
+    <Resource name="ast">
+      <![CDATA[
+LogicalProject(id=[$0], name=[$1])
++- LogicalTableFunctionScan(invocation=[TO_APPEND(TABLE(#0), DEFAULT(), 
DEFAULT())], rowType=[RecordType(INTEGER id, VARCHAR(2147483647) name)])
+   +- LogicalProject(id=[$0], name=[$1])
+      +- LogicalProject(id=[$0], name=[$1])
+         +- LogicalFilter(condition=[=($1, _UTF-16LE'a')])
+            +- LogicalTableScan(table=[[default_catalog, default_database, 
upsert_source_with_full_deletes]])
+]]>
+    </Resource>
+    <Resource name="optimized rel plan">
+      <![CDATA[
+ProcessTableFunction(invocation=[TO_APPEND(TABLE(#0), DEFAULT(), DEFAULT())], 
uid=[null], select=[id,name], rowType=[RecordType(INTEGER id, 
VARCHAR(2147483647) name)], changelogMode=[I])
++- Calc(select=[id, CAST('a' AS VARCHAR(2147483647)) AS name], 
changelogMode=[I,UA,D])

Review Comment:
   Agreed, created FLINK-41709 (merge Calcs after changelog mode inference) for 
it.



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