Description
What is the bug?
I found there are mismatches between declared and actual accepting argument types in datetime functions.
The documentation of datetime functions: https://github.com/opensearch-project/sql/blob/main/docs/user/ppl/functions/datetime.rst
Accepting TIME, but not declared to do so
- DAY
- DAY_OF_WEEK
- DAYOFWEEK
- DAY_OF_YEAR
- DAYOFYEAR
- DAYNAME
- DAYOFMONTH
- DAY_OF_MONTH
- MONTHNAME
- QUARTER
- TO_DAYS
- YEAR
- DATE
- MONTH
- MONTH_OF_YEAR
- LAST_DAY
- WEEK_DAY
- DAYOFWEEK
- UNIX_TIMESTAMP
NOT Accepting TIMESTAMP, but declared to do so:
How can one reproduce the bug?
Steps to reproduce the behavior:
-
Send a PPL request to local cluster
curl --location 'http://localhost:9200/_plugins/_ppl' \ --header 'Content-Type: application/json' \ --data '{ "query" : "source=[ANY_INDEX]| head 1 | eval d = unix_timestamp(time('\''12:00:00'\'')) | fields d" } '
-
It returns a value, assuming that the date is today. However, TIME is not supported as an argument for
unix_timestamp
. This behavior is undocumented.{ "schema": [ { "name": "d", "type": "double" } ], "datarows": [ [ 1.7434224E9 ] ], "total": 1, "size": 1 }
Moreover, when I pass a time from the index, it reports an error, but with unexpected error message:
-
Send a ppl query:
source=dates | head 1 | eval d = unix_timestamp(time) | fields d
, wheretime
is of type TIME. -
It reports an error like below:
{ "error": { "reason": "Invalid Query", "details": "invalid to get doubleValue from value of type TIME", "type": "ExpressionEvaluationException" }, "status": 400 }
What is the expected behavior?
To report an error on the incompatible argument, resembling the following:
{
"error": {
"reason": "Invalid Query",
"details": "unix_timestamp function expected {[], [DOUBLE],[DATE],[TIMESTAMP]}, but get [TIME]",
"type": "ExpressionEvaluationException"
},
"status": 400
}
What is your host/environment?
- OS: MacOS
- Version: 2.19.1
- Plugins: opensearch-sql 2.19.1.0 & opensearch-job-scheduler 2.19.1.0
Metadata
Metadata
Assignees
Type
Projects
Status