Repository navigation
fix(semantics): give every select item its range through each dialect's strict parser - #203
Merged
Merged
Conversation
…'s strict parser Lineage reports a projection item's source range as its output's expression_range, but through parse_strict most items had none or a short one: - Snowflake recorded item ranges only in a located parse, so an aliased item, a call, an expression or a star had no range; only a column reference did. - DuckDB, BigQuery, SQLite, SQL Server, Databricks and ClickHouse give a qualified column its name's range, so w.status read as status. - SQL Server and ClickHouse gave an aliased item no range, and SQL Server none to a star. A strict Snowflake parse now records each select item's range, as a located one does; the plain parse still records none, so no serialised tree the syntax reviews fingerprint changes. Lineage runs a column's range from its qualifier. SQL Server ranges aliased items and stars, and ClickHouse aliased items. SQLite stars still have no range: recording one changes the parse trees of 15 reviewed SQLite forms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Lineage gives each output column its select item's byte range (
expression_range), but onlyquery_lineage's located parse recorded every item's range. Through each dialect'sparse_strict, most items had none or a short one. OnSELECT w.window_id, UPPER(w.sku) AS loud FROM orders AS w, Snowflake gaveloudno range, and DuckDB gavew.window_idthe rangewindow_id.Changes
Through
parse_strict, before → after:SQLite stars have no range yet: recording one changes the parse trees of 15 reviewed SQLite forms, which would need re-review.
Verification
parse_strictand asserts every output's exact byte range: a literal withASafter a two-byte character, a qualified column, a call with a bare label, a bare column and, except SQLite, a qualified star. Seven fail on the previous code; Postgres already passed.check-syntaxloses no form in any dialect.make instruction-countspasses. Once each on one machine, base main 9b9070d → this head: parse 253,208,648 → 252,880,943 (−0.13%), analysis 240,240,857 → 240,389,961 (+0.06%); repeat runs of one build differ by up to 0.02%. The baseline is unchanged.make check-cipasses.