Comments (14)
Are you using the DBT templater? If so try changing sqlfluff.experimental.format.executeInTerminal
to True
from vscode-sqlfluff.
Does the formatting/linting work after changing that setting?
If so I would recommend setting the "sqlfluff.suppressNotifications" to true.
Sometime the extension shows extra errors that really don't matter.
You can still see the errors in the output channel.
Also here are a the settings you need for dbt templater to work.
"sqlfluff.linter.run": "onSave",
"sqlfluff.experimental.format.executeInTerminal": true,
"editor.formatOnSave": false, // You can set this to just sql if you want.
from vscode-sqlfluff.
I configured all these params but still does not work...
from vscode-sqlfluff.
@slve Are you also using a dbt templater? I don't think the dbt templater allow for linting using stdin
. Can you try changing the setting "sqlfluff.linter.run"
to "onSave"
and let me know if that changes the output and what the new output is.
from vscode-sqlfluff.
@RobertOstermann yes, I am using dbt templater.
Thanks using onSave works fine!
from vscode-sqlfluff.
Yes, I'm using DBT templater. Here is my .sqlfluff config file contents:
`[sqlfluff]
dialect = snowflake
templater = dbt
exclude_rules = L001, L034
[sqlfluff:templater:dbt]
project_dir = ./
[sqlfluff:rules]
max_line_length = 999
tab_space_size = 4
indent_unit = space
[sqlfluff:rules:L010]
Keywords
capitalisation_policy = lower
[sqlfluff:rules:L030]
Function names
capitalisation_policy = lower
[sqlfluff:rules:L040]
Null & Boolean Literals
capitalisation_policy = lower
[sqlfluff:rules:L057]
Special Characters in Identifiers
allow_space_in_identifier = True
additional_allowed_characters = ['.','(',')','-']`
If I change the parameter you mention, then I get this error:
/usr/local/lib/python3.8/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 18 leaked semaphore objects to clean up at shutdown warnings.warn('resource_tracker: There appear to be %d '
from vscode-sqlfluff.
In the output channels there should be a SQLFluff channel. Can you go to that channel then run the format command. The output channel should show you the exact command that is being run. Copy that command and try running it in the terminal (might have to be git bash terminal, but I'm not sure on that). If the formatting from the extension messed up your file you should undo those changes first. Let me know what happens when you run that format command in the terminal, I want to make sure this is an issue with the extension and not a SQLFluff issue.
from vscode-sqlfluff.
I also have this exact issue. It would be great if this extension eventually worked for VS Code remote containers, with dbt...
from vscode-sqlfluff.
@RobertOstermann thanks for dealing w/this issue,
here's output from the sqlfluff output channel
------------------------------------------------------------
Reading from stdin, not file, input may be dirty/partial
--------------------Executing Command--------------------
[redacted]/bin/sqlfluff lint --format json --config [redacted]/.sqlfluff --dialect bigquery --exclude-rules L009,L016 -
------------------------------------------------------------
Received close event, code 0 signal null
Raw stdout output:
------------------------------------------------------------
==== readout ====
==== summary ====
violations: 0 status: PASS
[]
------------------------------------------------------------
Raw stderr output:
------------------------------------------------------------
WARNING File [redacted]/stdin was not found in dbt project
of course if you echo an empty string into sqlfluff format, it wont' be able to do much, yet it's complaining
echo '' | sqlfluff lint --format json -
==== readout ====
WARNING File [redacted]/stdin was not found in dbt project
==== summary ====
violations: 0 status: PASS
[]
and this is the exact error I also keep getting
here's my configuration
"sqlfluff.config": "${workspaceFolder}/.sqlfluff",
"sqlfluff.dialect": "bigquery",
"sqlfluff.excludeRules": ["L009","L016"],
"sqlfluff.executablePath": "[redacted]/bin/sqlfluff",
"sqlfluff.experimental.format.executeInTerminal": true,
"sqlfluff.format.enabled": true,
"sqlfluff.format.workingDirectory": "",
"sqlfluff.ignoreLocalConfig": false,
"sqlfluff.ignoreParsing": false,
"sqlfluff.linter.run": "onType",
"sqlfluff.rules": [],
thank you!
from vscode-sqlfluff.
I am having the exact same issue
from vscode-sqlfluff.
@RobertOstermann For me this resolves the exceptions. However, it would be great if it is actually ran onType. Or at least also when we open a new file.
from vscode-sqlfluff.
@Luttik I am not able to change this to allow it to run onType, you would have to create an issue with the actual SQLFluff repo for that I think. Currently, the dbt-templater does not allow me to pass in the file contents through stdin
. It only allows me to pass the path of a file, which means if the file is unsaved it will not lint correctly.
I have done some work on another dbt templater that uses dbt-osmosis
to lint the files. That templater does not allow for formatting the document, but does lint much faster than the regular dbt templater and allows for linting onType
. Would you be interested in me publishing the changes I have made to allow that templater to work?
from vscode-sqlfluff.
Hi Robert, That might be a good suggestion...
I think that stability is key though for an IDE plugin. So if it is necessary, it might be a good fix to just enforce the onSave behavior when the templater is DBT (and maybe send a VSCode popup warning when first detected).
from vscode-sqlfluff.
Hi Robert, That might be a good suggestion...
I think that stability is key though for an IDE plugin. So if it is necessary, it might be a good fix to just enforce the onSave behavior when the templater is DBT (and maybe send a VSCode popup warning when first detected).
Yeah, I could do that when the configuration file path is provided. The difficulty comes when that path is not provided for this extensions settings, then I rely on the SQLFluff tool to find the configuration file and do not know if the templater is dbt or not.
I have also thought about adding a sqlfluff.dbt.enabled
setting that would automatically use the settings required for dbt to work, such as onSave
, so you wouldn't have to change each of those settings and it would be only 1 setting to get dbt to work.
from vscode-sqlfluff.
Related Issues (20)
- SQLFluff Formatting Failed. HOT 1
- SQL Fluff Fix is not working HOT 2
- Feature Request / Question: `noqa` inline quick fix HOT 5
- dbt project not registered HOT 2
- Allow ${userHome} variable to be used in executable path
- Issues with SQLFluff Command Execution and Path Specification HOT 8
- Aligned elements: attempting to set alias_expression HOT 4
- Allow exclude files HOT 1
- Nothing is showing in VS code when we do 'Format Document' HOT 1
- Fixes for LT01 not applied
- Not specifying a SQL Dialect in extension settings leads to confusing error HOT 1
- Environment variables cannot be passed to extension
- VS code SQL editor marks problems but running SQLFluff via terminal doesn't detect problems
- vscode format on save errors due to future deprecation
- `sqlfluff 3.0` release breaks extension `sql` document formatter HOT 5
- OSError: [Errno 6] Device not configured: '/dev/tty' HOT 4
- No documentation or examples for how to override defaults for rules or rule groups HOT 2
- `Format Document` or `SQLFluff: Fix` overwrites file contents with sqlfluff logs HOT 4
- Can't find the sqlfluff.exe file after installation HOT 6
- [Feature] Show rule name in `Problems` tab HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-sqlfluff.