@@ -11,6 +11,10 @@ import {
1111} from "../statement-index.js" ;
1212
1313const 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} ;
2732const tenKilobyteQuery = `SELECT ${ Array . from (
2833 { length : 1_100 } ,
@@ -35,9 +40,33 @@ const index = buildSqlStatementIndex(
3540) ;
3641const position = tenKilobyteQuery . length ;
3742const 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
3959describe ( "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