Skip to content

Conversation

@924060929
Copy link
Contributor

picked from #57532

Support dereference expression for map/struct/variant

```sql
MySQL root@127.0.0.1:rqg> select
                       ->   named_struct('c', named_struct('c', 100)).c.c,
                       ->   map('a', 10, 'b', 20).a,
                       ->   map('a', 10, 'b', 20).b,
                       ->   cast('{"a":{"b":300}}' as variant).a.b;
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
| named_struct('c', named_struct('c', 100)).c.c | map('a', 10, 'b', 20).a | map('a', 10, 'b', 20).b | cast('{"a":{"b":300}}' as variant).a.b |
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
| 100                                           | 10                      | 20                      | 300                                    |
+-----------------------------------------------+-------------------------+-------------------------+----------------------------------------+
```

<b>the slot name parts binding priority:</b>
1. try to bind catalog, if binding failed, jump to 2
2. try to bind database, if binding failed, jump to 3
3. try to bind table, if binding failed, jump to 4
4. try to bind column

for example, `a.a.a.a.a`
first try to bind: catalog=a, database=a, table=a, column=a, sub
fields=a
second try to bind: catalog=&lt;current catalog&gt;, database=a,
table=a, column=a, sub fields=a.a
third try to bind: catalog=&lt;current catalog&gt;, database=&lt;current
database&gt;, table=a, column=a, sub fields=a.a.a
4th try to bind: catalog=&lt;current catalog&gt;, database=&lt;current
database&gt;, table=&lt;underscore table&gt;, column=a, sub
fields=a.a.a.a

(cherry picked from commit ac92fd4)
@924060929 924060929 requested a review from yiguolei as a code owner December 1, 2025 03:20
@Thearas
Copy link
Contributor

Thearas commented Dec 1, 2025

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@924060929
Copy link
Contributor Author

run buildall

@924060929
Copy link
Contributor Author

run buildall

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

PR approved by at least one committer and no changes requested.

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Dec 2, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

PR approved by anyone and no changes requested.

@yiguolei yiguolei merged commit 9546f5c into apache:branch-4.0 Dec 2, 2025
24 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants