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

CAST( 'yes' AS BOOLEAN) fails #11925

Open
2 tasks done
manticore-projects opened this issue May 4, 2024 · 3 comments
Open
2 tasks done

CAST( 'yes' AS BOOLEAN) fails #11925

manticore-projects opened this issue May 4, 2024 · 3 comments

Comments

@manticore-projects
Copy link

What happens?

CAST( 'yes' AS BOOLEAN) fails, when all other RDBMS support it.
Same for no of course.

To Reproduce

-- Conversion Error: Could not convert string 'yes' to BOOL
SELECT Cast('yes' AS BOOLEAN);

OS:

Linux

DuckDB Version:

0.10.2

DuckDB Client:

Java

Full Name:

Andreas Reichel

Affiliation:

manticore-projects.com

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have
@soerenwolfers
Copy link

soerenwolfers commented May 4, 2024

Python casts "yes" and "no" both to True. The RDBMS you mention cast one to True and one to False, I assume. Best to not pick a side, IMO. I prefer there being no cast at all and requiring the user to write down themselves (using case statements) how to convert strings to Booleans. For example, you might be interested in yes/no parsing, the next person might be interested in True/False parsing, the next person in Y/N, the next person in non-empty vs empty string, the next person in string vs null, the next person in Ja/Nein.

@hannes
Copy link
Member

hannes commented May 6, 2024

SQLite casts to false (0)

@manticore-projects
Copy link
Author

SQLite casts to false (0)

I can't argue about that because it really depends what DuckDB is aiming for. My recommendation was to aim for H2 or HyperSQL at least and most time you refer to Postgres yourself. (SQLLite and MySQL are less appealing to me.)

We can close this issue immediately. I just write down things I notice while going through all DuckDB functions systematically. Your call please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants