morningman opened a new pull request, #67529:
URL: https://github.com/apache/doris/pull/67529
### What problem does this PR solve?
Five P0 regression cases are muted on TeamCity. Three of them fail on
**every** master build — they only look green on `branch-4.1` because the suite
is skipped there (`if (true) { return }` at the top of
`test_temp_table.groovy`), so the mute is hiding persistent master failures
rather than flakiness. The other two are genuinely flaky.
| muted case | failures / last 300 P0 runs |
|---|---|
| `nereids_rules_p0/pkfk/eliminate_inner` | 251 |
| `compaction/test_vertical_compaction_agg_state` | 254 |
| `temp_table_p0/test_temp_table` | 250 |
| `load_p0/routine_load/test_routine_load` | 32 |
| `query_p0/cache/sql_cache_object_type` | 10 / 103 |
Two of them turned out to be real FE bugs.
#### 1. `CREATE TEMPORARY TABLE ... AS SELECT` wrongly rejected
A temporary table is created under `<sessionId>#TEMP#<name>`, but the CTAS
existence probe added in #66112 (`CreateTableCommand.targetTableExists`) looked
up the **bare** name:
```java
return database != null && database.isTableExist(qualifiedName.get(2));
```
So any normal table sharing that name makes the statement fail with `Table
'x' already exists`, even though the table it would create does not exist. This
is user-visible, not just a test problem:
```sql
CREATE TABLE t (id INT) DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES('replication_num'='1');
CREATE TEMPORARY TABLE t PROPERTIES('replication_num'='1') AS SELECT * FROM
src;
-- ERROR 1105: errCode = 2, detailMessage = Table 't' already exists
```
The probe now mangles the name exactly the way `InternalCatalog.createTable`
does. Plain `CREATE TEMPORARY TABLE t (...)` was never affected, because that
path goes straight to `Env.createTable`, which mangles internally. This is the
failure `temp_table_p0/test_temp_table` hits at line 456.
#### 2. `DROP TEMPORARY TABLE IF EXISTS` ignored `IF EXISTS`
`Database.getTableNullable` resolves the temporary table first and falls
back to the normal table, so when a session owns no temporary table of that
name, `table != null` and the earlier `ifExists` branch is skipped. The
`mustTemporary` guard then raised `Unknown table` unconditionally:
```sql
DROP TEMPORARY TABLE IF EXISTS never_existed; -- OK, no-op
DROP TEMPORARY TABLE IF EXISTS t; -- ERROR 1105: Unknown table
't' (t is a normal table)
```
`IF EXISTS` is now honored there. Without `IF EXISTS` the statement still
reports `Unknown table`, and a `DROP TEMPORARY TABLE` still never drops the
normal table.
### Case and baseline fixes
- **`eliminate_inner`** — baseline went stale on 2026-07-16 when #65264
added `shapeInfo()` overrides to `Cast`, `IsNull` and `Not`, which now preserve
the table qualifier (`cast(f as ...)` → `cast(fkt_not_null.f as ...)`).
`branch-4.1` has no such override, which is why it stayed green there.
Regenerated the 8 affected shape lines.
- **`test_vertical_compaction_agg_state`** — the first assertion compared a
literal `collect_set_merge` ordering, but `collect_set` is backed by
`flat_hash_set`, whose iteration order is unspecified. Wrapped it in
`array_sort`, matching the two sibling assertions already in the same suite.
The set contents were never wrong, only their order.
- **`test_routine_load`** — the `load_to_single_tablet` section waited only
for the job to leave `NEED_SCHEDULE` (i.e. to be *scheduled*), not for a batch
to be committed, and its baseline recorded the empty table that race produced.
It now uses the same data-visibility wait as the other nine sections, and the
baseline holds the rows that actually load. 9 of the 14 most recent failures of
this suite were exactly this tag.
- **`sql_cache_object_type`** — asserted that a cache entry survived. The FE
map holds soft values under a bounded size (`Config.sql_cache_manage_num`) and
the rows live in the BE result cache, so neither is guaranteed to persist. It
re-primes the cache instead; the assertion that each
`return_object_data_as_binary` setting is served its own result is unchanged.
### Release note
Fix `CREATE TEMPORARY TABLE ... AS SELECT` failing with "Table already
exists" when a normal table of the same name exists, and `DROP TEMPORARY TABLE
IF EXISTS` raising "Unknown table" in the same situation.
### Check List
- [x] Regression test
- [x] Added `temp_table_p0/test_temp_table_ctas_name_conflict` and
`temp_table_p0/test_drop_temporary_table`
- [x] Both FE fixes verified with a negative control: revert the fix,
rebuild FE, confirm the new case fails with the exact production error,
restore, confirm it passes
- [x] Also ran `eliminate_inner`, `test_vertical_compaction_agg_state`,
`sql_cache_object_type`, `test_routine_load` (all 11 sections), plus
`ddl_p0/test_drop_view_nereids` and `ddl_p0/test_truncate_table` for the shared
`dropTable` path
- [x] Behavior changed
- [x] Has been tested and documented above
- [x] Does this need documentation? No — this restores documented behavior.
### Note for reviewers
`temp_table_p0/test_temp_table` cannot be completed locally: it creates an
S3 backup repository at line 213, long before the CTAS this fixes, and that
needs credentials I do not have. A CI run is needed to confirm nothing else
sits behind line 456 — note that #65090 previously commented out a `show table
status` assertion in that suite instead of fixing it, so `SHOW TABLE STATUS`
still does not list the current session's temporary tables. That is left
untouched here.
Happy to split this into separate PRs (FE fixes / baseline updates) if
preferred.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]