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

Idea: Catch divide-by-zero hazards #5952

Open
3 tasks done
irvingpop opened this issue Jun 6, 2024 · 1 comment
Open
3 tasks done

Idea: Catch divide-by-zero hazards #5952

irvingpop opened this issue Jun 6, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@irvingpop
Copy link

Search before asking

  • I searched the issues and found no similar issues.

Description

It would be super cool if SQLfluff caught things like this:

select 
  (important_number / totally_never_gonna_be_zero) as important_fact

and then told you not to (at a minimum), and/or redirected you to use dialect-appropriate divide-by-zero protections.

Use case

If SQLfluff flagged potentially unsafe division, then it might save a small number of growing SQL authors from footgunning themselves and breaking their data pipelines.

Dialect

Every dialect lets you divide using /

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

@irvingpop irvingpop added the enhancement New feature or request label Jun 6, 2024
@greg-finley
Copy link
Contributor

While I mostly agree, I’d also throw the opposite argument your way: isn’t it better to loudly break your data pipeline instead of silently masking a potential bug that could lead to misleading results? I’m hesitant to implement a rule that is maybe worse in some situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants