chovy-3012 opened a new pull request, #12666: URL: https://github.com/apache/seatunnel/pull/12666
### Purpose of this pull request This PR adds a `GET_JSON_OBJECT(json, path)` SQL function to the Transform-V2 module, available in both the Zeta and Calcite SQL transforms. Resolves #11249, which asked for inline JSON extraction in the SQL transform so jobs that extract JSON inside `SELECT` / `CASE WHEN` / `WHERE` no longer need a separate `JsonPath` transform plus intermediate columns. The path grammar supports: - `$` — the root document - `.field` — object field access - `[n]` — array index (non-negative integer) - `['field']` / `["field"]` — bracket field access (for keys containing `.` or `[`) Wildcards (`[*]`, `.*`), recursive descent (`..`) and filter expressions (`[?(...)]`) are not supported. Return semantics: any null input, invalid JSON, a missing path, an out-of-bounds index, or a JSON `null` value → `null`; a string → the unquoted content; a number/boolean → the value as text; an object/array → the raw compact JSON text. The Calcite UDF delegates to the Zeta `JsonFunction` so both engines share one implementation. ### Does this PR introduce _any_ user-facing change? Yes — a new built-in SQL function `GET_JSON_OBJECT(json, path)` is available in the SQL transforms (Zeta and Calcite). This is purely additive: no existing function, config option, or default value is changed. Documentation (en + zh) is updated with the new function. ### How was this patch tested? Unit tests added under `seatunnel-transforms-v2`: - `SQLJsonFunctionsTest` (Zeta, end-to-end via `SQLTransform`): 19 tests — path extraction, return semantics, null/error handling, malformed paths, argument-count guard, case-insensitive name, and `CASE WHEN` usage. - `GetJsonObjectFunctionTest` (Calcite, direct `eval`): 25 tests — the same surface plus type-mismatch branches, negative index, consecutive array indexes, root-array and scalar-root access, and bracket-quoted keys containing `.` / `]`. Total: 44 tests, all passing. Verification run locally: - `./mvnw spotless:apply` + `./mvnw -pl seatunnel-transforms-v2 spotless:check` — clean - `./mvnw -pl seatunnel-transforms-v2 test -Dtest='SQLJsonFunctionsTest,GetJsonObjectFunctionTest'` — 44/44 pass The Calcite `@AutoService` SPI registration was also verified: `META-INF/services/org.apache.seatunnel.transform.calcite.udf.CalciteUdf` lists `GetJsonObjectFunction` alongside the existing UDFs. ### Check list * [ ] No new Jar binary package adding in this PR — n/a, no new dependency (reuses the existing shaded Jackson runtime). * [x] Documentation updated — `docs/en/transforms/sql-functions.md` and `docs/zh/transforms/sql-functions.md` now include a "JSON Functions" section. * [ ] `incompatible-changes.md` — not needed; purely additive change with no incompatible API/config impact. * [ ] Connector code — n/a, this is a Transform-V2 SQL function, not a connector (plugin-mapping / seatunnel-dist / labeler / e2e / plugin_config do not apply). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
