Skip to content

ESQL: "expr::text" cast returning a keyword #111537

@ivancea

Description

@ivancea

The <x>::text inline cast depends on ToString to make the cast, which always returns keyword.
It could make sense in ToString, but a <x>::text cast is expected to return a text.

Reproduce with:

Query:

ROW txt="abc"::text

Result:

{
  "columns": [
    {
      "name": "txt",
      "type": "keyword"
    }
  ],
  "values": [
    [
      "txt"
    ]
  ]
}

Note that the column type is "keyword".

Another example

Index test with mapping:

{
  "text_field": {
    "type": "text"
  }
}

Query:

FROM test
| eval x = CASE(true, text_field, "txt"::text)

Result:

{
  "error": {
    "root_cause": [
      {
        "type": "verification_exception",
        "reason": "Found 1 problem line 4:12: third argument of [CASE(true, text_field, \"txt\"::text)] must be [text], found value [\"txt\"::text] type [keyword]"
      }
    ],
    "type": "verification_exception",
    "reason": "Found 1 problem line 4:12: third argument of [CASE(true, text_field, \"txt\"::text)] must be [text], found value [\"txt\"::text] type [keyword]"
  },
  "status": 400
}

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions