Skip to content

fix(json): remove artificial arg limit on JSONArray [CLAUDE]#7559

Open
maxa-jonathan-hallee wants to merge 1 commit intotobymao:mainfrom
maxa-jonathan-hallee:jhallee/fix/json-array-varargs
Open

fix(json): remove artificial arg limit on JSONArray [CLAUDE]#7559
maxa-jonathan-hallee wants to merge 1 commit intotobymao:mainfrom
maxa-jonathan-hallee:jhallee/fix/json-array-varargs

Conversation

@maxa-jonathan-hallee
Copy link
Copy Markdown
Contributor

@maxa-jonathan-hallee maxa-jonathan-hallee commented Apr 24, 2026

Summary

  • JSONArray enforced a 4-argument maximum because is_var_len_args was False and arg_types had only 4 keys
  • DuckDB's JSON_ARRAY is variadic and accepts any number of arguments (docs), so queries like JSON_ARRAY('a', 'b', 'c', 'd', 'e') failed at parse time
  • Setting is_var_len_args = True skips the arg count validation while preserving existing parsing behavior across all dialects

To the best of my understanding this isn't really a problem for other dialect parsers

Test plan

  • Added validate_all test with 5 args covering DuckDB round-trip and Snowflake transpilation
  • Verified existing JSON_ARRAY tests (0, 1, 3 args) still pass
  • Verified against real DuckDB CLI with 5 and 10 args
  • Full unit test suite passes (1042 tests)
  • Linting, formatting, and type checks pass

JSONArray enforced a 4-argument maximum because is_var_len_args was
False and arg_types had only 4 keys. DuckDB's JSON_ARRAY is variadic
and accepts any number of arguments, so queries like
JSON_ARRAY('a', 'b', 'c', 'd', 'e') failed at parse time.

Setting is_var_len_args = True skips the arg count validation while
preserving existing parsing behavior across all dialects.

Ref: https://duckdb.org/docs/current/data/json/creating_json
Copy link
Copy Markdown
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @maxa-jonathan-hallee, thanks for the PR. This is almost there, but needs one change: DuckDB needs to override the instantiation of JSON_ARRAY in the parser so that args don't spill over to strict. You can see this is what happens now if you parse a function call with more than 4 arguments. Instead, you need to make sure args are set to expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants