#8444·sqlfluff

SELECT SELECT 1 parses without error - a second SELECT keyword is silently accepted as a nested statement

Author: tan-ircoCreated Sep 4, 2026Updated Sep 17, 2026

Search before asking

  • I searched the issues and found no similar issues.

What Happened

SELECT SELECT 1 parses with zero violations on ansi and bigquery: the second SELECT is read as a nested select_statement used as the outer select clause's expression, equivalent to SELECT (SELECT 1) but without requiring the parentheses. BigQuery and Snowflake both reject the unparenthesized form as a syntax error, so this is a grammar gap, not an intentional extension.

Expected Behaviour

A PRS parsing violation, the same way three consecutive WHERE keywords (WHERE WHERE WHERE (x = 1)) already correctly produce one.

Observed Behaviour

Zero violations; sqlfluff lint reports All Finished!. sqlfluff parse shows the second SELECT starting a nested select_statement segment inside the first one's select_clause_element, with no requirement for surrounding parentheses.

Confirmed this is a real syntax error, not a style preference: tested against a live BigQuery project via a dry-run query -

SELECT SELECT 1
→ Error 400: Syntax error: Unexpected keyword SELECT at [1:8]

while the parenthesized form runs cleanly (SELECT (SELECT 1) → succeeds). Also rejected by BigQuery Studio's UI and Snowflake's UI - not engine-specific, this is invalid SQL generally.

How to reproduce

sql
SELECT SELECT 1;

sqlfluff lint --dialect bigquery example.sql (also reproduces with --dialect ansi) reports no violations at all.

Dialect

Reproduces on both ansi and bigquery - appears to be a core grammar issue (likely in how select_statement becomes reachable as a bare expression/select_clause_element), not a BigQuery-specific dialect extension.

Version

sqlfluff, version 4.3.0, Python 3.13.9.

Configuration

No .sqlfluff config file used for this repro - bare sqlfluff lint --dialect bigquery example.sql / sqlfluff parse --dialect bigquery example.sql with no other flags or config.

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct