mirror of
https://github.com/apache/doris.git
synced 2026-11-04 07:31:17 +00:00
### 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.