Add support for standard SQL ARRAY syntax in multi-field relevance
functions (multi_match, simple_query_string, query_string). The
NamedArgRewriter expands ARRAY['f1','f2'] into a MAP with VARCHAR-typed
field names and default weight 1.0, producing plans compatible with
the Analytics engine pushdown rules.
Syntax: multi_match(ARRAY['name', 'department'], 'John')
The key technique is wrapping each field literal in CAST(... AS VARCHAR)
at the SqlNode level so Calcite's validator produces bare RexLiterals
without type-widening CASTs in the final plan.
Signed-off-by: Chen Dai <daichen@amazon.com>
Description
This PR adds support for standard SQL
ARRAY[]syntax in multi-field relevance functions (multi_match,simple_query_string,query_string) for the unified SQL engine. TheNamedArgRewriteris extended to detect theARRAY[]argument and expands it into aMAPconstructor with VARCHAR-typed field names, producing plans consistent with the PPL path and compatible with the Analytics Engine's pushdown pattern matching in opensearch-project/OpenSearch#21562.Example:
Note: This uses
ARRAY['field1', 'field2']rather than V2's bracket syntax['field1', 'field2'], as Calcite's SQL parser does not support it and requires complex changes in the.ftlparser template. A follow-up PR will document all such syntax differences between V2 and unified SQL engine.Related Issues
Part of #5248
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.