-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: sqlfluff-changed-files | ||
name: sqlfluff-changed-files | ||
entry: ./dbt_scripts/run_sqlfluff_on_changed_files.sh | ||
language: script | ||
files: \.sql$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# .sqlfluff configuration file | ||
[sqlfluff] | ||
dialect = snowflake | ||
templater = jinja | ||
|
||
# General linting rules | ||
[sqlfluff:rules] | ||
max_line_length = 100 # Set maximum line length | ||
tab_space_size = 4 # Define tab space size | ||
|
||
# Specific rule configurations | ||
[sqlfluff:rules:L003] # Indentation should be a multiple of 4 spaces | ||
tab_space_size = 4 | ||
|
||
[sqlfluff:rules:capitalisation.keywords] | ||
capitalisation_policy = upper | ||
|
||
[sqlfluff:rules:capitalisation.identifiers] # Inconsistent capitalisation of unquoted identifiers | ||
extended_capitalisation_policy = consistent | ||
|
||
[sqlfluff:rules:references.consistent] # Avoid using aliases in join clauses | ||
single_table_references = consistent | ||
|
||
[sqlfluff:layout:type:comma] | ||
line_position = leading |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
# Get the list of changed SQL files | ||
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.sql$') | ||
|
||
if [ -z "$CHANGED_FILES" ]; then | ||
echo "No changed SQL files to lint" | ||
exit 0 | ||
fi | ||
|
||
# Run SQLFluff on each changed SQL file | ||
for file in $CHANGED_FILES; do | ||
sqlfluff fix "$file" | ||
if [ $? -ne 0 ]; then | ||
echo "SQLFluff found issues in $file" | ||
exit 1 | ||
fi | ||
done | ||
|
||
exit 0 |
20 changes: 14 additions & 6 deletions
20
models/metrics/stablecoins/contracts/fact_tron_stablecoin_contracts.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
{{ config(materialized="table") }} | ||
select symbol, contract_address, num_decimals, coingecko_id, initial_supply | ||
from | ||
SELECT | ||
symbol | ||
, contract_address | ||
, num_decimals | ||
, coingecko_id | ||
, initial_supply | ||
FROM | ||
( | ||
values | ||
('USDC', 'TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8', 6, 'usd-coin', 0), | ||
('USDT', 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', 6, 'tether', 0) | ||
) as results(symbol, contract_address, num_decimals, coingecko_id, initial_supply) | ||
VALUES | ||
('USDC', 'TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8', 6, 'usd-coin', 0) | ||
, ('USDT', 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', 6, 'tether', 0) | ||
) | ||
AS results ( | ||
symbol, contract_address, num_decimals, coingecko_id, initial_supply | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters