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

mySql - JSON_VALUE and CHARACTER SET utf8mb4 results in parsing error #5832

Open
3 tasks done
kzajaczkowski opened this issue Apr 30, 2024 · 1 comment
Open
3 tasks done
Labels
bug Something isn't working mysql

Comments

@kzajaczkowski
Copy link

kzajaczkowski commented Apr 30, 2024

Search before asking

What Happened

Please have a look at the following code:

SELECT
    JSON_VALUE('{"a":"b"}', '$.a' RETURNING CHAR(255) CHARACTER SET utf8mb4) AS JSON_VALUE_CHARSET_EXAMPLE_UNPARSABLE,
    NULL AS JSON_VALUE_UNSIGNED_EXAMPLE_UNPARSABLE,
    NULL AS JSON_VALUE_SIGNED_EXAMPLE_PARSABLE
UNION ALL
SELECT
    NULL AS JSON_VALUE_CHARSET_EXAMPLE_UNPARSABLE,
    JSON_VALUE('{"a":"1"}', '$.a' RETURNING UNSIGNED) AS JSON_VALUE_EXAMPLE_UNPARSABLE,
    NULL AS JSON_VALUE_SIGNED_EXAMPLE_PARSABLE
UNION ALL
SELECT
    NULL AS JSON_VALUE_CHARSET_EXAMPLE_UNPARSABLE,
    NULL AS JSON_VALUE_EXAMPLE_UNPARSABLE,
    JSON_VALUE('{"a":"1"}', '$.a' RETURNING SIGNED) AS JSON_VALUE_SIGNED_EXAMPLE_PARSABLE

Expected Behaviour

There should be no PRS type linting errors as this is a valid mysql code.

Observed Behaviour

Both CHARACTER SET and UNSIGNED give "unparsable section" error.

=== [dbt templater] Sorting Nodes...
=== [dbt templater] Compiling dbt project...
=== [dbt templater] Project Compiled.
== [models/....sql] FAIL                                                                                                                                                                               
L:   2 | P:  55 |  PRS | Line 2, Position 55: Found unparsable section:
                       | 'CHARACTER SET utf8mb4'
L:   8 | P:  45 |  PRS | Line 8, Position 45: Found unparsable section:
                       | 'UNSIGNED'

How to reproduce

Lint the following code with dialect set to mysql:

SELECT
    JSON_VALUE('{"a":"b"}', '$.a' RETURNING CHAR(255) CHARACTER SET utf8mb4) AS JSON_VALUE_CHARSET_EXAMPLE_UNPARSABLE,
    NULL AS JSON_VALUE_UNSIGNED_EXAMPLE_UNPARSABLE,
    NULL AS JSON_VALUE_SIGNED_EXAMPLE_PARSABLE
UNION ALL
SELECT
    NULL AS JSON_VALUE_CHARSET_EXAMPLE_UNPARSABLE,
    JSON_VALUE('{"a":"1"}', '$.a' RETURNING UNSIGNED) AS JSON_VALUE_EXAMPLE_UNPARSABLE,
    NULL AS JSON_VALUE_SIGNED_EXAMPLE_PARSABLE
UNION ALL
SELECT
    NULL AS JSON_VALUE_CHARSET_EXAMPLE_UNPARSABLE,
    NULL AS JSON_VALUE_EXAMPLE_UNPARSABLE,
    JSON_VALUE('{"a":"1"}', '$.a' RETURNING SIGNED) AS JSON_VALUE_SIGNED_EXAMPLE_PARSABLE

Dialect

mysql

Version

image

image

image

Configuration

Custom configuration not needed for this to occur

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

@kzajaczkowski kzajaczkowski added the bug Something isn't working label Apr 30, 2024
@github-actions github-actions bot added the mysql label Apr 30, 2024
@kzajaczkowski
Copy link
Author

I am happy to submit a PR, but currently am struggling in identifying what needs to be fixed as I am not familiar with the project. So any help much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mysql
Projects
None yet
Development

No branches or pull requests

1 participant