opensearch-project / opensearch-project/sql

[FEATURE] Support creating typed arrays & structs with Calcite

Open
#3,751 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

calcite enhancement PPL
Dominant language
Java
Stars
176
Forks
229
Avg merge
2d 21h
Merged PRs (30d)
43

Description

Is your feature request related to a problem?

Currently all arrays are created with type array<any>.

Reason: in OpenSearchTypeFactory.java#L176:

public static RelDataType convertExprTypeToRelDataType(ExprType fieldType, boolean nullable) 
...
        case ARRAY:
          return TYPE_FACTORY.createArrayType(
              TYPE_FACTORY.createSqlType(SqlTypeName.ANY, nullable), -1);

This raises a number of problem since we can not infer element types. E.g. when expanding an array, we can't know the element type until runtime.

What solution would you like?
Support creating array types with known element types.

What alternatives have you considered?
Not yet

Do you have any additional context?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in core/src/main/java/org/opensearch/sql/calcite/utils/OpenSearchTypeFactory.java at the ARRAY handling around line 176. Read the discussion in PR 3745 and issue 3229 for context on Calcite type creation and element inference. Done means arrays can be created with known element types, with the requested typed-array and struct support addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.