morningman commented on code in PR #69488:
URL: https://github.com/apache/doris/pull/69488#discussion_r4410622623


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/RewriteDefaultExpression.java:
##########
@@ -18,7 +18,10 @@
 package org.apache.doris.nereids.rules.expression.rules;
 
 import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.TableIf;
+import org.apache.doris.datasource.plugin.PluginDrivenExternalTable;
 import org.apache.doris.nereids.CascadesContext;
+import org.apache.doris.nereids.StatementContext;
 import org.apache.doris.nereids.analyzer.UnboundFunction;

Review Comment:
   Fixed in 7ddd7c94d61. A DELETE pins the writer schema only for its delete 
sink and writes no row values, so no write-default applies to it. 
`RowLevelDmlCommand` now marks the target of a DELETE in the `StatementContext` 
when it pins the schema (on the run and the EXPLAIN paths), and 
`RewriteDefaultExpression` rejects `DEFAULT(column)` on a marked table with 
write-only defaults: `DEFAULT(c) cannot be used in a DELETE: the defaults of 
this table apply only to the rows that a statement writes`. That is what 
branch-4.2 does too: its DELETE installs no write schema context, so 
`DEFAULT(c)` fails there. UPDATE and MERGE are not marked and resolve as before.
   
   Tests: `RewriteDefaultExpressionTest#writeOnlyDefaultInADeleteIsRejected` 
and `RowLevelDmlCommandTest#onlyADeleteMarksItsTargetAsWritingNoRowValues`; 
skipping the check, or marking UPDATE instead of DELETE, makes exactly these 
two fail. `test_iceberg_initial_defaults` now expects the error for `DELETE ... 
WHERE default_int = DEFAULT(default_int)` on rows 20 to 22, which hold the 
write-default. The description now covers DELETE as well.
   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to