Open paulstn opened 6 months ago
ip IS '21.8.113.52'
works because that it fallbacks to old SQL engine due to the IS
is an unknown syntax for new engine.
Adding ?format=json
will fallback to old SQL engine manually, so the query with ip = '21.8.113.52'
could work too.
POST _plugins/_sql?format=json
{
"query": "SELECT * FROM opensearch_dashboards_sample_data_logs WHERE ip = '21.8.113.52'"
}
Since IP
is not a ExprCoreType
, =
function couldn't resolve IP type in query analyzing in new engine. There would be two solutions to fix this problem.
DefaultFunctionResolver.resolve
, when NOT_MATCH
is triggered, if the function signature contains any non-core types, throw SyntaxCheckException
to fallback to old engine.OpenSearchDataType
to sql.core
module from sql.opensearch
module. Enhance current type casting expression.
What is the bug? When attempting to run a query that would select a field of type
ip
, the approach many people would take would be like the one below:The result returned would say that its invalid, with the explanation below:
As it turns out, the best way to actually select a field of type ip would be to use a relevance function, which wasn't made very clear by the error message above.
A better option would be to point users in some way to use a relevance function, if attempting to use the
=
operator for an unsupported field.Additionally, I was able to use the
IS
keyword successfully:but I couldn't find any docs about it. Is the
IS
keyword officially supported, and if so, could it be included in the docs somewhere?