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:
Studio 2026-12-01 09:39:58 -05:00
parent 94d8631d40
commit 98451ee07c
2 changed files with 75 additions and 0 deletions

View file

@ -522,6 +522,7 @@ const JOIN_MODIFIER_KEYWORDS: ReadonlySet<string> = new Set([
'LEFT',
'NATURAL',
'OUTER',
'POSITIONAL',
'RIGHT',
'SEMI',
]);
@ -1065,6 +1066,14 @@ function validateExpressionSlice(
continue;
}
// Fail closed if an unparsed JOIN token appears inside an expression or clause tail.
if (tok.kind === 'word' && tok.upper === 'JOIN') {
throw new FeatureLibraryError(
'INVALID_SQL_STATEMENT',
'Unexpected JOIN outside a parsed FROM/JOIN clause in feature SQL.'
);
}
// Callable function check: <word|quoted_ident> followed by '('.
if (
(tok.kind === 'word' || tok.kind === 'quoted_ident') &&
@ -1373,6 +1382,19 @@ function validateSelectBranch(
}
break;
}
if (pos < end) {
const afterFrom = tokens[pos] as SqlToken;
if (
afterFrom.kind !== 'word' ||
!CLAUSE_TERMINATOR_KEYWORDS.has(afterFrom.upper) ||
afterFrom.upper === 'FROM'
) {
throw new FeatureLibraryError(
'INVALID_SQL_STATEMENT',
`Unexpected token "${afterFrom.raw}" after FROM/JOIN clause in feature SQL.`
);
}
}
continue;
}