Skip to content

feat: support Spark-compatible json_tuple function#20412

Open
CuteChuanChuan wants to merge 1 commit intoapache:mainfrom
CuteChuanChuan:raymond/spark-func-json-tuple
Open

feat: support Spark-compatible json_tuple function#20412
CuteChuanChuan wants to merge 1 commit intoapache:mainfrom
CuteChuanChuan:raymond/spark-func-json-tuple

Conversation

@CuteChuanChuan
Copy link
Contributor

@CuteChuanChuan CuteChuanChuan commented Feb 17, 2026

Which issue does this PR close?

Rationale for this change

What changes are included in this PR?

  • Add Spark-compatible json_tuple function in datafusion-spark crate
  • Function signature: json_tuple(json_string, key1, key2, ...) -> Struct<c0: Utf8, c1: Utf8, ...>
    • json_string: The JSON string to extract fields from
    • key1, key2, ...: Top-level field names to extract
    • Returns a Struct because DataFusion ScalarUDFs return one value per row; caller (Comet) destructures the fields

Examples

SELECT json_tuple('{"f1":"value1","f2":"value2","f3":3}', 'f1', 'f2', 'f3');
-- {c0: value1, c1: value2, c2: 3}

SELECT json_tuple('{"f1":"value1"}', 'f1', 'f2');
-- {c0: value1, c1: NULL}

SELECT json_tuple(NULL, 'f1');
-- NULL

Are these changes tested?

  • Unit tests: return_field_from_args shape validation and too-few-args error
  • sqllogictest: test_files/spark/json/json_tuple.slt, test cases derived from Spark JsonExpressionsSuite

Are there any user-facing changes?

Yes.

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) spark labels Feb 17, 2026
@CuteChuanChuan CuteChuanChuan changed the title feat(spark): support Spark-compatible json_tuple function feat: support Spark-compatible json_tuple function Feb 17, 2026
@CuteChuanChuan CuteChuanChuan force-pushed the raymond/spark-func-json-tuple branch from 8babbe9 to e0cf25c Compare February 17, 2026 10:03
@CuteChuanChuan CuteChuanChuan force-pushed the raymond/spark-func-json-tuple branch from e0cf25c to 6d6c2a0 Compare February 17, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spark sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant