Skip to content

SQLFluff Pre-Commit Hook Not Detecting Trino SQL Issues #6619

@jorgemgomes

Description

@jorgemgomes

Search before asking

  • I searched the issues and found no similar issues.

What Happened

The sqlfluff-lint hook in my pre-commit setup is not detecting any linting issues in my SQL files, even when intentional errors are introduced.

Expected Behaviour

----------------------------- DDL -----------------------------
create table if not exists ${vars:catalog}.${vars:schema}.table
(
date_nk date,
date_ts timestamp,
site varchar(30)
partition_date date
)
with (
format = 'parquet',
partitioned_by = array ['partition_date']
);

----------------------------- sql -----------------------------
--truncate table everyday
dele
fro ${vars:catalog}.${vars:schema}.table
where 1 = 1
;

SQLFluff should flag issues in the pre-commit hook

Observed Behaviour

--- .pre-commit-config.yaml:

  • repo: https://github.com/sqlfluff/sqlfluff
    rev: 3.3.0
    hooks:
    • id: sqlfluff-lint
      args: [ --dialect=trino, --config=.sqlfluff ]
      files: code/
    • id: sqlfluff-fix
      args: [ --dialect=trino, --config=.sqlfluff ]
      files: code/

-- Result from commit:
sqlfluff-lint............................................................Passed
sqlfluff-fix.............................................................Passed

How to reproduce

Use the pre-commit-config.yaml, the .sqlfluff config presented below and the sql query with intentional issues that I shared.

Dialect

Trino

Version

3.3.0

Configuration

[sqlfluff]
verbose = 1
nocolor = False
dialect = trino
templater = placeholder
exclude_rules = AM04, AM06, CV02, CV06, LT05, RF02, RF04, RF05, ST02
large_file_skip_byte_limit = 50000
max_line_length = 150

[sqlfluff:indentation]
indented_joins = True

[sqlfluff:templater:placeholder]
param_regex = ${vars:(?<param_name>[\w_]+)}
date = 2023-05-31
year = 2023
month = 07
day = 11
schema = odyn
catalog = glue

Some rules have their own specific config.

[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = lower

[sqlfluff:rules:capitalisation.identifiers]
extended_capitalisation_policy = lower

[sqlfluff:rules:capitalisation.functions]
capitalisation_policy = lower

[sqlfluff:rules:capitalisation.types]
extended_capitalisation_policy = lower

[sqlfluff:rules:convention.select_trailing_comma]
select_clause_trailing_comma = forbid

[sqlfluff:rules:convention.count_rows]
prefer_count_1 = True

[sqlfluff:rules:convention.terminator]
multiline_newline = True
require_final_semicolon = False

[sqlfluff:rules:convention.quoted_literals]
preferred_quoted_literal_style = single_quotes

[sqlfluff:layout:type:comma]
line_position = trailing

[sqlfluff:rules:structure.subquery]
forbid_subquery_in = join

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtrino

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions