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

accurateCastOrNull raises an exception, rather than simply returning null when casting an invalid value to Bool #38585

Closed
rsdouglas opened this issue Jun 29, 2022 · 1 comment · Fixed by #54136 or #54629
Labels
bug Confirmed user-visible misbehaviour in official release

Comments

@rsdouglas
Copy link

Describe what's wrong

accurateCastOrNull raises an exception, rather than simply returning null when casting an invalid value to Bool

Code: 467. DB::Exception: Received from 127.0.0.1:9000. DB::Exception: Cannot parse boolean value here: 'test', should be 'true' or 'false' controlled by setting bool_true_representation and bool_false_representation or one of True/False/T/F/Y/N/Yes/No/On/Off/Enable/Disable/Enabled/Disabled/1/0: While processing accurateCastOrNull('test', 'Bool'). (CANNOT_PARSE_BOOL)

Does it reproduce on recent release?

ClickHouse server version 22.7.1.906 (official build).

How to reproduce

select accurateCastOrNull('test', 'Bool')

Expected behavior

I expect it to behave the same as an invalid cast to something like UInt8

SELECT accurateCastOrNull('test', 'UInt8')

Query id: e7d0473b-6ae0-455d-9eae-fb3827e7c671

┌─accurateCastOrNull('test', 'UInt8')─┐
│                                ᴺᵁᴸᴸ │
└─────────────────────────────────────┘
@rsdouglas rsdouglas added the potential bug To be reviewed by developers and confirmed/rejected. label Jun 29, 2022
@falcoagustin
Copy link

falcoagustin commented Aug 1, 2023

@alexey-milovidov @antonio2368
I'm also experiencing this, and it's pretty easy to reproduce as well.
The work around that I found - which is suitable for our use case, doesn't mean it works for every case - is to use reinterpret which will return true if there's a value:

a60baef7f266 :) select reinterpret('', 'Boolean')

SELECT reinterpret('', 'Boolean')

Query id: b5324ddf-9854-4f16-bdac-c3f95348cb5e

┌─reinterpret('', 'Boolean')─┐
│ false                      │
└────────────────────────────┘

1 row in set. Elapsed: 0.005 sec.

a60baef7f266 :) select reinterpret('test', 'Boolean')

SELECT reinterpret('test', 'Boolean')

Query id: 4006fc47-d025-4931-a90c-fccd03f87bac

┌─reinterpret('test', 'Boolean')─┐
│ true                           │
└────────────────────────────────┘

1 row in set. Elapsed: 0.004 sec.

Can we get some 👀 ?
Thanks in advanced!

@rschu1ze rschu1ze reopened this Sep 15, 2023
@rschu1ze rschu1ze added bug Confirmed user-visible misbehaviour in official release and removed potential bug To be reviewed by developers and confirmed/rejected. labels Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed user-visible misbehaviour in official release
Projects
None yet
3 participants