Skip to content

fix(curation): remove redundant wrapper parse in reject_non_single_select - #542

Open
amansingh-121 wants to merge 1 commit into
Hebbian-Robotics:mainfrom
amansingh-121:curation-remove-dead-parse
Open

amansingh-121 wants to merge 1 commit into
Hebbian-Robotics:mainfrom
amansingh-121:curation-remove-dead-parse

Conversation

@amansingh-121

Copy link
Copy Markdown
Contributor

Closes #481.

Removes the redundant third parsing step in reject_non_single_select (src/hflow/curation.py). The function already rejects multi-statement inputs and PRAGMA/DESCRIBE/SHOW/SUMMARIZE inputs via DuckDB's extract_statements count/type check and the leading-keyword check, respectively. The wrapper parse SELECT * FROM (<sql>) never catches a case that isn't already refused, and it adds a per-query DuckDB parse for no benefit.

The wrapper parse was originally added to catch subquery-forbidden leading keywords, but those are already covered by the _leading_keyword gate, and any SQL that parses standalone as a single SELECT also parses inside the wrapper (or is already rejected by the count/type check). Measurements in the issue confirmed the block is dead: removing it leaves all 9 reject_non_single_select tests green, and a broad shape sweep found no input where the wrapped parse fails while the first two checks pass.

Changes

  • Remove the wrapped_input construction and the extract_statements(wrapped_input) try/except.
  • Update the docstring and inline comment to remove references to the wrapper parse.

Tests

  • All test_reject_non_single_select* tests pass (9/9).
  • ruff check, ruff format --check, and ty check all pass.

Notes

The change is purely a dead-code removal — no new behaviour is introduced, and no existing refusal messages change. The per-query parse cost drops by one DuckDB parse for every curation gate check.

@kstonekuan

Copy link
Copy Markdown
Contributor

Please stop taking good first issue tickets. You were asked on #518 and this is another one.

Not reviewing this.

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.

The curation gate parses every query twice, and the second parse refuses nothing

2 participants