Skip to content

Commit 8fc0a97

Browse files
committed
fix(vnext): authenticate relation continuations
1 parent 12c7ac3 commit 8fc0a97

3 files changed

Lines changed: 643 additions & 86 deletions

File tree

src/vnext/__tests__/query-site.bench.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import {
1111
} from "../statement-index.js";
1212

1313
const dialect: SqlQuerySiteDialect = {
14+
classifyRelationAlias: (rawAlias) => ({
15+
status: "identifier",
16+
value: rawAlias,
17+
}),
1418
decodeRelationPath: (rawPath, cursorOffset) => ({
1519
finalSegment: { from: 0, to: rawPath.length },
1620
prefix: {
@@ -23,6 +27,7 @@ const dialect: SqlQuerySiteDialect = {
2327
}),
2428
lexicalProfile: DUCKDB_SQL_LEXICAL_PROFILE,
2529
maximumPathDepth: 16,
30+
supportsNaturalJoin: true,
2631
};
2732
const tenKilobyteQuery = `SELECT ${Array.from(
2833
{ length: 1_100 },
@@ -35,9 +40,33 @@ const index = buildSqlStatementIndex(
3540
);
3641
const position = tenKilobyteQuery.length;
3742
const slot = findSqlStatementSlot(index, position, "left");
43+
const aliasHeavyQuery = `SELECT * FROM ${Array.from(
44+
{ length: 1_000 },
45+
(_, aliasIndex) => `table_name alias_${aliasIndex}`,
46+
).join(", ")}, `;
47+
const aliasHeavySource = createIdentitySqlSource(aliasHeavyQuery);
48+
const aliasHeavyIndex = buildSqlStatementIndex(
49+
aliasHeavySource.analysisText,
50+
dialect.lexicalProfile,
51+
);
52+
const aliasHeavyPosition = aliasHeavyQuery.length;
53+
const aliasHeavySlot = findSqlStatementSlot(
54+
aliasHeavyIndex,
55+
aliasHeavyPosition,
56+
"left",
57+
);
3858

3959
describe("query-site recognizer", () => {
4060
bench("10 KiB active statement", () => {
4161
recognizeSqlRelationQuerySite(source, slot, position, dialect);
4262
});
63+
64+
bench("1,000 classified aliases", () => {
65+
recognizeSqlRelationQuerySite(
66+
aliasHeavySource,
67+
aliasHeavySlot,
68+
aliasHeavyPosition,
69+
dialect,
70+
);
71+
});
4372
});

0 commit comments

Comments
 (0)