Skip to content

[BUG] eval overwrites MAP root field when assigning multiple dotted-path names #5185

Closed

Description

@dai-chen

What is the bug?

When using eval to materialize multiple dotted paths from the same MAP column in a single command (e.g., eval doc.user.name=doc.user.name, doc.user.age=doc.user.age), the second assignment fails with Field [doc.user.age] not found. The first assignment succeeds, but it removes the MAP root column doc from the schema, making subsequent paths unresolvable.

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Create a test index with a JSON string field:
curl -s -X PUT 'localhost:9200/t/_doc/1?refresh=true' -H 'Content-Type: application/json' \
  -d '{"doc": "{\"user\":{\"name\":\"John\",\"age\":30}}"}'
curl -s -X PUT 'localhost:9200/t/_doc/2?refresh=true' -H 'Content-Type: application/json' \
  -d '{"doc": "{\"user\":{\"name\":\"Alice\",\"age\":25}}"}'
  1. Enable Calcite and run:
source=t | spath input=doc | eval doc.user.name=doc.user.name, doc.user.age=doc.user.age`
Error: Field [doc.user.age] not found
  1. Note: splitting into two separate eval commands also fails for the same reason:
source=t | spath input=doc | eval doc.user.name=doc.user.name | eval doc.user.age=doc.user.age

What is the expected behavior?

Both dotted-path assignments should succeed. The MAP root column doc should not be removed when a dotted-path column like doc.user.name is added — the dotted name is a new flat column, not a nested sub-field of doc.

What is your host/environment?

  • Version: PPL Calcite V3
  • Plugins: 3.6

Do you have any screenshots?
N/A

Do you have any additional context?

  • Single dotted-path eval works: eval doc.user.name=doc.user.name succeeds.
  • The workaround is to use non-dotted aliases: eval username=doc.user.name, age=doc.user.age.
  • The shouldOverrideField heuristic was designed for OpenSearch nested/struct fields where resource.attributes.key is a real sub-field of resource. For MAP columns produced by spath, the dotted name is just a flat column name that happens to contain dots — it's not a nested sub-field.
  • The root cause is in projectPlusOverriding → shouldOverrideField, which checks newName.startsWith(originalName + "."). When eval creates a column named doc.user.name, the check "doc.user.name".startsWith("doc.") returns true, so projectPlusOverriding removes the original doc MAP column. The second eval expression doc.user.age=doc.user.age then fails because doc no longer exists in the schema.
// shouldOverrideField (CalciteRelNodeVisitor.java)
private boolean shouldOverrideField(String originalName, List<String> newNames) {
    return newNames.stream()
        .anyMatch(newName ->
            newName.equals(originalName)
            || newName.startsWith(originalName + "."));  // ← incorrectly matches MAP root
}

Activity

  1. added
    bug
    on Feb 26, 2026
  2. changed the title [-][BUG] eval overwrites MAP root field when assigning multiple dotted-path names[/-] [+][BUG] `eval` overwrites MAP root field when assigning multiple dotted-path names[/+] on Feb 26, 2026
  3. added
    PPL
    on Feb 26, 2026
  4. added a commit that references this issue on Feb 26, 2026
    bee6e56
  5. moved this from Not Started to Done in PPL Trackeron Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    PPLbug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions