Yukang-Lian opened a new pull request, #31461:
URL: https://github.com/apache/doris/pull/31461

   Problem:
   Inconsistent behavior occurs when executing partial column update `UPDATE` 
statements and `INSERT` statements on merge-on-write tables with the Nereids 
optimizer enabled. The number of columns passed to BE differs; `UPDATE` 
operations incorrectly pass all columns, while `INSERT` operations correctly 
pass only the updated columns.
   
   Reason:
   The Nereids optimizer does not handle partial column update `UPDATE` 
statements properly. The processing logic for `UPDATE` statements rewrites them 
as equivalent `INSERT` statements, which are then processed according to the 
logic of `INSERT` statements. For example, assuming a MoW table structure with 
columns k1, k2, v1, v2, the correct rewrite should be:
   * `UPDATE` table t1 set v1 = v1 + 1 where k1 = 1 and k2 = 2
    * =>
    * `INSERT` into table (v1) select v1 + 1 from table t1 where k1 = 1 and k2 
= 2
   
   However, the actual rewriting process does not consider the logic for 
partial column updates, leading to all columns being included in the `INSERT` 
statement, i.e., the result is:
   * `INSERT` into table (k1, k2, v1, v2) select k1, k2, v1 + 1, v2 from table 
t1 where k1 = 1 and k2 = 2
   
   This results in `UPDATE` operations incorrectly passing all columns to BE.
   
   Solution:
   Having analyzed the cause, the solution is straightforward: when rewriting 
partial column update `UPDATE` statements to `INSERT` statements, only retain 
the updated columns and all key columns (as partial column updates must include 
all key columns). Additionally, this PR includes error injection cases to 
verify the number of columns passed to BE is correct.
   
   ## Proposed changes
   
   Issue Number: close #xxx
   
   <!--Describe your changes.-->
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at 
[d...@doris.apache.org](mailto:d...@doris.apache.org) by explaining why you 
chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to