[enhance](struct) Merge struct_element into element_at#64027
Open
csun5285 wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
run buildall |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
FE Regression Coverage ReportIncrement line coverage |
Contributor
TPC-H: Total hot run time: 29274 ms |
Contributor
TPC-DS: Total hot run time: 169828 ms |
morrySnow
reviewed
Jun 3, 2026
| // visitUnboundFunction where the named call `element_at(s,'f')` gets this same rewrite. Apply the | ||
| // shared ElementAt.rewriteWhenAnalyze() here so both syntaxes behave identically; otherwise the | ||
| // BE receives element_at(struct) and aborts. | ||
| if (coerced instanceof RewriteWhenAnalyze) { |
Contributor
There was a problem hiding this comment.
maybe we need merge element_at and struct_element into one function
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>
Contributor
Author
|
run buildall |
csun5285
added a commit
to csun5285/doris-website
that referenced
this pull request
Jun 3, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
doc: apache/doris-website#3898 element_at access for STRUCT type
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)