Collate SQLFluff

3.5.2 · active · verified Tue Apr 14

collate-sqlfluff is a fork of SQLFluff (the SQL Linter for Humans), maintained by the OpenMetadata community. It provides a modular, dialect-flexible, and configurable SQL linter and auto-formatter, designed particularly for ELT applications. It supports multiple SQL dialects (e.g., BigQuery, Snowflake, PostgreSQL) and templating languages like Jinja and dbt. The library frequently syncs with upstream SQLFluff, incorporating its features and adhering to its semantic versioning, while adding specific enhancements relevant to OpenMetadata's ecosystem.

Warnings

Install

Imports

Quickstart

This example demonstrates how to use the programmatic API to lint and fix a SQL string using the `sqlfluff` module. The `dialect` parameter is often crucial for accurate linting and fixing.

import sqlfluff

my_bad_query = "SeLEct *, 1, blah as fOO from mySchema.myTable"

# Lint the given string and return violations
lint_result = sqlfluff.lint(my_bad_query, dialect="bigquery")
print("Linting Results:", lint_result)

# Fix the given string and get a fixed string back
fix_result = sqlfluff.fix(my_bad_query, dialect="bigquery")
print("Fixed Query:\n", fix_result)

view raw JSON →