Skip to content

Commit 006423f

Browse files
author
msj
committed
Add sqlfluff for formatting
1 parent 396b35c commit 006423f

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
- id: flake8
1818
args: [--config=.flake8]
1919

20-
# - repo: https://github.com/sqlfluff/sqlfluff
21-
# rev: 2.3.5
22-
# hooks:
23-
# - id: sqlfluff-lint
20+
- repo: https://github.com/sqlfluff/sqlfluff
21+
rev: 2.3.5
22+
hooks:
23+
- id: sqlfluff-lint

.sqlfluff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Supported dialects https://docs.sqlfluff.com/en/stable/dialects.html
44
# Or run 'sqlfluff dialects'
5-
dialect = snowflake
5+
dialect = sqlite
66

77
# One of [raw|jinja|python|placeholder]
88
templater = jinja
@@ -17,7 +17,7 @@ exclude_rules = ambiguous.column_count, structure.column_order
1717
# other tools and several style guides. Many projects however prefer
1818
# something a little longer.
1919
# Set to zero or negative to disable checks.
20-
max_line_length = 120
20+
max_line_length = 80
2121

2222
# CPU processes to use while linting.
2323
# The default is "single threaded" to allow easy debugging, but this

scripts/update.sql

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
-- Given a CSV of re-scraped cases, update the matching cases in the database
22
CREATE TEMPORARY TABLE raw_case (
3-
ad_damnum text,
4-
calendar text,
5-
case_number text,
6-
case_type text,
7-
court text,
8-
division text,
9-
filing_date text,
10-
hash text,
11-
scraped_at text,
12-
updated_at text
3+
ad_damnum text,
4+
calendar text,
5+
case_number text,
6+
case_type text,
7+
court text,
8+
division text,
9+
filing_date text,
10+
hash text,
11+
scraped_at text,
12+
updated_at text
1313
);
1414

15-
.mode csv
16-
.import /dev/stdin raw_case
15+
.mode csv -- noqa
16+
.import /dev/stdin raw_case -- noqa
1717

1818
-- Update cases that have changed (i.e. their hashes are different)
1919
UPDATE court_case
20-
SET calendar = raw_case.calendar,
21-
filing_date = raw_case.filing_date,
22-
division = raw_case.division,
23-
case_type = raw_case.case_type,
24-
ad_damnum = raw_case.ad_damnum,
25-
court = raw_case.court,
26-
hash = raw_case.hash,
27-
scraped_at = raw_case.scraped_at,
28-
updated_at = raw_case.scraped_at
20+
SET
21+
calendar = raw_case.calendar,
22+
filing_date = raw_case.filing_date,
23+
division = raw_case.division,
24+
case_type = raw_case.case_type,
25+
ad_damnum = raw_case.ad_damnum,
26+
court = raw_case.court,
27+
hash = raw_case.hash,
28+
scraped_at = raw_case.scraped_at,
29+
updated_at = raw_case.scraped_at
2930
FROM raw_case
30-
WHERE court_case.case_number = raw_case.case_number and court_case.hash != raw_case.hash;
31+
WHERE
32+
court_case.case_number = raw_case.case_number AND court_case.hash != raw_case.hash;
3133

3234
-- For cases that haven't changed, just update their scraped_at field
3335
UPDATE court_case
3436
SET scraped_at = raw_case.scraped_at
35-
from raw_case
36-
where court_case.case_number = raw_case.case_number and court_case.hash = raw_case.hash;
37+
FROM raw_case
38+
WHERE
39+
court_case.case_number = raw_case.case_number AND court_case.hash = raw_case.hash;

0 commit comments

Comments
 (0)