Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] specifying fetch_size in REST API causes issue with aliases #2579

Open
pcoccoli opened this issue Mar 20, 2024 · 1 comment
Open

[BUG] specifying fetch_size in REST API causes issue with aliases #2579

pcoccoli opened this issue Mar 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@pcoccoli
Copy link

What is the bug?
If I select the same column twice, with 2 different aliases, and specify fetch_size, then first alias is ignored. It works fine if I don't include fetch_size.

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

POST /_plugins/_sql
{
    "query": "SELECT `process.executable` AS `colA`, `process.executable` AS `colB` FROM my_index LIMIT 3",
    "fetch_size": 1000
}

What is the expected behavior?
fetch_size should not effect SQL interpretation.

What is your host/environment?

  • OS: Unsure
  • Version: 2.12.0
  • Plugins: sql

Do you have any screenshots?
With fetch_size:

curl -u "password:password" https://example.com:9200/_plugins/_sql/ -X POST -d '{"query": "SELECT `process.executable` AS `colA`, `process.executable` AS `colB` FROM my_index LIMIT 1", "fetch_size": 10}' -H "Content-Type: application/json"
{
  "schema": [
    {
      "name": "process.executable",
      "alias": "colB",
      "type": "keyword"
    },
    {
      "name": "process.executable",
      "alias": "colB",
      "type": "keyword"
    }
  ],
  "total": 10000,
    "datarows": [[
    "C:\\Windows\\explorer.exe",
    "C:\\Windows\\explorer.exe"
  ]],
  "size": 1,
  "status": 200
}

Notice in the schema of the response, both columns have alias "colB"

Without fetch_size:

curl -u "username:password" https://example.com:9200/_plugins/_sql/ -X POST -d '{"query": "SELECT `process.executable` AS `colA`, `process.executable` AS `colB` FROM my_index LIMIT 1"}' -H "Content-Type: application/json"
{
  "schema": [
    {
      "name": "process.executable",
      "alias": "colA",
      "type": "keyword"
    },
    {
      "name": "process.executable",
      "alias": "colB",
      "type": "keyword"
    }
  ],
  "datarows": [
    [
      "C:\\Windows\\explorer.exe",
      "C:\\Windows\\explorer.exe"
    ]
  ],
  "total": 1,
  "size": 1,
  "status": 200
}

Here the alias fields in the result schema match the query.

Do you have any additional context?
The value of fetch_size doesn't seem to matter; its presence triggers the problem.

@pcoccoli pcoccoli added bug Something isn't working untriaged labels Mar 20, 2024
@penghuo penghuo removed the untriaged label Mar 27, 2024
@penghuo
Copy link
Collaborator

penghuo commented Mar 27, 2024

it is bug in legacy engine(v1)
add fetch_size, query execution fallback to legacy engine (v1),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants