[BUG] specifying fetch_size in REST API causes issue with aliases
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.
it is bug in legacy engine(v1) add fetch_size, query execution fallback to legacy engine (v1),