Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support MySQL's JSON_TABLE #1019

Closed
lovasoa opened this issue Oct 21, 2023 · 0 comments · Fixed by #1062
Closed

support MySQL's JSON_TABLE #1019

lovasoa opened this issue Oct 21, 2023 · 0 comments · Fixed by #1062

Comments

@lovasoa
Copy link
Contributor

lovasoa commented Oct 21, 2023

MySQL has a JSON_TABLE table-valued function with the following syntax:

JSON_TABLE(
    expr,
    path COLUMNS (column_list)
)   [AS] alias

column_list:
    column[, column][, ...]

column:
    name FOR ORDINALITY
    |  name type PATH string path [on_empty] [on_error]
    |  name type EXISTS PATH string path
    |  NESTED [PATH] path COLUMNS (column_list)

on_empty:
    {NULL | DEFAULT json_string | ERROR} ON EMPTY

on_error:
    {NULL | DEFAULT json_string | ERROR} ON ERROR

Example

SELECT * FROM
 JSON_TABLE(
         '[{"a":"3"},{"a":2},{"b":1},{"a":0},{"a":[1,2]}]',
         "$[*]"
         COLUMNS(
           rowid FOR ORDINALITY,
           ac VARCHAR(100) PATH "$.a" DEFAULT '111' ON EMPTY DEFAULT '999' ON ERROR,
           aj JSON PATH "$.a" DEFAULT '{"x": 333}' ON EMPTY,
           bx INT EXISTS PATH "$.b"
         )
) AS tt;
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 a pull request may close this issue.

1 participant