Skip to content

SQL: Text formatter fails on empty result pages #83371

@Luegg

Description

@Luegg

Elasticsearch Version

8.1.0-SNAPSHOT (but also affects 7.x releases)

Installed Plugins

No response

Java Version

bundled

OS Version

Os X

Problem Description

SQL scroll requests with format=txt fail when fetching a subsequent empty page with

HTTP/1.1 500 Internal Server Error
X-elastic-product: Elasticsearch
content-type: application/json; charset=UTF-8
content-encoding: gzip
content-length: 148

{
  "error": {
    "root_cause": [
      {
        "type": "sql_illegal_argument_exception",
        "reason": "Cannot find text formatter - this is likely a bug"
      }
    ],
    "type": "sql_illegal_argument_exception",
    "reason": "Cannot find text formatter - this is likely a bug"
  },
  "status": 500
}

Note, this only happens for scroll requests. If the first page is already empty (filter matches no records) an empty table is returned as expected.

Steps to Reproduce

Given the test_emp dataset, issue the following requests:

POST http://localhost:9201/_sql?format=txt
Content-Type: application/json

{
    "fetch_size": 90,
    "query": "select * from test_emp order by 1"
}

Returns the first 90 records and cursor A.

POST http://localhost:9201/_sql?format=txt
Content-Type: application/json

{
    "cursor": <insert cursor A from previous response>
}

Returns the remaining 10 records and cursor B (see also #75528).

POST http://localhost:9201/_sql?format=txt
Content-Type: application/json

{
    "cursor": <insert cursor B from previous response>
}

Fails with the sql_illegal_argument_exception mentioned above.

Logs (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions