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

Allow to convert float stored in string field to integer in JSONExtract #45432

Merged
merged 2 commits into from
Jan 20, 2023

Conversation

CurtizJ
Copy link
Member

@CurtizJ CurtizJ commented Jan 19, 2023

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Allow to implicitly convert floats stored in string fields of JSON to integers in JSONExtract functions. E.g. JSONExtract('{"a": "1000.111"}', 'a', 'UInt64') -> 1000, previously it returned 0.

@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-improvement Pull request with some product improvements label Jan 19, 2023
@CurtizJ
Copy link
Member Author

CurtizJ commented Jan 19, 2023

Previously there was an inconsistency:

SELECT JSONExtract('{"a": "1000"}', 'a', 'UInt64')

┌─JSONExtract('{"a": "1000"}', 'a', 'UInt64')─┐
│                                        1000 │
└─────────────────────────────────────────────┘

SELECT JSONExtract('{"a": "1000.111"}', 'a', 'UInt64');

┌─JSONExtract('{"a": "1000.111"}', 'a', 'UInt64')─┐
│                                               0 │
└─────────────────────────────────────────────────┘

SELECT JSONExtract('{"a": 1000.111}', 'a', 'UInt64');

┌─JSONExtract('{"a": 1000.111}', 'a', 'UInt64')─┐
│                                          1000 │
└───────────────────────────────────────────────┘

@kitaisreal kitaisreal self-assigned this Jan 19, 2023
@CurtizJ CurtizJ merged commit 9c0ba7c into ClickHouse:master Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-improvement Pull request with some product improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants