Хотя sqlfluff-templater-dbt установлен, sqlfluff установлен, но получает ошибку, связанную с шаблонизатором 'dbt' в настоящее время недоступен.
вот мои файлы ловушек sqlfluff и recommit
Код: Выделить всё
pre-commit run sqlfluff-lint
sqlfluff-lint............................................................Failed
- hook id: sqlfluff-lint
- exit code: 2
Starting in sqlfluff version 0.7.0 the dbt templater is distributed as a separate python package. Please pip install sqlfluff-templater-dbt to use it.
Error loading config: Requested templater 'dbt' which is not currently available. Try one of raw, jinja, python, placeholder
Код: Выделить всё
#.sqlfluff
[sqlfluff]
# Supported dialects https://docs.sqlfluff.com/en/stable/dialects.html
# Or run 'sqlfluff dialects'
dialect = postgres
# One of [raw|jinja|python|placeholder]
templater = dbt
sql_file_exts = .sql,.sql.j2,.dml,.ddl
# Comma separated list of rules to exclude, or None
# See https://docs.sqlfluff.com/en/stable/configuration.html#enabling-and-disabling-rules
# AM04 (ambiguous.column_count) and ST06 (structure.column_order) are
# two of the more controversial rules included to illustrate usage.
exclude_rules = ambiguous.column_count, structure.column_order
# The standard max_line_length is 80 in line with the convention of
# other tools and several style guides. Many projects however prefer
# something a little longer.
# Set to zero or negative to disable checks.
max_line_length = 140
# CPU processes to use while linting.
# The default is "single threaded" to allow easy debugging, but this
# is often undesirable at scale.
# If positive, just implies number of processes.
# If negative or zero, implies number_of_cpus - specified_number.
# e.g. -1 means use all processors but one. 0 means all cpus.
processes = 0
# If using the dbt templater, we recommend setting the project dir.
[sqlfluff:templater:dbt]
project_dir = ./
profiles_dir = .dbt/
profile = my_transformation
target = prod
[sqlfluff:templater:jinja]
apply_dbt_builtins = True
Код: Выделить всё
#.pre-commit-config.yaml
repos:
- repo: https://github.com/sqlfluff/sqlfluff
rev: 3.0.7 # Use the version you want
hooks:
- id: sqlfluff-lint
name: SQLFluff lint
entry: sqlfluff lint
language: python
files: \.sql$
- id: sqlfluff-fix
name: SQLFluff fix
entry: sqlfluff fix
language: python
files: \.sql$
Код: Выделить всё
Error loading config: Requested templater 'dbt' which is not currently available. Try one of raw, jinja, python, placeholderКод: Выделить всё
sqlfluff lint my_sql_file.sql
Код: Выделить всё
sqlfluff fix my_sql_file.sql
Подробнее здесь: https://stackoverflow.com/questions/790 ... -available