I’m just starting to experiment with the SQL plugin and quickly ran into a problem specifying a time range in my queries. I’m not sure how to format the date/time values in the WHERE clauses.
For example, this fails:
POST _opendistro/_sql?format=csv
{"query": "SELECT @timestamp, level, message, FROM kubernetes_cluster-galaxy-2020-04-27 WHERE logsource.keyword='cas' and @timestamp => "2020-04-28T21:36:56.335Z" LIMIT 100"
}
The error returned is:
{
"error": {
"reason": "Invalid SQL query",
"details": "Failed to parse request payload",
"type": "IllegalArgumentException"
},
"status": 400
}
How should I format the date time constant (i.e. “2020-04-28T21:36:56.335Z” )?
Also, the doc mentions there’s a date_format function but doesn’t provide any details. I seem to be able to extract the time part of @timestamp by using syntax like date_format(@timestamp,‘HH:mm:ss’), but if I use that in a WHERE condition, I can’t figure out what kind of constant value I can compare against. For example date_format(@timestamp,‘HH:mm:ss’) = “00:01:27” fails with the same error as above.
Is the SQL plugin leveraging some other open source SQL parser project which may have additional documentation? In addition to the specific questions above, I’m interested in understanding what other functions might be available.