[INLONG-12189][SDK] Support Map and JsonObject key access via [...] in ArrayParser - #12190
Open
luchunliang wants to merge 2 commits into
Open
[INLONG-12189][SDK] Support Map and JsonObject key access via [...] in ArrayParser#12190luchunliang wants to merge 2 commits into
luchunliang wants to merge 2 commits into
Conversation
luchunliang
requested review from
aloyszhang,
baomingyu,
doleyzi,
fuweng11 and
vernedeng
August 21, 2026 03:36
aloyszhang
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12189
Motivation
KV map lookup after
STR_TO_MAP— decode a URL-encoded query string and pluck a specific parameter in one line:JSON key access — read fields off a raw
JsonObjectproduced by JSON helper functions using the intuitiveobj['field']syntax, without additional casting.Consistency — align bracket-access semantics with common SQL / JSONPath expectations, reduce boilerplate, and remove edge cases where a valid-looking expression silently returned
null.Modifications
ArrayParser#parsenow handles four shapes; the two new branches (Map, JsonObject) are highlighted:Where
unwrapJsonElement:nullforJsonNull;JsonPrimitive(String/Boolean/Number, fallback totoString());JsonArray/JsonObjectfor structural elements, so chained bracket access keeps working.Behavior matrix
leftValuetyperightValuetypeList<?>Numberlist.get(index.intValue())Map<?, ?>map.get(rightValue)(new)JsonArrayNumberJsonObjectStringnullExample
Before this change, the following expression silently returned
nulland theWHEREclause could never match:After this change the map lookup works as intended, so both projection and filter behave correctly.
Tests
TestCsv2RowDataProcessor(peer ofTestCsv2KvProcessor) which drives the CSV → RowData pipeline with a SQL that usesSTR_TO_MAP(URL_DECODE(event_value), '&', '=')['HY50']in bothSELECTandWHERE, exercising the newMapbranch end-to-end.List/JsonArraybracket-access tests continue to pass unchanged.Backward compatibility
List[Number],JsonArray[Number]) keep identical semantics.null, so previously-null expressions can only turn into a real value — never into an unexpected error.Risks / Notes
Map<?, ?>usesmap.get(rightValue)directly; when the SQL parser resolves the bracket key as aStringwhile the map key is a boxed number (or vice versa), the lookup will returnnulldue to.equalstype mismatch. This matches JavaMapsemantics and is consistent with how other Transform SDK operators treat mixed key types.JsonObject, missing keys resolve tonull(Gson returnsnullfromget); no exception is thrown.JsonPrimitiveunwrapping intentionally mirrors whatJsonSourceDataalready does elsewhere, so downstream comparison/arithmetic operators receive the same Java type regardless of whether the value originated from the source or from a JSON helper function.Files changed
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/parser/ArrayParser.javainlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/processor/TestCsv2RowDataProcessor.java(new; end-to-end coverage forMap[key])Checklist
List[Number]/JsonArray[Number]usageJsonSourceDataVerifying this change
(Please pick either of the following options)
This change is a trivial rework/code cleanup without any test coverage.
This change is already covered by existing tests, such as:
(please describe tests)
This change added tests and can be verified as follows:
(example:)
Documentation