Skip to content

fix(lint): lint DuckDB queries under sqlfluff 4.4.0 - #624

Merged
Adam Lastowka (Rachmanin0xFF) merged 1 commit into
mainfrom
rachmanin0xff-fix-sqlfluff-lint-failures
Nov 18, 2026
Merged

Adam Lastowka (Rachmanin0xFF) merged 1 commit into
mainfrom
rachmanin0xff-fix-sqlfluff-lint-failures

Conversation

@Rachmanin0xFF

@Rachmanin0xFF Adam Lastowka (Rachmanin0xFF) commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request

Fixes #623

MegaLinter 10.2.0 (#612) ships sqlfluff 4.4.0, which can parse DuckDB LOAD and INSTALL. Before that, every DuckDB query failed to parse on the first line, and they all had -- noqa at the top to avoid that.

This PR removes the -- noqa lines (mostly) and fixes formatting to comply with the linting rules on all SQL examples.

Changes

  • src/queries/duckdb/.sqlfluff: match the athena exclude list. Also exclude AM09, AL03, AM03 and CP04. ST06 stays excluded because it reorders SELECT columns, which changes query output. Functions are lowercase, except CAST.
  • Query files: uppercase keywords, lowercase functions, leading AND, drop self-aliases, add trailing newlines.
  • Remove the dead -- noqa comments on LOAD/INSTALL lines.
  • Add -- noqa: PRS to the lines sqlfluff still can't parse: COPY ... WITH (FORMAT GDAL, ...) and SET VARIABLE.
  • places_conflating_OSM.sql: replace four CASE null checks with coalesce(...) (ST02). places_in_buildings.sql: DISTINCT(buildings.id) becomes DISTINCT buildings.id.
  • scripts/test_queries.py: skip comment-only fragments after a ;. Without this, a trailing ; -- noqa: PRS turns a single query into a multi-statement script.

Testing

  • uvx sqlfluff==4.4.0 lint --config .sqlfluff src/queries: passed, no violations.
  • python scripts/test_queries.py --dry-run: passed, all 62 files prepared.
  • Offline check against main: all 62 files are classified the same way (query vs. script), and DuckDB parses every statement.
  • The live smoke test against the release wasn't run locally. The Query Tests job on this PR covers it.

MegaLinter 10.2.0 ships sqlfluff 4.4.0, which parses DuckDB LOAD and
INSTALL. Before that, every DuckDB query failed to parse on line 1 and
the -- noqa on that line hid it, so no rules ran. Now they all run.

- Match the athena exclude list, and also exclude AM09, AL03, AM03 and
  CP04. ST06 stays excluded because it reorders SELECT output.
- Lowercase functions (except CAST) and uppercase keywords.
- Drop the dead noqa comments on LOAD and INSTALL lines.
- Mark COPY ... WITH (FORMAT GDAL) and SET VARIABLE lines with
  -- noqa: PRS, since sqlfluff still can't parse them.
- Replace CASE null checks with coalesce in places_conflating_OSM.sql.
- test_queries.py skips comment-only fragments after a semicolon, so a
  trailing -- noqa: PRS doesn't turn a query into a script.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Adam Lastowka <adamlastowka@gmail.com>
@github-actions

Copy link
Copy Markdown

🗺️ Overture Docs preview is live!

🌍 Preview site https://staging.overturemaps.org/docs/pr/624/index.html
🕐 Updated Nov 18, 2026 18:40 UTC
📝 Commit abaf38c

Note

♻️ This preview updates automatically with each push to this PR.

@github-actions

Copy link
Copy Markdown

✅MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ JAVASCRIPT eslint 32 0 0 19.13s
✅ MARKDOWN markdownlint 286 0 0 0.61s
✅ SQL sqlfluff 79 0 0 10.66s

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@10.2.0 --custom-flavor-setup --custom-flavor-linters JAVASCRIPT_ES,MARKDOWN_MARKDOWNLINT,SQL_SQLFLUFF

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

@Rachmanin0xFF
Adam Lastowka (Rachmanin0xFF) marked this pull request as ready for review November 18, 2026 18:42
Copilot AI balanced review requested due to automatic review settings November 18, 2026 18:42

@lowlydba John McCall (lowlydba) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful 🎨

@Rachmanin0xFF
Adam Lastowka (Rachmanin0xFF) merged commit a193b14 into main Nov 18, 2026
18 checks passed
@Rachmanin0xFF
Adam Lastowka (Rachmanin0xFF) deleted the rachmanin0xff-fix-sqlfluff-lint-failures branch November 18, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the DuckDB SQLFluff compatibility updates and smoke-test statement-splitter changes.

No open issues 🎉

What changed in this PR

Addresses #623 by adapting the documentation’s DuckDB examples to SQLFluff 4.4.0, introduced by the MegaLinter upgrade in #612.

Changes:

  • Adjusts DuckDB lint rules while preserving SELECT column order and existing layout.
  • Removes obsolete suppressions, standardizes SQL formatting, and adds targeted suppressions for unsupported syntax.
  • Updates the smoke-test statement splitter to ignore comment-only fragments.
File Description
src/​queries/​duckdb/​write_geoparquet.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​transportation_routes.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​transportation_parking.sql Removes suppressions; uses leading AND.
src/​queries/​duckdb/​segment_bbox.sql Removes suppressions; uses leading AND.
src/​queries/​duckdb/​seattle_water_for_map.sql Normalizes keyword casing; targets GDAL suppression.
src/​queries/​duckdb/​seattle_roads_for_map.sql Replaces LOAD suppression with GDAL suppression.
src/​queries/​duckdb/​seattle_places_for_map.sql Normalizes casing and AND placement; suppresses GDAL parsing.
src/​queries/​duckdb/​seattle_placenames_for_map.sql Normalizes alias casing; targets GDAL suppression.
src/​queries/​duckdb/​seattle_land_use_for_map.sql Replaces LOAD suppression with GDAL suppression.
src/​queries/​duckdb/​seattle_land_for_map.sql Replaces LOAD suppression with GDAL suppression.
src/​queries/​duckdb/​seattle_buildings_for_map.sql Normalizes alias casing; targets GDAL suppression.
src/​queries/​duckdb/​rome_places.sql Removes self-alias; adjusts AND placement and suppressions.
src/​queries/​duckdb/​places.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​places_wawa.sql Normalizes alias casing; targets GDAL suppression.
src/​queries/​duckdb/​places_mountains.sql Removes LOAD suppression; adds final newline.
src/​queries/​duckdb/​places_mills.sql Removes suppressions; normalizes alias casing.
src/​queries/​duckdb/​places_in_buildings.sql Normalizes DISTINCT syntax and keyword casing.
src/​queries/​duckdb/​places_conflating_OSM.sql Replaces null-check CASE expressions with coalesce; cleans up SQL.
src/​queries/​duckdb/​places_confidence.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​paris_roads_intersecting.sql Normalizes alias casing; targets GDAL suppression.
src/​queries/​duckdb/​paris_roads_contained.sql Normalizes alias casing; targets GDAL suppression.
src/​queries/​duckdb/​new_york_pizza.sql Removes self-alias; normalizes casing and suppressions.
src/​queries/​duckdb/​mountain_peaks.sql Normalizes alias casing; targets GDAL suppression.
src/​queries/​duckdb/​lithuania_places.sql Removes suppressions; normalizes alias casing.
src/​queries/​duckdb/​hyderabad_buildings.sql Replaces LOAD suppression with GDAL suppression.
src/​queries/​duckdb/​gers_registry_lookup_id.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​gers_registry_file_path.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​gers_registry_fetch_feature.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​gers_registry_check_matched_ids.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​gers_divisions_hierarchy.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​gers_divisions_hierarchy_areas.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​gers_churn_by_change_type.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​gers_bridge_meta_places_facebook.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​gers_bridge_buildings_multi_source.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​gers_bridge_buildings_by_source.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​divisions_subtype_counts_specific_countries.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​divisions_query_specific_feature.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​divisions_philly_places.sql Removes suppressions; lowercases function names.
src/​queries/​duckdb/​divisions_lookup_osm.sql Removes suppressions; uppercases LIKE.
src/​queries/​duckdb/​divisions_is_territorial_true.sql Normalizes casing; targets GDAL suppression.
src/​queries/​duckdb/​divisions_is_land_true.sql Normalizes casing; targets GDAL suppression.
src/​queries/​duckdb/​divisions_division_counts.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​divisions_division_area_counts.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​divisions_denmark_locality_neighborhood.sql Normalizes alias casing; targets GDAL suppression.
src/​queries/​duckdb/​divisions_counts_per_type.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​divisions_counts_per_entity.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​divisions_boundary_counts.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​divisions_border_usmx.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​county_level_geometries.sql Replaces LOAD suppression with GDAL suppression.
src/​queries/​duckdb/​changelog_places_feature_by_change_type.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​changelog_places_churn.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​buildings_in_division_area.sql Replaces extension suppressions with SET VARIABLE suppression.
src/​queries/​duckdb/​buildings_detroit.sql Normalizes alias casing; targets GDAL suppression.
src/​queries/​duckdb/​base_transit_rome.sql Removes LOAD suppression; adds final newline.
src/​queries/​duckdb/​base_transit_counts.sql Removes LOAD suppression; adds final newline.
src/​queries/​duckdb/​base_land_mountains.sql Removes obsolete LOAD suppression.
src/​queries/​duckdb/​addresses_utah.sql Removes extension suppressions; lowercases st_within.
src/​queries/​duckdb/​addresses_to_parquet.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​addresses_nz_export.sql Replaces LOAD suppressions with GDAL suppression.
src/​queries/​duckdb/​addresses_counts.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​addresses_calgary.sql Removes obsolete LOAD suppressions.
src/​queries/​duckdb/​.sqlfluff Expands rule exclusions; sets lowercase functions except CAST.
scripts/​test_queries.py Ignores comment-only fragments when splitting statements.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
staging — abaf38c6 Deployed Nov 18, 2026 by Rachmanin0xFF via Cleanup #229
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlfluff 4.4.0 fails on all DuckDB example queries

3 participants