This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Description
Field name with function is supposed to be exactly same as what it is in SELECT. We've already implemented for simple case. However, it is converted to lowercase if used in GROUP BY.
PUT date_test
{
"mappings": {
"properties": {
"birthday": {
"type": "date"
}
}
}
}
PUT date_test/_doc/1
{
"birthday": "2019-09-10T10:00:00Z"
}
# Query without GROUP BY returns field name as expected, "DATE_format".
POST _opendistro/_sql
{
"query": "SELECT DATE_format(birthday, 'yyyy-MM-dd', 'UTC') FROM date_test"
}
{
"schema": [{
"name": "DATE_format(birthday, 'yyyy-MM-dd', 'UTC')",
"type": "text"
}],
"total": 1,
"datarows": [["2019-09-10"]],
"size": 1,
"status": 200
}
# Field name is converted to lowercase "date_format" for aggregation
POST _opendistro/_sql
{
"query": """
SELECT DATE_format(birthday, 'yyyy-MM-dd', 'UTC')
FROM date_test
GROUP BY DATE_FORMAT(birthday, 'yyyy-MM-dd', 'UTC')
ORDER BY DATE_FORMAT(birthday, 'yyyy-MM-dd', 'UTC')
"""
}
{
"schema": [{
"name": "date_format(birthday)",
"type": "text"
}],
"total": 1,
"datarows": [["2019-09-10"]],
"size": 1,
"status": 200
}