Skip to content

Commit 4b3b621

Browse files
sahrizviclaude
andauthored
fix(validate): fold uppercase metadata to the engine's identifier case; skip existence checks without a schema (AltimateAI#1343)
* fix(validate): fold uppercase metadata to the engine's identifier case; skip existence checks without a schema `altimate_core_validate` rejected correct Snowflake SQL against real metadata. The engine compares an unquoted identifier in lowercase and a quoted one exactly; `schema_inspect` and `snowflake_get_table_stats` return UPPERCASE names, so every query came back ColumnNotFound — with the engine's own DidYouMean pointing at the same column in uppercase at confidence 1 — and uppercasing the SQL did not help because the engine lowercased it again. The model looped three or four validation rounds per warehouse demo before giving up on the validator (AltimateAI#1333). `normalizeSchemaContext` now folds an all-uppercase table or column name — the storage form of an identifier created unquoted — to lowercase before the schema reaches the engine. Mixed-case names were created quoted, must be referenced quoted, and are matched exactly by the engine, so they are left alone; lowercase names are already in the engine's form. Applies to both schema_context shapes. Without a schema the engine ran against the `_empty_` placeholder and reported every table as missing, while the tool's description promised existence checks are skipped. The handler now drops TableNotFound / ColumnNotFound findings when no schema was given and recomputes `valid` from what remains, so syntax and dialect errors still surface. Tests: the exact query and uppercase metadata from the issue validate (lower and upper SQL); a genuinely missing column is still reported; no schema → valid for a correct query, still invalid for a syntax error; fold and existence-classifier unit cases. Both guards were deleted once to confirm the tests fail. Closes AltimateAI#1333 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 * fix(validate): quoted uppercase references, fold collisions, table-less contexts Bot review on AltimateAI#1343, checked against the engine: it lowercases table keys at load, keeps column names as written, lowercases an unquoted reference and matches a quoted one exactly, and dedups columns case-insensitively (first wins) — so both spellings of a name cannot be emitted. - `foldQuotedIdentifierCase`: a quoted all-uppercase identifier in the SQL (`"ORDER_MONTH"`, dbt `quote_columns` / BI style on Snowflake) is lowercased inside its quotes when a schema is present, so it matches the folded metadata; same length, still quoted, string literals and comments stepped over, mixed-case left exact - A fold that would collide with an entry the schema already carries (`ORDERS` + `orders`, `FOO` + `foo` columns) keeps the name as written instead of overwriting; null-prototype maps so `__PROTO__` is an entry - `schemaProvided`: a `schema_context` counts only if it normalises to a table. `{ tables: {} }` / `{ users: {} }` used to fail the call outright ("Schema must define at least one table"); they now take the no-schema path - Test: engine-dependent modules imported lazily behind a `require.resolve` guard so the skip really skips; prior `ALTIMATE_TELEMETRY_DISABLED` restored; dispatcher reset after the suite; cases for each of the above Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 * fix(validate): fold both halves for every SQL-plus-schema operation, schema files too Codex review of AltimateAI#1343 (gpt-5.6-sol). - Only `validate` folded the SQL; the other operations that match SQL against a schema (lint, explain, check incl. lintDiff/base_sql, fix, policy, semantics, testgen, equivalence, rewrite, correct, grade, query_pii, column_lineage, track_lineage, complete, optimize_for_query, prune_schema) got the folded schema with unfolded SQL — the mismatch the fold exists to remove. `prepareSql` now hands every one of them the pair - The fold is explicit (`normalizeSchemaContext(ctx, { fold })`): schema-only operations (diff, export, fingerprint, classify, resolve_term) see the names as written - `schema_path` took the SQL half without the schema half: a JSON/YAML file is now normalised and folded like an inline context; a DDL file is loaded as-is and the SQL left alone - Lexer: BigQuery/Databricks backticks fold too; a doubled quote inside a name keeps it as written; dotted quoted names fold as one; `$tag$…$tag$` and `E'…'` (backslash escapes) are opaque spans - The tool decided `has_schema` on its own and reported "VALID" for a table-less context as if existence had been checked; the handler says it now. A failed schema load (`success: false`) is an engine failure, not a valid result - Tests for each; `isExistenceError` gets a code-only fixture Not changed: the fold is dialect-blind. On a lowercase-folding warehouse an uppercase metadata name can be a genuinely quoted identifier, and an unquoted reference to it then validates; the tool has no dialect input to scope by. Same class as the tradeoff already noted in `foldIdentifierCase`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 * fix(validate): fold only names the schema holds, one preparation per schema source Bot review of 8ecf029 on AltimateAI#1343. - The SQL fold touched every quoted all-uppercase token, and on MySQL/BigQuery/SQLite `"SHIPPED"` is a string literal: a query's values changed under validation. Only tokens whose lowercase form is a name the folded schema holds (table keys, each dotted segment, columns) are folded - `hasSchema` was not a fold flag: for a DDL file the head SQL was left as written but `base_sql` and lineage queries were folded, and the PII base comparison used the raw base. `prepareSql` exposes `foldSql`, the same preparation for any sibling SQL against that schema — identity for DDL — and `check` (lintDiff + PII subtraction), `equivalence` and `track_lineage` use it - `sql.analyze`, `sql.optimize`, `sql.fix`, `sql.rewrite`, `sql.diff` and `lineage.check` (`native/sql/register.ts`) match SQL against a schema too and were still on the unfolded resolver; they prepare the pair now - Test guard uses `require` (loads the binding) rather than `require.resolve`; the temp schema directory is removed; a comment named the wrong handler Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 * fix(validate): give generated SQL back in the caller's spelling; diff from raw inputs Bot review of 449513d on AltimateAI#1343 (third round). - The fold leaked into engine output: `sql.rewrite`/`fix`/`optimize` and the `altimate_core` rewrite/fix/correct/complete/optimize_for_query/testgen handlers returned SQL with the validation-time lowercase spelling, which a case-sensitive warehouse would not resolve. `prepareSql` records every token it folded and exposes `unfold`, which restores the caller's spelling in any string of the result (walking objects and arrays); those handlers use it - `sql.diff` rendered its text diff from the folded copies, hiding a case-only edit; it renders from the raw inputs and folds only for the equivalence check - The dollar-quote branch requires an identifier boundary (`foo$t$` is an identifier, not a string start) - A JSON/YAML schema file that parses to zero tables takes the no-schema path instead of failing in `Schema.fromJson` - Tests: the sql.*/lineage case uses unquoted lowercase references and asserts on the raw lineage source (an unfolded resolver fails it); generated-SQL spelling across six handlers (disabling `unfold` fails it); the diff case; the dollar boundary; the zero-table file Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 * test(validate): assert success before the spelling checks; do not endorse the quoted-lowercase equivalence (bot review) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 * test(validate): sql.fix reports success=false with a fixed_sql when nothing needed fixing Guard on "the handler ran and returned SQL" instead. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012Q51zFUmPg1WwtS5CrGJE6 --------- Co-authored-by: Claude Opus 5 <[email protected]>
1 parent 13cab51 commit 4b3b621

5 files changed

Lines changed: 729 additions & 81 deletions

File tree

‎packages/opencode/src/altimate/native/altimate-core.ts‎

Lines changed: 80 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,23 @@
1111
import * as core from "@altimateai/altimate-core"
1212
import { EngineCoerce } from "./engine-coerce"
1313
import { register } from "./dispatcher"
14-
import { schemaOrEmpty, resolveSchema, SchemaResolver } from "./schema-resolver"
14+
import { schemaOrEmpty, SchemaResolver, prepareSql } from "./schema-resolver"
1515
import type { AltimateCoreResult } from "./types"
1616

1717
// ---------------------------------------------------------------------------
1818
// Helpers
1919
// ---------------------------------------------------------------------------
2020

2121
/** Spread a rich TypeScript object into a plain Record for the data field. */
22+
// altimate_change start — the engine's existence findings, which mean nothing without a schema
23+
const EXISTENCE_CODES = new Set(["E001", "E002"])
24+
const EXISTENCE_KINDS = new Set(["TableNotFound", "ColumnNotFound"])
25+
export function isExistenceError(err: unknown): boolean {
26+
const e = err as { code?: unknown; kind?: { type?: unknown } } | null
27+
return EXISTENCE_CODES.has(String(e?.code)) || EXISTENCE_KINDS.has(String(e?.kind?.type))
28+
}
29+
// altimate_change end
30+
2231
function toData(obj: unknown): Record<string, unknown> {
2332
if (obj === null || obj === undefined) return {}
2433
if (typeof obj !== "object") return { value: obj }
@@ -89,9 +98,22 @@ export function registerAll(): void {
8998
// 1. altimate_core.validate
9099
register("altimate_core.validate", async (params) => {
91100
try {
92-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
93-
const raw = await core.validate(params.sql, schema)
101+
const { sql, schema, hasSchema } = prepareSql(params.sql, params.schema_path, params.schema_context)
102+
const raw = await core.validate(sql, schema)
94103
const data = toData(raw)
104+
// altimate_change start — without a schema the engine still runs against the
105+
// `_empty_` placeholder and reports every table as missing. The tool promises that
106+
// existence checks are skipped when no schema is given, so those findings are
107+
// dropped here and `valid` is recomputed from what remains (syntax, dialect).
108+
// Said back to the tool, which used to decide it separately (and differently).
109+
;(data as Record<string, unknown>).has_schema = hasSchema
110+
const errors = (data as { errors?: unknown }).errors
111+
if (!hasSchema && Array.isArray(errors)) {
112+
const kept = errors.filter((err) => !isExistenceError(err))
113+
;(data as Record<string, unknown>).errors = kept
114+
;(data as Record<string, unknown>).valid = kept.length === 0
115+
}
116+
// altimate_change end
95117
return ok(true, data)
96118
} catch (e) {
97119
return fail(e)
@@ -101,8 +123,8 @@ export function registerAll(): void {
101123
// 2. altimate_core.lint
102124
register("altimate_core.lint", async (params) => {
103125
try {
104-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
105-
const raw = core.lint(params.sql, schema)
126+
const { sql, schema } = prepareSql(params.sql, params.schema_path, params.schema_context)
127+
const raw = core.lint(sql, schema)
106128
const data = toData(raw)
107129
return ok(true, data)
108130
} catch (e) {
@@ -156,8 +178,8 @@ export function registerAll(): void {
156178
// 5. altimate_core.explain
157179
register("altimate_core.explain", async (params) => {
158180
try {
159-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
160-
const raw = await core.explain(params.sql, schema)
181+
const { sql, schema } = prepareSql(params.sql, params.schema_path, params.schema_context)
182+
const raw = await core.explain(sql, schema)
161183
const data = toData(raw)
162184
return ok(true, data)
163185
} catch (e) {
@@ -168,32 +190,37 @@ export function registerAll(): void {
168190
// 6. altimate_core.check — composite: validate + lint + scan_sql
169191
register("altimate_core.check", async (params) => {
170192
try {
171-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
193+
const { sql, schema, foldSql } = prepareSql(params.sql, params.schema_path, params.schema_context)
194+
// The base SQL is matched against the same schema (lintDiff, the PII subtraction),
195+
// so it gets exactly the preparation the head SQL got.
196+
const baseSql = params.base_sql ? foldSql(params.base_sql) : params.base_sql
172197
// NOTE: validation is deliberately NOT diff-scoped against base_sql.
173198
// The engine validates fail-fast (only the FIRST error is reported), so
174199
// subtracting base errors can hide genuinely new breakage behind a
175200
// pre-existing one. Re-reporting a pre-existing error is the safe mode.
176-
const validation: Record<string, unknown> = toData(await core.validate(params.sql, schema))
201+
const validation: Record<string, unknown> = toData(await core.validate(sql, schema))
177202
// Diff-scoped lint: when a base SQL is supplied, core returns only the
178203
// findings the change INTRODUCED (pre-existing issues in the file are
179204
// dropped) — the structural comparison stays in the AST engine.
180205
const lintResult =
181-
params.base_sql && typeof core.lintDiff === "function"
206+
baseSql && typeof core.lintDiff === "function"
182207
? core.lintDiff(
183-
params.sql,
184-
params.base_sql,
208+
sql,
209+
baseSql,
185210
// lintDiff takes SchemaDefinition JSON — normalize flat agent
186211
// schemas too, or the whole composite throws "missing field tables".
187-
params.schema_context ? SchemaResolver.normalizeSchemaContext(params.schema_context) : undefined,
212+
params.schema_context
213+
? SchemaResolver.normalizeSchemaContext(params.schema_context, { fold: true })
214+
: undefined,
188215
)
189-
: core.lint(params.sql, schema)
216+
: core.lint(sql, schema)
190217
// Diff-scope safety like lint: threats present in the base SQL are
191218
// pre-existing, not introduced by this change. Subtract as a MULTISET on
192219
// (rule, matched_pattern) — one base occurrence consumes one head
193220
// occurrence, so a PR that ADDS a second identical injection still
194221
// reports it. Recompute safe/risk_score from the surviving threats so a
195222
// fully pre-existing threat set doesn't leave a stale unsafe verdict.
196-
let safety: Record<string, unknown> = toData(core.scanSql(params.sql))
223+
let safety: Record<string, unknown> = toData(core.scanSql(sql))
197224
if (params.base_sql) {
198225
try {
199226
const baseCounts = new Map<string, number>()
@@ -238,16 +265,16 @@ export function registerAll(): void {
238265
// must not fail the whole composite.
239266
let pii: Record<string, unknown>
240267
try {
241-
pii = toData(core.checkQueryPii(params.sql, schema))
242-
if (params.base_sql && Array.isArray(pii.pii_columns) && (pii.pii_columns as any[]).length) {
268+
pii = toData(core.checkQueryPii(sql, schema))
269+
if (baseSql && Array.isArray(pii.pii_columns) && (pii.pii_columns as any[]).length) {
243270
try {
244271
// Pre-existing exposures are not introduced by this change. The
245272
// identity INCLUDES the sorted output aliases — adding or renaming
246273
// a SELECT-list alias for an already-exposed column is a NEW
247274
// output exposure and must still surface.
248275
const exposureKey = (c: any) =>
249276
`${c.table}|${c.column}|${[...(c.query_targets ?? [])].sort().join(",")}`
250-
const baseExposed = new Set(core.checkQueryPii(params.base_sql, schema).pii_columns.map(exposureKey))
277+
const baseExposed = new Set(core.checkQueryPii(baseSql, schema).pii_columns.map(exposureKey))
251278
const remaining = (pii.pii_columns as any[]).filter((c: any) => !baseExposed.has(exposureKey(c)))
252279
pii = {
253280
...pii,
@@ -358,9 +385,10 @@ export function registerAll(): void {
358385
// 7. altimate_core.fix
359386
register("altimate_core.fix", async (params) => {
360387
try {
361-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
362-
const raw = await core.fix(params.sql, schema, params.max_iterations ?? undefined)
363-
const data = toData(raw)
388+
const { sql, schema, unfold } = prepareSql(params.sql, params.schema_path, params.schema_context)
389+
const raw = await core.fix(sql, schema, params.max_iterations ?? undefined)
390+
// Generated SQL goes back in the caller's spelling (see `PreparedSql.unfold`).
391+
const data = unfold(toData(raw))
364392
return ok(true, data)
365393
} catch (e) {
366394
return fail(e)
@@ -370,8 +398,8 @@ export function registerAll(): void {
370398
// 8. altimate_core.policy
371399
register("altimate_core.policy", async (params) => {
372400
try {
373-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
374-
const raw = await core.checkPolicy(params.sql, schema, params.policy_json)
401+
const { sql, schema } = prepareSql(params.sql, params.schema_path, params.schema_context)
402+
const raw = await core.checkPolicy(sql, schema, params.policy_json)
375403
const data = toData(raw)
376404
return ok(true, data)
377405
} catch (e) {
@@ -382,8 +410,8 @@ export function registerAll(): void {
382410
// 9. altimate_core.semantics
383411
register("altimate_core.semantics", async (params) => {
384412
try {
385-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
386-
const raw = await core.checkSemantics(params.sql, schema)
413+
const { sql, schema } = prepareSql(params.sql, params.schema_path, params.schema_context)
414+
const raw = await core.checkSemantics(sql, schema)
387415
const data = toData(raw)
388416
return ok(true, data)
389417
} catch (e) {
@@ -394,9 +422,9 @@ export function registerAll(): void {
394422
// 10. altimate_core.testgen
395423
register("altimate_core.testgen", async (params) => {
396424
try {
397-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
398-
const raw = core.generateTests(params.sql, schema)
399-
return ok(true, toData(raw))
425+
const { sql, schema, unfold } = prepareSql(params.sql, params.schema_path, params.schema_context)
426+
const raw = core.generateTests(sql, schema)
427+
return ok(true, unfold(toData(raw)))
400428
} catch (e) {
401429
return fail(e)
402430
}
@@ -405,14 +433,14 @@ export function registerAll(): void {
405433
// 11. altimate_core.equivalence
406434
register("altimate_core.equivalence", async (params) => {
407435
try {
408-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
436+
const one = prepareSql(params.sql1, params.schema_path, params.schema_context)
409437
// Pass the optional dialect hint so dialect-specific compiled warehouse SQL
410438
// (e.g. Snowflake semi-structured `col:field`) parses and the pair is
411439
// decidable instead of abstaining on a syntax error. Supported since
412440
// [email protected]. dialectHint coerces "" (the ReviewConfig default)
413441
// to undefined: the engine throws on an unknown dialect "", and "" must
414442
// mean auto-detect, not a real dialect.
415-
const raw = await core.checkEquivalence(params.sql1, params.sql2, schema, EngineCoerce.dialectHint(params.dialect))
443+
const raw = await core.checkEquivalence(one.sql, one.foldSql(params.sql2), one.schema, EngineCoerce.dialectHint(params.dialect))
416444
const data = toData(raw)
417445
return ok(true, data)
418446
} catch (e) {
@@ -449,9 +477,9 @@ export function registerAll(): void {
449477
// 14. altimate_core.rewrite
450478
register("altimate_core.rewrite", async (params) => {
451479
try {
452-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
453-
const raw = core.rewrite(params.sql, schema)
454-
return ok(true, toData(raw))
480+
const { sql, schema, unfold } = prepareSql(params.sql, params.schema_path, params.schema_context)
481+
const raw = core.rewrite(sql, schema)
482+
return ok(true, unfold(toData(raw)))
455483
} catch (e) {
456484
return fail(e)
457485
}
@@ -460,9 +488,9 @@ export function registerAll(): void {
460488
// 15. altimate_core.correct
461489
register("altimate_core.correct", async (params) => {
462490
try {
463-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
464-
const raw = await core.correct(params.sql, schema)
465-
const data = toData(raw)
491+
const { sql, schema, unfold } = prepareSql(params.sql, params.schema_path, params.schema_context)
492+
const raw = await core.correct(sql, schema)
493+
const data = unfold(toData(raw))
466494
return ok(true, data)
467495
} catch (e) {
468496
return fail(e)
@@ -472,8 +500,8 @@ export function registerAll(): void {
472500
// 16. altimate_core.grade
473501
register("altimate_core.grade", async (params) => {
474502
try {
475-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
476-
const raw = await core.evaluate(params.sql, schema)
503+
const { sql, schema } = prepareSql(params.sql, params.schema_path, params.schema_context)
504+
const raw = await core.evaluate(sql, schema)
477505
const data = toData(raw)
478506
// EvalResult embeds a full safety scan — redact its threat echoes too
479507
// (the CLI grade check renders nested threat messages).
@@ -500,8 +528,8 @@ export function registerAll(): void {
500528
// 18. altimate_core.query_pii
501529
register("altimate_core.query_pii", async (params) => {
502530
try {
503-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
504-
const raw = core.checkQueryPii(params.sql, schema)
531+
const { sql, schema } = prepareSql(params.sql, params.schema_path, params.schema_context)
532+
const raw = core.checkQueryPii(sql, schema)
505533
return ok(true, toData(raw))
506534
} catch (e) {
507535
return fail(e)
@@ -524,8 +552,8 @@ export function registerAll(): void {
524552
// 20. altimate_core.column_lineage
525553
register("altimate_core.column_lineage", async (params) => {
526554
try {
527-
const schema = resolveSchema(params.schema_path, params.schema_context)
528-
const raw = core.columnLineage(params.sql, EngineCoerce.dialectHint(params.dialect), schema ?? undefined)
555+
const { sql, schema, hasSchema } = prepareSql(params.sql, params.schema_path, params.schema_context)
556+
const raw = core.columnLineage(sql, EngineCoerce.dialectHint(params.dialect), hasSchema ? schema : undefined)
529557
return ok(true, toData(raw))
530558
} catch (e) {
531559
return fail(e)
@@ -535,8 +563,8 @@ export function registerAll(): void {
535563
// 21. altimate_core.track_lineage
536564
register("altimate_core.track_lineage", async (params) => {
537565
try {
538-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
539-
const raw = core.trackLineage(params.queries, schema)
566+
const { schema, foldSql } = prepareSql("", params.schema_path, params.schema_context)
567+
const raw = core.trackLineage(params.queries.map(foldSql), schema)
540568
return ok(true, toData(raw))
541569
} catch (e) {
542570
return fail(e)
@@ -577,9 +605,9 @@ export function registerAll(): void {
577605
// 25. altimate_core.complete
578606
register("altimate_core.complete", async (params) => {
579607
try {
580-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
581-
const raw = core.complete(params.sql, params.cursor_pos, schema)
582-
return ok(true, toData(raw))
608+
const { sql, schema, unfold } = prepareSql(params.sql, params.schema_path, params.schema_context)
609+
const raw = core.complete(sql, params.cursor_pos, schema)
610+
return ok(true, unfold(toData(raw)))
583611
} catch (e) {
584612
return fail(e)
585613
}
@@ -599,9 +627,9 @@ export function registerAll(): void {
599627
// 27. altimate_core.optimize_for_query
600628
register("altimate_core.optimize_for_query", async (params) => {
601629
try {
602-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
603-
const raw = core.optimizeForQuery(params.sql, schema)
604-
return ok(true, toData(raw))
630+
const { sql, schema, unfold } = prepareSql(params.sql, params.schema_path, params.schema_context)
631+
const raw = core.optimizeForQuery(sql, schema)
632+
return ok(true, unfold(toData(raw)))
605633
} catch (e) {
606634
return fail(e)
607635
}
@@ -610,8 +638,8 @@ export function registerAll(): void {
610638
// 28. altimate_core.prune_schema
611639
register("altimate_core.prune_schema", async (params) => {
612640
try {
613-
const schema = schemaOrEmpty(params.schema_path, params.schema_context)
614-
const raw = core.pruneSchema(params.sql, schema)
641+
const { sql, schema } = prepareSql(params.sql, params.schema_path, params.schema_context)
642+
const raw = core.pruneSchema(sql, schema)
615643
return ok(true, toData(raw))
616644
} catch (e) {
617645
return fail(e)

0 commit comments

Comments
 (0)