Skip to content

Lint patron_data.sql and import-partial.sql with sqlfluff 4.4.0 - #13732

Merged
RayBB merged 2 commits into
internetarchive:masterfrom
gauranshahuja:12245-sqlfluff-exclusions
Oct 12, 2026
Merged

RayBB merged 2 commits into
internetarchive:masterfrom
gauranshahuja:12245-sqlfluff-exclusions

Conversation

@gauranshahuja

@gauranshahuja gauranshahuja commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #12245

Technical

sqlfluff 4.4.0 includes the fixes for sqlfluff/sqlfluff#7696 and #7697, so the two files excluded from the sqlfluff-lint hook can be linted now. This PR bumps the hook to 4.4.0 (the latest release), removes the exclude, and fixes what the linter then reports:

  • scripts/dev-instance/patron_data.sql now parses. The only findings were in the four hand-written INSERT statements at the end (LT14, ST05, RF02). They are reformatted onto multiple lines, and the datum_ref insert uses CTEs instead of subqueries in FROM. The column mapping is unchanged: the three columns are selected in the same order as before, now with explicit aliases matching the target columns. The file is loaded with psql from stdin (scripts/dev-instance/load-patron-data.sh), which handles multi-line statements.
  • scripts/solr_builder/sql/import-partial.sql: the :source placeholder parses now, but sqlfluff can't parse the pre-9.0 COPY option syntax WITH delimiter E'\t' quote E'\b' csv. It is switched to the equivalent WITH (FORMAT csv, DELIMITER E'\t', QUOTE E'\b'). The two SELECT * there are deliberate (the temp table mirrors test), so they get -- noqa: AM04.

pre-commit.ci's #13585 also bumps sqlfluff; whichever lands second only needs that one line rebased.

Testing

  • sqlfluff lint --dialect postgres over all 15 tracked .sql files with both 4.3.0 and 4.4.0 (repo config): all pass. pre-commit run sqlfluff-lint --all-files passes on 4.4.0.
  • End-to-end on postgres:18.3 (dev DB initialised via docker/ol-db-init.sh): loading the old and new patron_data.sql produces identical version/data/datum_str/datum_ref rows for the test list, and the old and new import-partial.sql produce identical rows in test (including quotes, backslashes and an upsert conflict).
  • Parsed the changed SQL with pglast (libpg_query, PostgreSQL's own parser): all 9 INSERT statements in patron_data.sql parse, and the old and new COPY statements produce identical options (format=csv, delimiter=\t, quote=\x08).

Stakeholders

@RayBB

@openlibrary-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

The linked issue hasn't been triaged yet — triage happens on Mondays and Fridays. There are currently 64 open non-draft PRs ahead of yours.

PR triage checklist (maintainers / Pierre)
  • PR description — not empty; explains what the change does and how to verify it
  • References an issue — PR body contains a #NNN reference
    • Linked issue is triaged — has a Priority: * label (not just Needs: Triage)
    • Linked issue is assigned — has at least one assignee
  • Commit history clean — no WIP/fixup/conflict noise; commit messages are meaningful
  • CI passing — no failing check-runs
  • Test cases present — if the change touches substantive logic, test coverage exists or is explained
  • Proof of testing — PR body includes a description of what was tested, a screenshot, or a video

Note

This comment was automatically generated by Pierre, Open Library's PR first-touch assistant, on behalf of @mekarpeles. This is NOT a code review or sign-off.

@github-project-automation github-project-automation Bot moved this to Waiting Review/Merge from Staff in Ray's Project Sep 28, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@RayBB RayBB changed the title Lint patron_data.sql and import-partial.sql with sqlfluff 4.3.0 Lint patron_data.sql and import-partial.sql with sqlfluff 4.4.0 Oct 12, 2026
@RayBB RayBB removed the Needs: Lead label Oct 12, 2026

@RayBB RayBB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Very nice this is working as expected.
Appreciate you finding this and getting a PR open!

@RayBB
RayBB merged commit 249c173 into internetarchive:master Oct 12, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Tracking sqlfluff issue fixes to remove remaining files from pre-commit exclusion

3 participants