Fix PPL foreach JSON array type coercion - #5637
Conversation
Signed-off-by: Songkan Tang <songkant@amazon.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
@penghuo As per merged PR disucssion: #5613 (comment), I've changed document phrase and coercion behavior from parsing unknown dynamic type directly from index storage. For now, I haven't find a good solution to immediately solve that. Additionally, none of the user’s example queries use |
Signed-off-by: Songkan Tang <songkant@amazon.com>
Description
This is a follow-up to #5613 for JSON arrays stored in text fields.
For field-backed JSON, element values are not visible while the query is being planned. Numeric use of
<<ITEM>>therefore selects a concrete numeric element type from the expression context, butForeachJsonArrayFunctionImplpreviously assumed every parsed value was already aNumber. A JSON string in that path caused aClassCastExceptionand an HTTP 500 response.This change:
nullwhen a value cannot be converted to the inferred concrete type instead of throwing;ARRAY<DOUBLE>andARRAY<VARCHAR>return types concrete rather than introducingANYor runtime-dependent operator coercion;foreachas experimental and removes product-comparison wording from plugin documentation and test comments.User impact
Field-backed JSON arrays used by numeric
foreachexpressions no longer fail the request when an element is not numeric. Valid numeric values and numeric strings continue to use numeric evaluation, while incompatible values producenull.Validation
The change also adds the affected
ForeachFieldJsonITcoverage to the no-pushdown integration suite.Related review: #5613 (comment)