Skip to content

Indent BigQuery pipe AGGREGATE and EXTEND clause lists - #8190

Merged
peterbud merged 1 commit into
sqlfluff:mainfrom
ricardoalencar-pr:fix/bigquery-pipe-aggregate-extend-indent
Jul 22, 2026
Merged

peterbud merged 1 commit into
sqlfluff:mainfrom
ricardoalencar-pr:fix/bigquery-pipe-aggregate-extend-indent

Conversation

@ricardoalencar-pr

@ricardoalencar-pr ricardoalencar-pr commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Brief summary of the change made

Fixes #8189.

BigQuery pipe-syntax AGGREGATE and EXTEND clauses take a
comma-delimited expression list, like SELECT and GROUP BY, but their
grammar wrapped that list without Indent / Dedent metadata. As a
result LT02 (layout.indent) flagged every continuation line as "Line
should not be indented", and sqlfluff fix would not indent a
multi-line clause — so an indented multi-line AGGREGATE was impossible.

This wraps the Delimited(...) list of both AggregateClauseSegment
and ExtendClauseSegment in Indent / Dedent, matching how
GroupAndOrderByClauseSegment (the GROUP BY used in the same pipe
syntax) already behaves.

Before:

FROM my_table
|> AGGREGATE
    SUM(a) AS total_a,   -- LT02: Line should not be indented
    SUM(b) AS total_b    -- LT02: Line should not be indented
GROUP BY c

After: lints clean, and fix indents a flat list to the above.

Are there any other side effects of this change that we should be aware of?

Indent / Dedent are meta segments and are excluded from the parse
YAML fixtures, so existing test/fixtures/dialects/bigquery fixtures are
unchanged. All 429 bigquery dialect tests and the LT01/LT02/LT03 rule
suites pass. Single-line AGGREGATE / EXTEND are unaffected.

Pull Request checklist

  • Included test cases to demonstrate the code change:
    • .yml rule test cases in test/fixtures/rules/std_rule_cases
      (LT02-indent.yml): a passing indented multi-line AGGREGATE, a
      fail/fix pair, and a passing multi-line EXTEND.
  • Change is small and self-documenting; no docs change needed.
  • Created GitHub issues for any relevant followup — n/a.

Summary by cubic

Fix indentation for BigQuery pipe AGGREGATE and EXTEND clause lists. Adds indent metadata so multi-line lists are indented correctly, removing LT02 false positives and allowing sqlfluff fix to format them.

  • Bug Fixes
    • Wrap the Delimited(...) expression list in Indent/Dedent for both clauses, matching pipe GROUP BY.
    • Add LT02 rule cases for multi-line AGGREGATE and EXTEND, including a fixable failure.

Written for commit ef0bfab. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Results ✅

Name    Stmts   Miss  Cover   Missing
-------------------------------------
TOTAL   22533      0   100%

269 files skipped due to complete coverage.

@peterbud
peterbud added this pull request to the merge queue Jul 22, 2026
Merged via the queue into sqlfluff:main with commit 72d0d38 Jul 22, 2026
49 checks passed
benfdking added a commit to quarylabs/sqruff that referenced this pull request Oct 5, 2026
Port SQLFluff #8190 (72d0d389e7ae25a5719953597b55385e7d19870a).

Add indent and dedent metadata around BigQuery pipe AGGREGATE and EXTEND expression lists. Add the three upstream LT02 regression cases.

Upstream PR: sqlfluff/sqlfluff#8190

Upstream commit: sqlfluff/sqlfluff@72d0d38
benfdking added a commit to quarylabs/sqruff that referenced this pull request Oct 5, 2026
Port SQLFluff #8190 (72d0d389e7ae25a5719953597b55385e7d19870a).

Add indent and dedent metadata around BigQuery pipe AGGREGATE and EXTEND expression lists. Add the three upstream LT02 regression cases.

Upstream PR: sqlfluff/sqlfluff#8190

Upstream commit: sqlfluff/sqlfluff@72d0d38
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.

BigQuery pipe AGGREGATE/EXTEND clauses can't be indented (LT02 false positive)

2 participants