T-139: M2.4a — Versioned Feature Library core: declarative DuckDB SQL feature definitions + registerSignal registry + versioned Parquet batch-plan runner over an injected DuckDbExecutor in libs/research/src/feature-library.ts (pure, no new deps)
This commit is contained in:
parent
f86e520dec
commit
1bbe88947d
2 changed files with 74 additions and 6 deletions
|
|
@ -1009,6 +1009,25 @@ function extractProjectionOutputName(tokens: readonly SqlToken[], start: number,
|
|||
);
|
||||
}
|
||||
|
||||
function hasTopLevelSetOperator(tokens: readonly SqlToken[], start: number, end: number): boolean {
|
||||
let depth = 0;
|
||||
for (let i = start; i < end; i += 1) {
|
||||
const tok = tokens[i] as SqlToken;
|
||||
if (tok.kind === 'lparen') {
|
||||
depth += 1;
|
||||
} else if (tok.kind === 'rparen') {
|
||||
depth -= 1;
|
||||
} else if (
|
||||
depth === 0 &&
|
||||
tok.kind === 'word' &&
|
||||
(tok.upper === 'UNION' || tok.upper === 'INTERSECT' || tok.upper === 'EXCEPT')
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function validateExpressionSlice(
|
||||
tokens: readonly SqlToken[],
|
||||
start: number,
|
||||
|
|
@ -1019,13 +1038,15 @@ function validateExpressionSlice(
|
|||
while (i < end) {
|
||||
const tok = tokens[i] as SqlToken;
|
||||
|
||||
// Nested subquery: (SELECT ...) or (WITH ...); reject DuckDB FROM-first / TABLE subqueries.
|
||||
// Nested subquery: (SELECT ...), (WITH ...), or compound subquery ((SELECT ...) UNION ...);
|
||||
// reject DuckDB FROM-first / TABLE subqueries.
|
||||
if (tok.kind === 'lparen') {
|
||||
const closeIdx = findMatchingParen(tokens, i, end);
|
||||
const innerFirst = tokens[i + 1];
|
||||
if (
|
||||
innerFirst?.kind === 'word' &&
|
||||
(innerFirst.upper === 'SELECT' || innerFirst.upper === 'WITH')
|
||||
(innerFirst?.kind === 'word' &&
|
||||
(innerFirst.upper === 'SELECT' || innerFirst.upper === 'WITH')) ||
|
||||
hasTopLevelSetOperator(tokens, i + 1, closeIdx)
|
||||
) {
|
||||
validateQuerySlice(tokens, i + 1, closeIdx, inScopeCtes, false);
|
||||
i = closeIdx + 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue