Skip to content

[FEATURE] Add support for alias field type #3201

@dai-chen

Description

@dai-chen

Is your feature request related to a problem?

Currently PPL query does not support fields of alias type. When an alias field is used in a PPL query, it results in a "field not found" semantic error as below:

# Index mapping:
{
  "mappings": {
    "properties": {
      "@gender": {
        "type": "alias",
        "path": "gender"
      },
      "gender": {
        "type": "text",
        "fielddata": true
      },

# IT
  @Test
  public void testFieldsWithOneField() throws IOException {
    JSONObject result =
        executeQuery(String.format("source=%s | fields @gender", TEST_INDEX_ACCOUNT));
    verifyColumn(result, columnName("firstname"));
  }

# Error message
method [POST], host [http://127.0.0.1:62157], URI [/_plugins/_ppl], status line [HTTP/1.1 400 Bad Request]
{
  "error": {
    "reason": "Invalid Query",
    "details": "can't resolve Symbol(namespace=FIELD_NAME, name=@gender) in type env",
    "type": "SemanticCheckException"
  },
  "status": 400
}

What solution would you like?

Add alias field name to symbol table when analyzing the query to avoid such semantic error.

What alternatives have you considered?

Keep current behavior and document the limitation.

Do you have any additional context?

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions