Skip to content

Support json value constructors#12049

Merged
kasiafi merged 4 commits intotrinodb:masterfrom
kasiafi:327JsonValueConstructors
Jun 6, 2022
Merged

Support json value constructors#12049
kasiafi merged 4 commits intotrinodb:masterfrom
kasiafi:327JsonValueConstructors

Conversation

@kasiafi
Copy link
Copy Markdown
Member

@kasiafi kasiafi commented Apr 20, 2022

Support json_object() and json_array() functions, as specified by the SQL standard.

Documentation #12677

@cla-bot cla-bot bot added the cla-signed label Apr 20, 2022
@kasiafi kasiafi added the WIP label Apr 20, 2022
@github-actions github-actions bot added the docs label Apr 20, 2022
@kasiafi kasiafi force-pushed the 327JsonValueConstructors branch 3 times, most recently from 5f934bc to d2d1727 Compare April 25, 2022 13:23
@kasiafi kasiafi removed the WIP label Apr 25, 2022
Copy link
Copy Markdown
Member

@losipiuk losipiuk left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you use different values to test a more generic case?
You can then assert that resulting json has either of two values.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added a new assert method for the "ambiguous" case. It checks that the result is in a given set.

@kasiafi kasiafi force-pushed the 327JsonValueConstructors branch 3 times, most recently from ac0c62d to 3eb1fb1 Compare May 19, 2022 13:10
@kasiafi kasiafi force-pushed the 327JsonValueConstructors branch 2 times, most recently from 4b4793e to afc4410 Compare June 2, 2022 09:32
@kasiafi
Copy link
Copy Markdown
Member Author

kasiafi commented Jun 2, 2022

@losipiuk I addressed comments.
Additionally, I added support for more input types for json_array and json_object functions. Previously, it was required that a type has an implicit coercion to varchar. Now it is only required that a coercion exists. This change is in a separate commit, but I'll squash if you approve. PTAL

kasiafi added 3 commits June 6, 2022 10:43
Preparatory commit before `VALUE` is made a non-reserved keyword
For the purpose of supporting the JSON_OBJECT function.

This commit changes a colmn name from `value` to `v` in a test
which verifies error messages on parse exceptions.

If a query contains an identifier being a non-reserved token, and
later in te query text there's parse error, the error message points
to the correct location of the error, but it incorrectly returns the
non-reserved keyword as the erroneous token.
Support the json constructor functions as described in SQL standard.
This change includes full grammar and AST for json object constructor,
and full grammar and AST for json array constructor by enumeration.

Json array constructor by query is not yet supported. It should be
added after the JSON_ARRAYAGG function is supported.
@kasiafi kasiafi force-pushed the 327JsonValueConstructors branch from 16cf294 to f285c00 Compare June 6, 2022 08:54
@kasiafi kasiafi force-pushed the 327JsonValueConstructors branch from f285c00 to 2340165 Compare June 6, 2022 11:06
@kasiafi kasiafi merged commit 0ebe8c3 into trinodb:master Jun 6, 2022
@kasiafi kasiafi mentioned this pull request Jun 6, 2022
@github-actions github-actions bot added this to the 385 milestone Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants