…streamstats
Window functions outside WINDOW_FUNC_MAPPING (e.g. rank, dense_rank,
nth_value) throw a generic "Unexpected window function: X" from
CalciteRexNodeVisitor#visitWindowFunction. These functions require
ORDER BY semantics that eventstats/streamstats don't have (they only
support partition-by), so they are intentionally unsupported, not a
bug -- but the error message gave users no indication of what to use
instead.
Replace the message with one that names the function and lists the
functions eventstats/streamstats do support, so users get actionable
guidance instead of a bare "unexpected" error.
Fixes opensearch-project#5168
Signed-off-by: Radhakrishnan Pachyappan <gingeekrishna@gmail.com>
Description
Fixes #5168
eventstats/streamstatsreject window functions outsideWINDOW_FUNC_MAPPING(e.g.rank(),dense_rank(),nth_value()) with a bare"Unexpected window function: X"error.As confirmed in the issue discussion by @songkant-aws, this is expected behavior, not a bug —
rank/dense_rank/nth_valuerequireORDER BYsemantics, buteventstats/streamstatsonly supportpartition by. The issue was relabelederror-experience: the fix is to make the error message clearer, not to add support for these functions.Changes
CalciteRexNodeVisitor#visitWindowFunction: replaced the generic"Unexpected window function: X"message with one that names the rejected function and lists the functionseventstats/streamstatsdo support (sourced fromWINDOW_FUNC_MAPPING), so users get actionable guidance instead of a bare error.UnifiedQueryPlannerTest) and integration tests (CalcitePPLEventstatsIT,CalciteStreamstatsCommandIT) to assert against the new message.rank/dense_rankspecifically, since the issue's repro queries used those functions.Note: this PR builds on top of #5587 (already merged), which fixed the same throw site to return a 4xx instead of a 500. This PR only changes the message text, not the exception type or HTTP status.
Test plan
UnifiedQueryPlannerTest#unsupportedWindowFunctionIsRethrownAsSemanticCheckExceptionpasseseventstatsandstreamstats(require a live cluster to run in CI)