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

Safe divide #56

Closed
tiboun opened this issue Dec 3, 2024 · 0 comments
Closed

Safe divide #56

tiboun opened this issue Dec 3, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@tiboun
Copy link
Contributor

tiboun commented Dec 3, 2024

Safe divide currently doesn't return the correct answer.

Given:

SELECT SAFE_DIVIDE(5, 4) a;

it gets translated to :

SELECT /* Approximation: SAFE variant not supported */ DIVIDE(5, 4) a

But divide in duckdb is an alias for // which is getting the integer part and not the precision part.

I think, this should be translated to:

SELECT if(4 != 0, 5/4, NULL) as a
@manticore-projects manticore-projects self-assigned this Dec 7, 2024
@manticore-projects manticore-projects added the bug Something isn't working label Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants