Repository navigation
Commit 724071d
[fix](fe) Keep DEFAULT(column) in a derived table of INSERT ... SELECT on its own FROM clause
### What problem does this PR solve?
Issue Number: None
Related PR: #69488
Problem Summary:
For a target with write-only defaults (Iceberg), `InsertUtils.normalizePlan`
resolves `DEFAULT(column)` in the select lists of an `INSERT ... SELECT` by
name against the target's pinned writer schema, before the source relations
are bound. It walked the whole query plan with `rewriteUp`, so it also
rewrote the projections of a derived table in `FROM`, which is a query of its
own. With a source `src(c INT DEFAULT 7)` and a target `t(c INT)` whose
write-default is 9,
INSERT INTO t(c) SELECT v FROM (SELECT DEFAULT(c) AS v FROM src) q
wrote 9 instead of 7, and `DEFAULT(src.c)` inside the derived table failed
with "column in assignment list is invalid", because its qualifier was
checked against the target. branch-4.2's
`resolveIcebergSelectDefaultReferences` walks the plan the same way.
The walk now stops at `LogicalSubQueryAlias`. `DEFAULT(column)` inside a
derived table is left to binding and names a column of that table's own
`FROM` clause, as it does on master. The select lists of the INSERT's own
query, set operation branches included, are resolved as before, still
bottom-up.
### Release note
None
### Check List (For Author)
- Test: Unit Test
- New `InsertUtilsTest#writeOnlyDefaultInDerivedTableNamesItsOwnSource`
covers an unqualified and a qualified `DEFAULT(score)` inside a derived
table (left to binding while the outer `DEFAULT(name)` resolves to the
pinned default), and a UNION whose first branch resolves and whose
second branch reads a derived table. It fails with the previous
`rewriteUp` walk.
- `InsertUtilsTest`, `ConnectorWriteSchemaUtilsTest`,
`RewriteDefaultExpressionTest`, `IvmDeltaRewriterTest` and
`IvmLinearDeltaHandlerTest` pass, as does the fe-core checkstyle.
- Behavior changed: Yes. Within this PR, `DEFAULT(column)` in a derived
table of an `INSERT ... SELECT` into an Iceberg table no longer resolves
against the target; it keeps master's meaning.
- Does this need documentation: No
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>1 parent fc049a2 commit 724071d
2 files changed
Lines changed: 64 additions & 17 deletions
File tree
- fe/fe-core/src
- main/java/org/apache/doris/nereids/trees/plans/commands/insert
- test/java/org/apache/doris/nereids/trees/plans/commands/insert
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
526 | 527 | | |
527 | 528 | | |
528 | 529 | | |
| 530 | + | |
| 531 | + | |
529 | 532 | | |
530 | 533 | | |
531 | 534 | | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
549 | 555 | | |
550 | 556 | | |
551 | 557 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
508 | 510 | | |
509 | 511 | | |
510 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
511 | 552 | | |
512 | 553 | | |
513 | 554 | | |
| |||
0 commit comments