Repository navigation
[enhance](struct) Merge struct_element into element_at - #64027
Conversation
|
run buildall |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
TPC-H: Total hot run time: 29274 ms |
TPC-DS: Total hot run time: 169828 ms |
cbd7023 to
5a06428
Compare
Subscript access on a struct, s['field'], is parsed directly into an element_at expression, but element_at only supported ARRAY and MAP and aborted on a DCHECK in the BE (DORIS-26105). Rather than routing struct field access through a separate struct_element function, make element_at the single entry point for array/map/struct field access. BE: FunctionArrayElement (element_at) now resolves a struct field by its constant int/string index and the standalone struct_element function is removed. The struct_element name is registered as a plain extra name on the same implementation (not an alias: element_at is in the variadic set because FunctionVariantElement shares the name, so an alias key would be mangled to element_atStructString and fail to resolve), keeping any persisted plan that still references struct_element resolvable. FE: the StructElement node is removed and every struct field access form (s['f'], s.f, element_at(s,'f'), struct_element(s,'f')) converges on ElementAt, which absorbs the struct signature, legality check, int->name normalization and the nested-column-pruning access path. struct_element remains a user-facing SQL name bound to ElementAt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5a06428 to
51f5033
Compare
Projecting a struct field by its original mixed-case name (e.g. reading a migrated Iceberg table whose schema keeps sName while Doris stores it as sname, then querying sName) failed with an opaque error: [INTERNAL_ERROR] function return type check failed ... real_return_type is nullptr. Root cause: struct field names are canonically lower-cased by the FE (both native DDL and the Iceberg schema read go through StructField.toLowerCase), but a query may reference a field with different casing. The FE matches the field case-insensitively and forwards the original-case name to the BE, while DataTypeStruct::try_get_position_by_name compared case-sensitively, so the field was not found, get_return_type returned nullptr and build() reported the opaque internal error. Fix: - DataTypeStruct::try_get_position_by_name / get_position_by_name match the field name case-insensitively (iequal). - element_at's struct return-type path throws the concrete "field not found / index out of bound" error instead of returning nullptr, so an unresolvable field surfaces a clear message rather than an internal error. DORIS-26117 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
run buildall |
Reflect apache/doris#64027 latest changes: struct_element is now subsumed by element_at (kept as a backward-compatible alias), struct field names are matched case-insensitively, document the dot operator s.field access form, and update the non-constant index error message. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
TPC-H: Total hot run time: 29127 ms |
TPC-DS: Total hot run time: 169412 ms |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
FE UT Coverage ReportIncrement line coverage |
…tainer The struct_element->element_at merge kept PropagateNullLiteral on ElementAt (inherited from the old StructElement). FoldConstantRuleOnFE then folds any element_at whose argument is a null literal to a NULL literal. That is correct when the container is null (element_at(NULL, i)) but wrong for a map: a map may contain a null key, so element_at(map, NULL) must be evaluated by the BE to look up that key, otherwise m[null] always returns NULL. Fix: keep PropagateNullLiteral (so element_at(NULL, i) and a null array/struct index still fold to NULL, e.g. the union push-down in PruneNestedColumnTest), but override foldable() to return false for the single problematic shape element_at(map, <null literal>), so it is left to the BE instead of being folded away. Fixes the regression in map_agg and test_map_load_and_function where m[NULL] returned NULL instead of the null-key value. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2138066 to
dd81b69
Compare
TPC-H: Total hot run time: 29293 ms |
TPC-DS: Total hot run time: 170738 ms |
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
Per apache/doris#64027, STRUCT_ELEMENT is removed since 4.1.3 and subsumed by ELEMENT_AT. Add a caution notice on the STRUCT_ELEMENT page (EN/ZH) pointing users to ELEMENT_AT and the equivalent subscript/dot syntax. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
STRUCT_ELEMENT is removed since 4.1.3 (apache/doris#64027). Rewrite the "Element Access" section to lead with ELEMENT_AT / subscript / dot syntax, add a caution notice, and switch the nested-struct example to the dot operator (verified by the test_dereference regression test). EN + ZH. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…T_ELEMENT (#3898) Update the STRUCT field-access docs to match apache/doris#64027, which merges `struct_element` into `element_at`. `STRUCT_ELEMENT` is removed since version 4.1.3; struct fields are now accessed via `ELEMENT_AT`, the subscript operator, or the dot operator — all equivalent: - `ELEMENT_AT(s, k)` / `ELEMENT_AT(s, 'field_name')` - `s[k]` / `s['field_name']` - `s.field_name` (and nested `s.a.b`, for a STRUCT column) ## Versions - [x] dev - [x] 4.x - [ ] 3.x - [ ] 2.1 or older (not covered by version/language sync gate) ## Languages - [x] Chinese - [x] English - [ ] Japanese candidate translation needed ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built - [ ] Updated required version and language counterparts, or explained why not - [ ] If only one language changed, confirmed whether source/translation counterparts need sync --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
/review |
There was a problem hiding this comment.
Automated review summary:
I did not find additional distinct inline issues beyond the existing review threads, so I am not duplicating those comments. The current PR still appears to contain the two already-raised blockers:
struct_elementis still removed as a FE/BE public function name, which is a user-visible incompatible change for existing SQL, views, clients, and persisted references.- Struct integer index resolution in FE still uses truncated
intvalues (IntegerLikeLiteral#getIntValue()/ equivalent int conversion), so indexes wider thanInteger.MAX_VALUEcan be analyzed with the wrong field before BE rejects the original value.
Critical checkpoint conclusions:
- Goal/test: The PR aims to route struct access through
element_atand updates tests for common struct access, NULL struct rows, subscript syntax, NCP paths, and BE field lookup. Existing tests cover the intended happy paths, but the wide-index negative regression requested in the existing thread is still missing. - Scope/focus: The implementation is mostly focused on the
struct_elementtoelement_atmerge, with broad test/query rewrites caused by removing the old name. - Concurrency/lifecycle: No new shared mutable state, background threads, lock ordering, or special lifecycle/static-initialization concerns were found in the reviewed function/rule paths.
- Configuration/compatibility: No config items are added. There is a compatibility concern because the public
struct_elementname is removed; this is already covered by an existing inline thread. - Parallel paths: FE and BE both add struct handling to
element_at; variant/array/map paths are preserved. The removedstruct_elementalias remains the main parallel-path/compatibility gap. - Conditional checks/error handling: BE now returns concrete field-not-found/out-of-bound errors instead of opaque return-type failure, which is good. The FE wide integer bounds check remains problematic as already reported.
- Test coverage/results: Regression and BE unit tests were added/updated for normal struct access and case-insensitive BE field lookup. Negative coverage for out-of-range wide integer struct indexes and compatibility coverage for
struct_elementare still absent. - Observability: No new long-running or distributed operation is introduced; existing errors include the function/index/name context and are sufficient for this path.
- Transaction/persistence/data writes: Not applicable; no transaction, persisted metadata, storage format, or data write path changes were found.
- FE/BE protocol/type consistency: FE and BE agree for ordinary struct field resolution, including nullable result shape. The already-reported wide-index truncation can still make FE infer a different field type than BE validates.
- Security model: Auth/TLS-sensitive areas are not part of this PR's actual file list from
gh pr view; no additional security finding was identified. - User focus: No additional user-provided review focus was supplied.
Please resolve the existing blocker threads before merge.
|
PR approved by at least one committer and no changes requested. |
…ion suites (#64204) PR #64027 removed the struct_element SQL function (merged into element_at), but PR #63736 (merged just before it) added the topn_expr_pullup and topn_lazy_nested_column_pruning suites that still call struct_element(...). Because #64027 was prepared before #63736 landed, its cleanup never touched these new files, leaving regression suites that call a removed function. ### What problem does this PR solve? Issue Number: close #xxx Related PR: #xxx Problem Summary: ### Release note None ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into --> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
apache#64027 merged struct_element into element_at and removed the struct_element function entirely. Users upgrading from an older version whose SQL / views still reference struct_element then fail with "function not found". Re-register struct_element as an alias of element_at on both sides: - FE: register the name struct_element on the ElementAt class, so it resolves to ElementAt (whose name is element_at) and reuses all of element_at's struct-handling logic; the function name sent to BE is always element_at. - BE: add a defensive register_alias so a struct_element name also resolves to the element_at implementation. Add regression cases asserting struct_element over a struct returns exactly the same results as element_at. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
#64027 merged struct_element into element_at and removed the struct_element function entirely. Users upgrading from an older version whose SQL / views still reference struct_element then fail with "function not found".
#64027 merged struct_element into element_at and removed the struct_element function entirely. Users upgrading from an older version whose SQL / views still reference struct_element then fail with "function not found".
### Background FE checks and folds constant function arguments. BE evaluates row arguments and resolves STRUCT ordinals for execution. ### What problem does this PR solve? Issue Number: None Related PR: #64027 (retained STRUCT ordinal narrowing) PR Type: Bugfix Problem Summary: Some function arguments lose high bits, change sign, or overflow before validation. For example, element_at(struct(7), 4294967297) returns 7 instead of an error. This change extracts six fixes and their tests. Valid boundary inputs return correct results; invalid arguments report errors. ### Details - **Change map:** 173 production lines: STRUCT lookup and pruning 68, substring counts 6, array lengths 14, bitmap elements 54, funnel windows 16, ngram sizes 7, and the shared range helper 8. Tests change 390 lines; generated results add 23. No documentation or protocol changes. - **Frequency:** Always for the reported boundary inputs. BE substring behavior can depend on compiler handling of signed overflow. - **Root cause:** STRUCT and ngram narrow integers before checks. SUBSTRING_INDEX negates INT_MIN. ARRAY_SLICE adds length before clamping. Bitmap functions convert negative elements to unsigned values. An empty funnel event list bypasses window validation. - **Why existing tests missed it:** StructOrdinal coverage was absent. Existing STRUCT, StringArithmetic, bitmap and funnel UTs use ordinary values. The closest SQL suites omit wide aliases and signed minima; test_ngram_search_gram_num covers ordinary negative sizes but not values beyond INT or BIGINT. - **Fix:** Check full-width values before conversion. Widen before negation or absolute value. Clamp length before addition. Reject negative elements and windows before execution shortcuts. - **Other paths and branches:** Cover STRUCT normalization and pruning, both bitmap functions, FE constants, and BE rows. ARRAY_SLICE INT64_MIN positions remain outside this extraction. Source commits are 62eaf86, 9d58004, and d73c2e1. Release-branch applicability was not rechecked. - **Behavior change:** Invalid ordinals, bitmap elements, funnel windows, and ngram sizes report errors. Extreme valid substring counts and array lengths return correct results. No configuration or storage-format change. ### Testing Local checks on master 0a6b84b plus this patch: - build.sh --be --fe: passed with ASAN; FE Checkstyle passed. - run-fe-ut.sh: 109 tests passed across five selected classes. - run-be-ut.sh: 35 tests passed, including all five new BE cases. - run-regression-test.sh: generated two new result files, checked their values, then passed test_struct_field_ordinal, test_selected_function_parameters, and test_ngram_search_gram_num. No skips. - C++ formatting, header hygiene, and clang-tidy on eight changed files passed. Supplied reports reproduce the old results on the same master baseline. That baseline was not rebuilt during this extraction. Runtime checks used the candidate artifacts from this worktree. ### Release note Fix incorrect results and missing argument errors in STRUCT access, SUBSTRING_INDEX, ARRAY_SLICE, BITMAP_CONTAINS, BITMAP_REMOVE, WINDOW_FUNNEL_V2, and NGRAM_SEARCH. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Codex (GPT-6 family). - Generated: Selected patch, scoped tests, review notes, and this description. - Human review: The author has not supplied a human-review statement. <!-- Recommended: develop the change with the develop-with-evidence skill and write this description with the doris-pr-description skill, both from https://github.com/apache/doris-skills (the doris-skills submodule of this repository). --> ### Background <!-- How the feature or module this PR touches works today, in two to four plain sentences, for a reviewer who doesn't know it. Link the user doc if there is one. Leave the problem and the fix to Problem Summary. --> ### What problem does this PR solve? <!-- Issue Number: "close #N" if this PR resolves the issue, "#N" if it only relates to it, "None" if there is none. A Feature needs an issue. --> <!-- Related PR: "#N (relation)" for each PR a reviewer should know about, such as "#123 (introduced the bug)", separated by commas. Write "None" if no related PR is known. --> <!-- PR Type: Bugfix, Performance, Feature, Enhancement, Refactor, Test, Build/CI/Chore, Revert, Release/Dependency, or Other. --> Issue Number: Related PR: PR Type: Problem Summary: <!-- Two to five sentences: the problem or need and who is affected; the approach in one sentence; when the diff is larger than that suggests, what else it had to handle, or that most of it is tests; and what existing users see after an upgrade. --> ### Details <!-- For a diff of more than about 300 changed lines, start with "- **Change map:**": how many lines are production code, tests, generated files, and docs, then the code in parts, each with the problem it handles and its size. Then answer each field of your PR type on its own line, as "- **Field:** answer", in this order: Bugfix: Frequency, Root cause, Why existing tests missed it, Fix, Other paths and branches Performance: Why it was slow, Optimization, Results, Applicability and cost Feature: Scope, Design, Usage, Default behavior, Compatibility Enhancement: Before and after, Configs and defaults, Impact on existing users Refactor: Moves vs. logic changes, Behavior change, Compatibility, Performance impact, Rollback Test, adding tests: Scenarios, What existing tests miss, Fails when broken Test, fixing a test: Failure, Cause, Stability evidence Build/CI/Chore: Affected, Developer and release impact, License and third-party, Rollback Revert: Why not fix forward, Original author notified, Follow-up Release/Dependency: Versions, Upstream changes, Compatibility, Rollback Other: Why Other "None" is a valid answer when it is true. Don't restate the diff. --> ### Testing <!-- The tests, suites, or commands that ran, what each shows, and where it ran (locally or in CI). For a fix, the test that fails before it and passes after. --> ### Notes for Reviewers <!-- Optional; delete this section if there is nothing to say. Why each non-obvious edit was made, what you are unsure about, and where to start reading if Details has no Change map. --> ### Release note <!-- One paragraph on what users will notice, or None. --> ### Check List (For Author) <!-- Behavior changed: "No", or "Yes (see Details)" with a Behavior change field in Details. --> <!-- Does this need documentation: "No", or "Yes" with the apache/doris-website PR or the plan. --> <!-- Pre-submission status: "Ready"; "Partially verified: " and what is not verified; or "Not ready: " and why, for a Draft PR. --> - Behavior changed: - Does this need documentation: - Pre-submission status: ### AI Disclosure <!-- Tool: the agent and model, or None. Generated: the parts it wrote (code, tests, this description), or None. Human review: what you reviewed of the generated parts, or "Not applicable" without AI tools. You may add "- Prompts:" to summarize how you directed the agent. --> - Tool: - Generated: - Human review:
Other databases / query engines do not have such a function, so we removed struct_element.
Struct fields should be accessed via element_at, the subscript operator s['f'] / s[idx], or the dot operator s.field.
doc: apache/doris-website#3898
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)