Commit ac90080
feat: add sqlfmt pre-commit hook and format all SQL files (#953)
* feat: add sqlfmt pre-commit hook and format all SQL files
- Add sqlfmt (v0.29.0) as a pre-commit hook with jinjafmt support
- Run sqlfmt on all SQL files in the repo (excluding dbt_packages/)
- This enforces consistent SQL formatting across the codebase
Resolves: ELE-5274
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* fix: restore return() parens broken by sqlfmt + update CI to Python 3.10
- Fix Jinja compilation error in is_primitive macro where sqlfmt removed
parentheses from return() call
- Update run-precommit.yml to Python 3.10 (sqlfmt requires >= 3.10)
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* fix: restore Jinja return() parens, ClickHouse casing, exclude unparseable files
- Fix all broken Jinja return() calls across 3 files (sqlfmt removed parens)
- Restore ClickHouse function casing with -- fmt: off protection (parseDateTimeBestEffortOrNull, formatDateTime, toString, toDateTime)
- Exclude 4 unparseable SQL files from sqlfmt hook in .pre-commit-config.yaml
- Error message formatting updated by sqlfmt (cosmetic only)
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* fix: restore files with Python/YAML/non-SQL content damaged by sqlfmt
- Restore compile_py_code.sql (Python code for Snowflake/BigQuery)
- Restore test_json_schema.sql (Python code for json validation)
- Restore python.sql (Python test macros)
- Restore generate_schema_baseline_test.sql (YAML template output)
- Restore empty_table.sql (corrupted Jinja dict key access)
- Exclude all files with non-SQL content from sqlfmt hook
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* fix: restore corrupted Jinja dict keys in test_exposure_schema_validity.sql
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* fix: restore files with ClickHouse/BigQuery case-sensitive identifiers and exclude from sqlfmt
sqlfmt lowercases camelCase/PascalCase identifiers that are case-sensitive
in ClickHouse and BigQuery. Since sqlfmt will always re-lowercase these on
every run, the correct fix is to restore these files from master and exclude
them from sqlfmt.
Restored files (7):
- column_numeric_monitors.sql (stddevPop, varSamp, Nullable)
- table_monitoring_query.sql (dateDiff, Nullable)
- buckets_cte.sql (arrayJoin, toUInt32)
- full_names.sql (splitByChar, BOTH, AS, OFFSET)
- datediff.sql (dateDiff, Nullable, Int32)
- lag.sql (lagInFrame)
- null_as.sql (Nullable)
Also adds exclude pattern for integration_tests/dbt_project/dbt_packages/
to prevent symlink recursion during pre-commit runs.
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* docs: add comment explaining sqlfmt exclude list reasons
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* refactor: use -- fmt: off/on for ClickHouse/BigQuery case-sensitive identifiers instead of file exclusion
Instead of excluding 7 files entirely from sqlfmt, use inline
-- fmt: off / -- fmt: on comments to protect only the case-sensitive
identifiers (Nullable, stddevPop, varSamp, arrayJoin, toUInt32,
splitByChar, dateDiff, lagInFrame, OFFSET) while letting sqlfmt
format the rest of each file.
This reduces the exclude list from 17 to 10 files.
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* revert: restore ClickHouse/BigQuery files to exclusion approach
The -- fmt: off/on inline comments break ClickHouse's SQL parser when
macros are inlined into compiled queries (the comments cause 'Unmatched
parentheses' syntax errors). Reverted to full-file exclusion with an
updated comment explaining why inline comments can't be used here.
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* fix: restore dict utility macros and store_anomaly_test_results to fix fusion compatibility
sqlfmt reformatting of these files collapsed multi-line Jinja conditionals
with return() statements to single lines, causing fusion's minijinja engine
to treat returned dicts as immutable maps. This broke .update() calls with
'map has no method named update' errors in all fusion test variants.
Files restored to master versions and excluded from sqlfmt.
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* fix: restore all macros/edr, dict_utils, graph from master and exclude from sqlfmt for fusion compatibility
sqlfmt's Jinja reformatting (trailing commas, collapsed conditionals, multi-line
macro calls) causes fusion's minijinja engine to mishandle dict types, breaking
.update() calls with 'map has no method named update'. The issue is systemic
across the Jinja execution chain and not isolatable to specific files.
Restores all 131 macro files under macros/edr/, macros/utils/dict_utils/, and
macros/utils/graph/ to their master versions and excludes these directories
from sqlfmt. Models and other utility macros remain formatted.
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* fix: restore ALL macros from master and exclude entire macros/ dir from sqlfmt
The fusion minijinja 'map has no method named update' error persists even after
restoring macros/edr/, dict_utils/, and graph/. The remaining sqlfmt-formatted
utility macros (cross_db_utils, data_types, table_operations, run_queries, etc.)
are also in the test execution chain. Excluding the entire macros/ directory
from sqlfmt ensures fusion compatibility.
sqlfmt formatting is now applied to models/ and integration_tests/ SQL files only.
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* test: restore ALL SQL files to master to verify if fusion failure is pre-existing
Only .pre-commit-config.yaml and .github/workflows/run-precommit.yml differ
from master. All macros/, models/, and integration_tests/ SQL files are
identical to master. If fusion still fails, the issue is pre-existing in the
elementary Python repo, not caused by sqlfmt formatting.
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* feat: restore sqlfmt formatting — fusion failure proven pre-existing
Definitive test (commit a7ec322) proved fusion 'map has no method named update'
failure occurs even with ALL SQL files identical to master. The only differences
were .pre-commit-config.yaml and .github/workflows/run-precommit.yml, which
don't affect dbt execution. Therefore the fusion failure is pre-existing in the
elementary-data/elementary Python repo, not caused by sqlfmt formatting.
This commit restores the proper sqlfmt formatting for all applicable SQL files,
with exclusions only for files sqlfmt genuinely damages:
- ClickHouse/BigQuery case-sensitive identifiers
- Embedded Python/YAML content
- Complex Jinja patterns sqlfmt cannot parse
- dbt_packages symlink (infinite recursion)
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* style: one-time sqlfmt format of excluded ClickHouse/BigQuery files
Run sqlfmt on the 8 excluded files that contain ClickHouse/BigQuery
case-sensitive identifiers. After formatting, restore the correct
casing for: splitByChar, arrayJoin, toUInt32, dateDiff, lagInFrame,
stddevPop, varSamp, Nullable, Int32.
Files remain excluded in .pre-commit-config.yaml so future edits
are not auto-formatted (which would re-lowercase the identifiers).
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
* fix: restore dict key access syntax in empty_table.sql
sqlfmt corrupted Jinja dict bracket access by adding spaces:
dummy_values['timestamp'] → dummy_values[' timestamp ']
This caused empty string values instead of actual dummy values,
breaking Postgres (invalid timestamp '') and ClickHouse (CANNOT_PARSE_DATETIME).
Co-Authored-By: Itamar Hartstein <haritamar@gmail.com>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Itamar Hartstein <haritamar@gmail.com>1 parent e4a4826 commit ac90080
276 files changed
Lines changed: 11329 additions & 6977 deletions
File tree
- .github/workflows
- integration_tests/dbt_project
- macros
- ci_schemas_cleanup
- schema_utils
- models
- metrics/sql
- macros
- commands
- permissions
- edr
- alerts
- data_monitoring
- anomaly_detection
- data_monitors_configuration
- monitors_query
- monitors
- schema_changes
- dbt_artifacts
- materializations/test
- metadata_collection
- system
- configuration
- hooks
- system_utils
- tests
- on_run_end
- on_run_start
- test_configuration
- test_utils
- materializations
- utils
- cross_db_utils
- data_types
- dict_utils
- graph
- list_utils
- run_queries
- sql_utils
- table_operations
- models/edr
- alerts
- data_monitoring
- anomaly_detection
- data_monitoring
- schema_changes
- dbt_artifacts
- run_results
- system
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
30 | 65 | | |
31 | 66 | | |
32 | 67 | | |
| |||
Lines changed: 58 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
39 | 51 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
53 | 77 | | |
54 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
55 | 84 | | |
Lines changed: 25 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 33 | + | |
| 34 | + | |
32 | 35 | | |
Lines changed: 75 additions & 55 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
32 | 39 | | |
33 | 40 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
57 | 72 | | |
58 | 73 | | |
59 | 74 | | |
60 | 75 | | |
61 | | - | |
62 | 76 | | |
63 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
64 | 82 | | |
65 | 83 | | |
66 | 84 | | |
67 | | - | |
68 | | - | |
69 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
70 | 90 | | |
71 | 91 | | |
72 | 92 | | |
73 | | - | |
74 | | - | |
| 93 | + | |
| 94 | + | |
75 | 95 | | |
76 | 96 | | |
77 | 97 | | |
78 | | - | |
79 | | - | |
| 98 | + | |
| 99 | + | |
80 | 100 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
9 | 17 | | |
10 | 18 | | |
11 | 19 | | |
12 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
13 | 23 | | |
14 | 24 | | |
15 | 25 | | |
| |||
0 commit comments