-
Notifications
You must be signed in to change notification settings - Fork 3
feat(vnext): recognize bounded relation query sites #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e05f1ab
feat(vnext): recognize bounded relation query sites
Light2Dark b0e7978
fix(vnext): recognize quoted relation aliases
Light2Dark bdb91f1
fix(vnext): harden relation query recognition
Light2Dark aba3f22
test(vnext): cover chained join modifiers
Light2Dark 31c873b
docs(vnext): clarify dialect path depth budget
Light2Dark 12c7ac3
test(vnext): use spell-safe identifier fixture
Light2Dark 8fc0a97
fix(vnext): authenticate relation continuations
Light2Dark eea3f34
fix(vnext): authenticate join continuations
Light2Dark 01cd8d2
fix(vnext): bound identifier callbacks
Light2Dark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { bench, describe } from "vitest"; | ||
| import { | ||
| recognizeSqlRelationQuerySite, | ||
| type SqlQuerySiteDialect, | ||
| } from "../query-site.js"; | ||
| import { createIdentitySqlSource } from "../source.js"; | ||
| import { | ||
| buildSqlStatementIndex, | ||
| DUCKDB_SQL_LEXICAL_PROFILE, | ||
| findSqlStatementSlot, | ||
| } from "../statement-index.js"; | ||
|
|
||
| const dialect: SqlQuerySiteDialect = { | ||
| classifyRelationAlias: (rawAlias) => ({ | ||
| status: "identifier", | ||
| value: rawAlias, | ||
| }), | ||
| decodeRelationPath: (rawPath, cursorOffset) => ({ | ||
| finalSegment: { from: 0, to: rawPath.length }, | ||
| prefix: { | ||
| quoted: false, | ||
| value: rawPath.slice(0, cursorOffset), | ||
| }, | ||
| qualifier: [], | ||
| quality: "exact", | ||
| status: "decoded", | ||
| }), | ||
| lexicalProfile: DUCKDB_SQL_LEXICAL_PROFILE, | ||
| maximumPathDepth: 16, | ||
| supportsNaturalJoin: true, | ||
| }; | ||
| const tenKilobyteQuery = `SELECT ${Array.from( | ||
| { length: 1_100 }, | ||
| (_, index) => `value_${index}`, | ||
| ).join(", ")} FROM schema_prefix`; | ||
| const source = createIdentitySqlSource(tenKilobyteQuery); | ||
| const index = buildSqlStatementIndex( | ||
| source.analysisText, | ||
| dialect.lexicalProfile, | ||
| ); | ||
| const position = tenKilobyteQuery.length; | ||
| const slot = findSqlStatementSlot(index, position, "left"); | ||
| const aliasHeavyQuery = `SELECT * FROM ${Array.from( | ||
| { length: 1_000 }, | ||
| (_, aliasIndex) => `table_name alias_${aliasIndex}`, | ||
| ).join(", ")}, `; | ||
| const aliasHeavySource = createIdentitySqlSource(aliasHeavyQuery); | ||
| const aliasHeavyIndex = buildSqlStatementIndex( | ||
| aliasHeavySource.analysisText, | ||
| dialect.lexicalProfile, | ||
| ); | ||
| const aliasHeavyPosition = aliasHeavyQuery.length; | ||
| const aliasHeavySlot = findSqlStatementSlot( | ||
| aliasHeavyIndex, | ||
| aliasHeavyPosition, | ||
| "left", | ||
| ); | ||
|
|
||
| describe("query-site recognizer", () => { | ||
| bench("10 KiB active statement", () => { | ||
| recognizeSqlRelationQuerySite(source, slot, position, dialect); | ||
| }); | ||
|
|
||
| bench("1,000 classified aliases", () => { | ||
| recognizeSqlRelationQuerySite( | ||
| aliasHeavySource, | ||
| aliasHeavySlot, | ||
| aliasHeavyPosition, | ||
| dialect, | ||
| ); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.