-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
fix succeeds even though lint fails with PRS error #2345
Comments
Apart from when But there are instances where this is not the case (as you've noted in #2134) and where If using this as part of a pre-commit, I would recommend running Similarly, in this repo, our pre-commit runs |
@tunetheweb To me the analogy of black + flake8 doesn't really work. Those tools may have quite different purposes, especially depending on the flake8 configuration. I would rather like to see as analogous It is counterintuitive that the same tool (sqlfluff) exits with a successful status code after It also sounds a bit inefficient to run two commands instead of one? It seems better if the tool itself handles the final validation, in the best way it sees fit, instead of eg. parsing everything again etc. as required by an extra round of Is it worth creating a new issue about this in general: "fix succeeds even though lint fails"? Because this current issue kind of turned out to be treated as specific to PRS errors. A possible problem is that I'm not sure how to provide a test case that reproduces that situation since the PRS case was fixed, although based on what you wrote it sounds clear that it is still possible in some other situations. |
As I said in general I would expect it to be the case that I agree it is counter intuitive in the (hopefully small number now) of cases where this does not happen and it's usually due to incorrect fixes (e.g. #1304 where I see you've raised #2584 which is probably a good idea to concentrate on that particular (non-parsing problem) example. Ideally, we should correct this, but I'm not sure how easy that will be. So offered the suggestion to run |
Right, so the suggestion to run both fix & lint was offer more like as a temporary workaround. I have said it before, but maybe it's still worth repeating: Does it make sense that users have to run There is maybe one important aspect though: sql is complex, and that means that sqlfluff takes some time to execute. Maybe it is a good tradeoff that users are just running |
It was offered as the only way to guarantee what you seek to guarantee.
SQLFluff runs up to 10 iterations to attempt to settle. It has been suggested in #1386 that we should alert when hitting that limit and I would very much be in favour of that. In the example you've raised in #2584 upping the limit to 20 (and even 30) does not fix it in one run. So it's not a matter of "doing on more run", but the fact that, for some reason,
No it doesn't make sense, and I'd rather it didn't. As an open source project we're happy to accept a pull request over an issue to resolve this behaviour. What you seek is not unreasonable but unfortunately I don't have the answer you want. But if you know how to fix this to act like you would like it to, then we would be happy to accept that fix. I do see hope for implementing it, but cannot guarantee when (or even if) that will be.
I honestly think CI should lint, but not fix to catch this. Yes it would be more painful than not making it to CI but, as I have stated above, it's (hopefully!) rare enough and we haven't been able to identify and fix why this happens. Pre-commits and the like should fix (and potentially lint as well as a double check). Unless you are doing a massive commit, or you have very large SQL files, that should be quick. Ideally we could report when it's not settled but, as I have explained above, |
Note that there are issues SQLFluff can detect but not fix. |
True, another iteration in |
It does look like For example: SELECT a +
b
FROM foo Both
|
It could. Personally I think re-parsing between each fix iteration as suggest in #1304 (comment) would likely resolve most of the issues, but happy to do above too. But I had a quick look at doing that and couldn't get it working. |
This discussion seems to have become very philosophical -- is there a particular case we have in mind where SQLFluff should do something different? If so, can we create a new issue about that. If not, I propose we table the discussion, at least here. The issue is already closed. 🙂 |
Expected Behaviour
I assume fix is basically lint + fix (probably many do if they fix in a pre-commit, for example). If that assumption is reasonable, then
fix -f
should fail wheneverlint
would fail.Observed Behaviour
It's possible that
fix -f
succeeds when fix doesn't find anything to do, even though there are errors that would causelint
to fail.Steps to Reproduce
Edit: since #2438 the
INTEGER
is detected. Replace it with any non-existing pseudo type to reproduce this issue again.lint_placeholders.sql
:That is as expected, because
INTEGER
is not listed as a keyword in Hive dialect at the moment.That is unexpected. I was expecting this to also fail and complain about the PRS error.
Dialect
Hive, but this issue doesn't seem to be dialect specific per se.
Version
sqlfluff, version 0.9.1
Python 3.7.5
(not using dbt)
Configuration
.sqlfluff
:The text was updated successfully, but these errors were encountered: