Skip to content

Conversation

@qianheng-aws
Copy link
Collaborator

Description

Support access to nested field of struct after fields command

Related Issues

Resolves #3459

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

// TODO: should use RelRecordType instead of MapSqlType here
// https://github.com/opensearch-project/sql/issues/3459
final RelDataType relKey = TYPE_FACTORY.createSqlType(SqlTypeName.VARCHAR);
// TODO: should we provide more precise type here?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: Do you have any idea how to specify precise type here? Calcite 1.41.0 has more strict type checking in RexToLixTranslator. If the Map value is another Array type, it cannot cast a ANY to Array.

Copy link
Collaborator Author

@qianheng-aws qianheng-aws Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can do type-conversion recursively for the nested fields and store them in a customized type? It will has benefit to resolve proper functions for these fields.

What's more I'm thinking we may be able to deprecate the flatten fields if these nested fields' type are precise enough. It's not worthy to do that now since we have flatten fields and it only takes effect after FIELD command. It should be done as another issue for enhancement.

Copy link
Collaborator Author

@qianheng-aws qianheng-aws Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the beginning, I'm thinking using RelRecordType instead of MapSqlType to address this issue, which will get better performance and naturally support variant types.

But looks like using map to support dynamic fields and type tolerance will be our trend. #4349 and #4433

@yuancu yuancu merged commit e06ebc5 into opensearch-project:main Nov 4, 2025
38 of 39 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Nov 4, 2025
Signed-off-by: Heng Qian <[email protected]>
(cherry picked from commit e06ebc5)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
LantaoJin pushed a commit that referenced this pull request Nov 4, 2025
…#4727)

(cherry picked from commit e06ebc5)

Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Heng Qian <[email protected]>
expani pushed a commit to vinaykpud/sql that referenced this pull request Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 2.19-dev bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE][Calcite Engine] Support access to nested fields after command FIELDS

3 participants