Skip to content

[BUG] rename does not work with struct field #3279

Closed

Description

@currantw

What is the bug?

The rename command returns incorrect results when applied to a struct field.

While the renamed field is correctly added to the search results, additional fields are also added that correspond to each of the fields within the struct, and which contain null values.

Consider the following input data:

name location
Seattle { country: 'United States' }
Vancouver { country: 'Canada' }

Query: source=input | rename location as renamed_location

Expected Results:

name renamed_location
Seattle { country: 'United States' }
Vancouver { country: 'Canada' }

Actual Results:

name country renamed_location
Seattle null { country: 'United States' }
Vancouver null { country: 'Canada' }

How can one reproduce the bug?

See comment below for sample mapping, input data, query, and results.

What is the expected behaviour?

See above. Struct field should be renamed, not additional columns should be created.

What is your host/environment?

Not applicable.

Do you have any screenshots?

Not applicable. See example above and sample mapping, input data, query, and results in comment below.

Do you have any additional context?

Discovered during work on #3030.

Activity

  1. added
    bug
    on Jan 30, 2025
  2. currantw commented on Jan 30, 2025

    @currantw
    ContributorAuthor

    EXAMPLE

    Mapping:

    {
      "mappings": {
        "properties": {
          "name": {
            "type": "keyword"
          },
          "location": {
            "type": "object",
            "properties": {
              "state": {
                "type": "keyword"
              },
              "province": {
                "type": "keyword"
              },
              "country": {
                "type": "keyword"
              },
              "coordinates": {
                "type": "object",
                "properties": {
                  "latitude": {
                    "type": "double"
                  },
                  "longitude": {
                    "type": "double"
                  }
                }
              }
            }
          }
        }
      }
    }

    Data (Bulk):

    {"index":{"_id":"1"}}
    {"name": "Seattle", "location": { "state": "Washington", "country": "United States", "coordinates": {"latitude": 47.6061, "longitude": -122.3328}}}
    {"index":{"_id":"2"}}
    {"name": "Vancouver", "location": { "province": "British Columbia", "country": "Canada", "coordinates": {"latitude": 49.2827, "longitude": -123.1207}}}

    Query:

    source=cities | rename location AS renamed_location
    

    Response:

    {
        "schema": [
            {
                "name": "name",
                "type": "string"
            },
            {
                "name": "location.coordinates",
                "type": "struct"
            },
            {
                "name": "location.country",
                "type": "string"
            },
            {
                "name": "location.province",
                "type": "string"
            },
            {
                "name": "location.state",
                "type": "string"
            },
            {
                "name": "renamed_location",
                "type": "struct"
            }
        ],
        "datarows": [
            [
                "Seattle",
                null,
                null,
                null,
                null,
                {
                    "state": "Washington",
                    "country": "United States",
                    "coordinates": {
                        "latitude": 47.6061,
                        "longitude": -122.3328
                    }
                }
            ],
            [
                "Vancouver",
                null,
                null,
                null,
                null,
                {
                    "province": "British Columbia",
                    "country": "Canada",
                    "coordinates": {
                        "latitude": 49.2827,
                        "longitude": -123.1207
                    }
                }
            ]
        ],
        "total": 2,
        "size": 2
  3. changed the title [-][BUG] Command `rename` does not work with`struct` field[/-] [+][BUG] Command `rename` does not work with `struct` field[/+] on Jan 30, 2025
  4. changed the title [-][BUG] Command `rename` does not work with `struct` field[/-] [+][BUG] `rename` does not work with `struct` field[/+] on Feb 5, 2025
  5. added
    PPL
    on May 29, 2025
  6. moved this from Not Started to No status in PPL Trackeron Jun 27, 2025
  7. moved this to Not Started in PPL Trackeron Jul 8, 2025
  8. songkant-aws commented on Apr 16, 2026

    @songkant-aws
    Collaborator

    This is no longer issue in latest Calcite engine enabled PPL query. PPL flatten nested fields per original design because of some historical decisions. We don't know the struct internal field schema. With workaround solutions, accessing struct fields are resolved by this PR: #4719.

  9. moved this from Not Started to Done in PPL Trackeron Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

PPLbug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions