xylaaaaa opened a new pull request, #71356:
URL: https://github.com/apache/doris/pull/71356

   ### What problem does this PR solve?
   
   Issue Number: None
   
   Related PR: #71197
   
   Problem Summary:
   Backport #71197 (`6cf5f94e8c`) to `branch-4.1`. System-table binding in 
`BindRelation.handleMetaTable` returns before the `finally` block that 
registers SQL cache table dependencies or marks unsupported tables. When 
rewrites eliminate the system-table scan (e.g., a folded native system-table 
subquery over an OLAP/Hive outer table, or a Hive `$partitions` TVF query 
reduced to `PhysicalEmptyRelation`), the result can be cached without tracking 
the source table, allowing repeated queries to reuse stale SQL cache after the 
source table is dropped.
   
   ### Details
   
   - **Root cause**: Both native and TVF branches in 
`BindRelation.handleMetaTable` return before ordinary table dependency / 
unsupported-table registration runs.
   - **Fix**: Mark `SqlCacheContext#setHasUnsupportedTables(true)` right after 
`SysTableResolver.resolveForPlan` succeeds and before branching into native or 
TVF plans.
   - **Why bypass rather than cache**: Surviving system-table scans were 
already excluded by `CacheAnalyzer` and explicit TVFs by `BindExpression`, so 
disabling cache at bind time causes no regression on normal system-table 
queries while preventing stale reads across DDL, snapshot expiration, and range 
selectors. This matches common practice in other engines for live 
metadata/system tables (for example, BigQuery excludes `INFORMATION_SCHEMA` and 
external tables from cached results, and ClickHouse excludes `system.*` / 
`information_schema.*` by default via `query_cache_system_table_handling`).
   - **Release-branch adaptation**:
     - `BindRelation.java` change is identical to #71197.
     - Adapted `BindRelationTest` to Java 8 source compatibility on 
`branch-4.1` (`ImmutableList.of`, `ImmutableMap.of`, 
`Optional.orElseThrow(AssertionError::new)`).
   
   ### Release note
   
   Queries referencing catalog system tables bypass SQL result caching, 
including when optimization removes the system-table scan.
   
   ### Check List (For Author)
   
   - Test:
       - [x] FE build (`DISABLE_BUILD_UI=ON ./build.sh --fe`, including 
Checkstyle) passed.
       - [x] Unit Test (`./run-fe-ut.sh --run 'BindRelationTest'`): 9 passed, 0 
failures, 0 errors, 0 skipped (covering both native `LogicalFileScan` and TVF 
`LogicalTVFRelation` system-table branches).
   - Behavior changed:
       - [x] Yes: queries referencing catalog system tables always bypass SQL 
result caching.
   - Does this need documentation:
       - [x] No.
   


-- 
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]

Reply via email to