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

   ### Background
   
   JDBC catalogs expose external schemas that can include types Doris cannot 
read. Queries such as `COUNT(*)` do not reference a source column, but the 
physical scan still needs one column to preserve row counts.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #71242 (same fix on master), #41548 (introduced the 
constant-projection path)
   PR Type: Bugfix
   
   Problem Summary:
   
   `COUNT(*)` on a PostgreSQL table containing only unsupported columns can 
send `UNSUPPORTED` slot metadata to BE and abort it during descriptor 
construction. Select a supported fallback column when available and otherwise 
report an analysis error; validate serialized slots and reject unsupported 
metadata on BE as well. Most changed lines add coverage. Supported projections 
from mixed schemas continue to work.
   
   ### Details
   
   - **Change map:** 58 production lines and 351 test/result lines. FE 
selection and serialization checks account for 40 production lines; BE 
descriptor validation accounts for 18.
   - **Frequency:** Always for a column-free scan over an unsupported-only 
schema; PostgreSQL built-in `oid`, `name`, and `regnamespace` types reproduce 
it without extensions.
   - **Root cause:** A constant projection hides source column types from 
logical expression checks. `getSmallestSlot` can retain an unsupported scan 
column, whose BE datatype construction reaches a fatal type switch.
   - **Why existing tests missed it:** `CountStarSmallestSlotTest` and 
`SlotDescriptorTest` cover valid column metadata. PostgreSQL catalog/type 
suites cover readable types and arrays containing NULL, without an 
unsupported-only count scan.
   - **Fix:** Exclude recursively unsupported fallback types, check the actual 
serialized slot, and return a BE error before constructing its datatype. Check 
specifically for `UNSUPPORTED` so legitimate types such as `ARRAY<NULL>` remain 
accepted.
   - **Other paths and branches:** The shared scan/descriptor checks also cover 
other external scans and requests from older FEs, in both deployment modes. The 
master companion uses its newer descriptor converter; this branch validates 
slots in `SlotDescriptor.toThrift()`. `branch-4.1` shares the path but is not 
included here. Other release branches were not checked.
   - **Behavior change:** Unsupported-only scans report an error instead of 
crashing BE; supported fallback ordering is preserved. No protocol or 
configuration changes.
   
   ### Testing
   
   - Locally passed 32 FE tests, including six new slot-validation tests and 19 
existing COUNT(*) tests. The new FE tests failed three cases before the fix.
   - Locally passed 13 descriptor tests under ASAN. The baseline BE test 
reproduced the fatal unsupported-type check.
   - PostgreSQL 15 regression suite `test_pg_jdbc_unsupported_scan_types`: 12 
query expectations, generation and comparison both passed without skips. Covers 
unsupported-only scans, explicit unsupported projections, mixed schemas, source 
casts, and subsequent queries.
   - FE Checkstyle, clang-format 16, clang-tidy, and local review passed. All 
review findings were fixed and re-reviewed.
   
   ### Release note
   
   JDBC queries that retain an unsupported scan column now report a descriptive 
error instead of crashing a BE. Queries using supported columns from mixed 
schemas continue to work.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: No
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: Codex (GPT-6); GPT-6 Astra for local review.
   - Generated: Implementation, tests, and this description.
   - Human review: None reported in this session.
   - Prompts: Fix both master and branch-4.2, add unit and regression coverage, 
and resolve all local review findings before opening the pull requests.
   


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