Skip to content

branch-4.0: [fix](fe) Handle generated columns in delete partial update#65067

Open
bobhan1 wants to merge 1 commit into
apache:branch-4.0from
bobhan1:backport/4.0/pr-64884-generated-column-delete
Open

branch-4.0: [fix](fe) Handle generated columns in delete partial update#65067
bobhan1 wants to merge 1 commit into
apache:branch-4.0from
bobhan1:backport/4.0/pr-64884-generated-column-delete

Conversation

@bobhan1

@bobhan1 bobhan1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: N/A

Related PR: #64884

Problem Summary:

This PR backports #64884 to branch-4.0.

For DELETE on unique merge-on-write tables with generated columns and
enable_mow_light_delete=false, Doris rewrites DELETE into a partial update.
Before the fix, BindSink still treated generated columns as target columns to
bind and recompute. If the generated-column expression referenced ordinary
columns that were not part of the DELETE partial-update output, analysis could
fail before the DELETE was planned.

This change detects the DELETE partial-update path in BindSink, avoids
auto-adding omitted generated columns for that path, and keeps existing
generated-column handling for normal INSERT/UPDATE partial updates.

Release note

None

Check List (For Author)

  • Test
    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason

Regression test:

./run-regression-test.sh --run -d regression-test/suites/ddl_p0/test_create_table_generated_column -s test_generated_column_delete
./run-regression-test.sh --run -d regression-test/suites/ddl_p0/test_create_table_generated_column -s test_partial_update_generated_column

Unit test:

./run-fe-ut.sh --run org.apache.doris.nereids.trees.plans.DeleteFromUsingCommandTest

Manual test:

git diff --check HEAD~1 HEAD
./build.sh --fe -j100
./build.sh --be -j100

The local regression cluster was restarted after rebuilding BE. FE and BE both
reported version doris-4.0.6-rc02-a9d12207ae5 before running regression.

  • Behavior changed:

    • No.
    • Yes. DELETE partial updates on unique MOW tables no longer try to recompute omitted generated columns.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

…4884)

Issue Number: N/A

Related PR: N/A

Original Problem: DELETE failed during analysis on a unique
merge-on-write table that contains a generated column when light delete
is disabled. The original reported table had a generated VARIANT column:

```sql
new_col variant AS (receive_address_detail) NULL
```

and the DELETE failed with:

```text
errCode = 2, detailMessage = cannot find column from target table /receive_address_detail
```

A minimized reproduction is:

```sql
create table test_gen_col_mow_delete_partial_update (
    a int,
    b int,
    c int as (b + 1),
    d int
)
unique key(a)
distributed by hash(a) buckets 1
properties (
    "enable_unique_key_merge_on_write" = "true",
    "enable_mow_light_delete" = "false",
    "replication_num" = "1"
);
```

After inserting rows, running:

```sql
delete from test_gen_col_mow_delete_partial_update where a = 1;
```

failed with:

```text
java.sql.SQLException: errCode = 2, detailMessage = cannot find column from target table [b]
```

Problem Summary: DELETE on a unique merge-on-write table with light
delete disabled is rewritten to a partial update load that writes key
columns and the delete sign. BindSink used to auto-add every generated
column and then recompute omitted generated columns, which required
ordinary value columns that were not part of the DELETE output and
caused analysis to fail.

This change treats DELETE partial updates specially: generated columns
that are not emitted by the child plan are skipped, and generated
columns that are emitted by the child plan use that child output
directly. Normal partial update generated-column dependency checks are
unchanged.

The tests cover generated value columns, generated key columns, a
generated value-column table with an omitted NOT NULL value column that
has no default value, and the original VARIANT generated-column shape
based on `receive_address_detail`.

Fix DELETE failure on unique merge-on-write tables with generated
columns when light delete is disabled.

- Test: Regression test / Unit Test
    - `./build.sh --fe -j100`
- `./run-fe-ut.sh --run
org.apache.doris.nereids.trees.plans.DeleteFromUsingCommandTest`
- `./run-regression-test.sh --run -d
regression-test/suites/ddl_p0/test_create_table_generated_column -s
test_generated_column_delete -forceGenOut`
- `./run-regression-test.sh --run -d
regression-test/suites/ddl_p0/test_create_table_generated_column -s
test_generated_column_delete`
- `./run-regression-test.sh --run -d
regression-test/suites/ddl_p0/test_create_table_generated_column -s
test_partial_update_generated_column`
- Behavior changed: Yes (DELETE now succeeds for unique merge-on-write
tables with generated columns when light delete is disabled.)
- Does this need documentation: No

(cherry picked from commit c02808a)
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@bobhan1 bobhan1 changed the title [branch-4.0][fix](fe) Handle generated columns in delete partial update branch-4.0: [fix](fe) Handle generated columns in delete partial update Jul 1, 2026
@bobhan1 bobhan1 marked this pull request as ready for review July 1, 2026 04:16
@bobhan1 bobhan1 requested a review from morningman as a code owner July 1, 2026 04:16
@bobhan1

bobhan1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants