Open alex-spies opened 1 year ago
Pinging @elastic/es-ql (Team:QL)
For some background: DateTimeArithmeticOperator::fold
uses the default fold
implementation which applies an evaluator like during normal expression evaluation outside of folding. Normal evaluation, however, catches arithmetic exceptions and turns them into warnings (which IMO is correct as we wouldn't want to stop execution with an error just because there was e.g. one overflow).
IMO it's preferable to consistently send back a 400 REST response in such cases instead of warnings.
It is. This noted issue happens because we don't fold as much as we could when optimising and leave the rest to be executed (#99502).
IMO it's preferable to consistently send back a 400 REST response in such cases instead of warnings.
It is. This noted issue happens because we don't fold as much as we could when optimising and leave the rest to be executed (#99502).
I think arithmetic expressions are actually folded before execution just fine (should be done in the constant folding optimization rule) - but using the standard evaluators, which record warnings + return null. So it looks like it was just not folded.
Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL)
Pinging @elastic/es-analytics-geo (Team:Analytics)
Pinging @elastic/es-analytical-engine (Team:Analytics)
Description
When folding constants before a query is properly evaluated, date math arithmetic exceptions result in an error message in the REST response whereas other arithmetic exceptions only result in warnings.
We should treat errors during constant folding consistently.
For instance:
results in a REST response containing
and status code 400.
But for
one obtains
and a warning header:
In particular, the first query never hits the compute service, but the second does - always evaluating the expression to null.
Since exceptions during constant folding mean that the whole query will be essentially pointless (the offending expression will always return null and waste potentially a lot of compute time), IMO it's preferable to consistently send back a 400 REST response in such cases instead of warnings.