Skip to content

fix: pass warehouse dialect to altimate-core tools instead of hardcoding snowflake#550

Open
VJ-yadav wants to merge 5 commits intoAltimateAI:mainfrom
VJ-yadav:fix/hardcoded-snowflake-dialect
Open

fix: pass warehouse dialect to altimate-core tools instead of hardcoding snowflake#550
VJ-yadav wants to merge 5 commits intoAltimateAI:mainfrom
VJ-yadav:fix/hardcoded-snowflake-dialect

Conversation

@VJ-yadav
Copy link
Copy Markdown
Contributor

@VJ-yadav VJ-yadav commented Mar 28, 2026

Summary

Fixes #455 — Adds optional dialect parameter (default: "snowflake") to all 8 altimate-core tools that were hardcoding it:

  • altimate-core-validate.ts, fix.ts, correct.ts, semantics.ts, equivalence.ts, policy.ts, check.ts
  • impact-analysis.ts

Each tool now accepts dialect via zod schema, passes it to the Dispatcher call, and includes it in telemetry metadata. Follows the pattern already established in sql-analyze.ts, sql-optimize.ts, and schema-diff.ts.

Type interfaces updated in types.ts. Tests updated to pass dialect explicitly.

Test Plan

  • bun turbo typecheck — 5/5 packages pass
  • bun test test/altimate/schema-finops-dbt.test.ts — 56 pass
  • bun test test/altimate/tool-error-propagation.test.ts — 22 pass
  • Manual: run tools with dialect: "postgres" and verify it reaches telemetry

Checklist

  • Follows existing pattern from sql-analyze/optimize/schema-diff
  • Default value preserves backward compatibility
  • No breaking changes
  • Tests updated

Summary by CodeRabbit

  • New Features

    • Altimate tools (validate, check, fix, correct, policy, semantics, equivalence) accept an optional dialect parameter (default "snowflake").
    • Tool responses/metadata now include the provided dialect for all outcomes.
    • Schema resolution fallback parsing now respects the provided dialect for consistent SQL parsing/validation.
  • Tests

    • Tests updated to include and assert dialect handling across affected tools.

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 19f10da0-b2ea-4d8e-ac6e-661be6008eef

📥 Commits

Reviewing files that changed from the base of the PR and between 10f47a1 and d2ad6ac.

📒 Files selected for processing (13)
  • packages/opencode/src/altimate/native/altimate-core.ts
  • packages/opencode/src/altimate/native/schema-resolver.ts
  • packages/opencode/src/altimate/native/types.ts
  • packages/opencode/src/altimate/tools/altimate-core-check.ts
  • packages/opencode/src/altimate/tools/altimate-core-correct.ts
  • packages/opencode/src/altimate/tools/altimate-core-equivalence.ts
  • packages/opencode/src/altimate/tools/altimate-core-fix.ts
  • packages/opencode/src/altimate/tools/altimate-core-policy.ts
  • packages/opencode/src/altimate/tools/altimate-core-semantics.ts
  • packages/opencode/src/altimate/tools/altimate-core-validate.ts
  • packages/opencode/src/altimate/tools/impact-analysis.ts
  • packages/opencode/test/altimate/e2e-tool-errors.ts
  • packages/opencode/test/altimate/tool-error-propagation.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/opencode/src/altimate/native/altimate-core.ts
🚧 Files skipped from review as they are similar to previous changes (12)
  • packages/opencode/src/altimate/tools/impact-analysis.ts
  • packages/opencode/src/altimate/tools/altimate-core-semantics.ts
  • packages/opencode/src/altimate/tools/altimate-core-validate.ts
  • packages/opencode/src/altimate/native/schema-resolver.ts
  • packages/opencode/src/altimate/tools/altimate-core-fix.ts
  • packages/opencode/src/altimate/tools/altimate-core-equivalence.ts
  • packages/opencode/test/altimate/tool-error-propagation.test.ts
  • packages/opencode/src/altimate/tools/altimate-core-correct.ts
  • packages/opencode/src/altimate/tools/altimate-core-check.ts
  • packages/opencode/src/altimate/native/types.ts
  • packages/opencode/test/altimate/e2e-tool-errors.ts
  • packages/opencode/src/altimate/tools/altimate-core-policy.ts

📝 Walkthrough

Walkthrough

Adds an optional dialect parameter (default "snowflake") to multiple Altimate core tools and native types, propagates it through Dispatcher calls and returned telemetry metadata, and updates schema resolution to accept an optional dialect for the fallback empty-schema parse.

Changes

Cohort / File(s) Summary
Type Definitions
packages/opencode/src/altimate/native/types.ts
Added optional dialect?: string to dispatcher parameter interfaces for Altimate core methods (AltimateCoreValidateParams, AltimateCoreCheckParams, AltimateCoreFixParams, AltimateCorePolicyParams, AltimateCoreSemanticsParams, AltimateCoreEquivalenceParams, AltimateCoreCorrectParams).
Core Tools
packages/opencode/src/altimate/tools/altimate-core-{validate,check,fix,correct,semantics,equivalence,policy}.ts
Each tool now accepts dialect?: string (default "snowflake"), forwards dialect to Dispatcher.call(...), and includes dialect in returned metadata for success, no-schema, and error paths.
Impact Analysis Tool
packages/opencode/src/altimate/tools/impact-analysis.ts
Includes dialect: args.dialect in metadata across NO MANIFEST, MODEL NOT FOUND, success, and ERROR paths.
Native Handlers & Schema Resolver
packages/opencode/src/altimate/native/altimate-core.ts, packages/opencode/src/altimate/native/schema-resolver.ts
Native handlers pass params.dialect into schemaOrEmpty; schemaOrEmpty signature updated to accept dialect?: string and forwards it to fallback Schema.fromDdl(...).
Tests
packages/opencode/test/altimate/e2e-tool-errors.ts, packages/opencode/test/altimate/tool-error-propagation.test.ts
Test payloads updated to include dialect: "snowflake" for tool execute() calls; assertions updated to reflect metadata containing dialect.

Sequence Diagram(s)

sequenceDiagram
  participant Tool as Tool (caller)
  participant Dispatcher as Dispatcher
  participant Native as Native Handler
  participant Resolver as schemaOrEmpty
  participant Core as Altimate Core

  Tool->>Dispatcher: call("altimate_core.*", { sql, schema_path, schema_context, dialect })
  Dispatcher->>Native: invoke handler with params (including dialect)
  Native->>Resolver: schemaOrEmpty(schema_path, schema_context, dialect)
  alt schema resolved
    Resolver->>Native: Schema (from resolveSchema)
  else fallback used
    Resolver->>Resolver: Schema.fromDdl(..., dialect)
    Resolver->>Native: fallback Schema
  end
  Native->>Core: core.*(sql, schema, ...)
  Core-->>Native: result
  Native-->>Dispatcher: wrapped result (includes metadata.dialect)
  Dispatcher-->>Tool: response (includes metadata.dialect)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

contributor

Suggested reviewers

  • mdesmet
  • kulvirgit

Poem

🐰 I hopped a tiny change today,
A dialect tucked where SQLs play,
Snowflake by default, ready to roam,
It travels through dispatcher and schema home,
Metadata hums — new voices may say!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description lacks the required 'PINEAPPLE' marker at the top as specified in the repository template for AI-generated contributions. Add 'PINEAPPLE' at the very top of the PR description before the Summary section, as required by the repository template for AI contributions.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: adding dialect parameter support to altimate-core tools instead of hardcoding Snowflake.
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from issue #455: dialect parameter added to all 8 tools, passed to Dispatcher calls, included in telemetry metadata, with updated types and tests.
Out of Scope Changes check ✅ Passed All changes are directly scoped to requirements in issue #455: adding dialect parameter to specified tools, updating type interfaces, and modifying tests accordingly. No extraneous changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@dev-punia-altimate
Copy link
Copy Markdown

🤖 Behavioral Analysis — 4 Finding(s)

🟡 Warnings (3)

  • FINDING-001 packages/opencode/src/altimate/tools/altimate-core-validate.ts:20 [logic_error]
    The early-return 'NO SCHEMA' path (the if (noSchema) guard before the try block) returns metadata without the dialect field, while all other return paths in this file are updated to include dialect. When noSchema is true the function returns metadata: { success: false, valid: false, has_schema: false, error } — omitting dialect. This is inconsistent with the PR's goal of including dialect in all telemetry metadata; the most common early-failure case (no schema provided) will have dialect missing.

  • FINDING-002 packages/opencode/src/altimate/tools/altimate-core-semantics.ts:21 [logic_error]
    Same issue as FINDING-001: the early-return 'NO SCHEMA' path (if (!hasSchema) guard before the try block) returns metadata without dialect. The PR only adds dialect to the Dispatcher.call, success, and catch paths. The early-return returns metadata: { success: false, valid: false, issue_count: 0, has_schema: false, error } — missing dialect.

  • FINDING-003 packages/opencode/src/altimate/tools/altimate-core-equivalence.ts:22 [logic_error]
    Same issue: the early-return 'NO SCHEMA' path returns metadata without dialect. The if (!hasSchema) guard returns metadata: { success: false, equivalent: false, has_schema: false, error } — missing dialect. The PR adds dialect to the other paths but misses this one.

🔵 Nits (1)

  • FINDING-004 packages/opencode/src/altimate/tools/impact-analysis.ts:38 [consistency]
    The two operational early-return paths in impact-analysis.ts — 'NO MANIFEST' (when manifest is empty) and 'MODEL NOT FOUND' (when target model is not found in the DAG) — return bare metadata: { success: false } objects without dialect or other telemetry fields. The PR adds dialect to the success and catch paths but does not update these early returns. Low severity since these are configuration errors rather than SQL analysis failures, but inconsistent with the PR's intent.

Analysis run | Powered by QA Autopilot

@dev-punia-altimate
Copy link
Copy Markdown

Auto-fixed 4 finding(s)

  • FINDING-001
  • FINDING-002
  • FINDING-003
  • FINDING-004

@gitguardian
Copy link
Copy Markdown

gitguardian bot commented Mar 31, 2026

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/opencode/src/altimate/tools/altimate-core-correct.ts`:
- Around line 22-27: The six native handlers drop the dialect despite it being
passed in params; update altimate_core.validate, altimate_core.check,
altimate_core.fix, altimate_core.semantics, altimate_core.equivalence, and
altimate_core.correct so their core calls include the dialect (use
params.dialect || undefined) when invoking core.validate, core.fix,
core.checkSemantics, core.checkEquivalence, and core.correct respectively;
ensure each call signature matches the core function's dialect parameter
position and propagate params.dialect in the same pattern used by other handlers
(e.g., formatSql, extractMetadata, compareQueries).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 46aff016-36ac-4072-a604-a460e3a35cc1

📥 Commits

Reviewing files that changed from the base of the PR and between 5d0ada3 and 3ff930e.

📒 Files selected for processing (11)
  • packages/opencode/src/altimate/native/types.ts
  • packages/opencode/src/altimate/tools/altimate-core-check.ts
  • packages/opencode/src/altimate/tools/altimate-core-correct.ts
  • packages/opencode/src/altimate/tools/altimate-core-equivalence.ts
  • packages/opencode/src/altimate/tools/altimate-core-fix.ts
  • packages/opencode/src/altimate/tools/altimate-core-policy.ts
  • packages/opencode/src/altimate/tools/altimate-core-semantics.ts
  • packages/opencode/src/altimate/tools/altimate-core-validate.ts
  • packages/opencode/src/altimate/tools/impact-analysis.ts
  • packages/opencode/test/altimate/e2e-tool-errors.ts
  • packages/opencode/test/altimate/tool-error-propagation.test.ts

@VJ-yadav VJ-yadav force-pushed the fix/hardcoded-snowflake-dialect branch from 3ff930e to 6edf2e5 Compare April 3, 2026 06:15
@dev-punia-altimate
Copy link
Copy Markdown

❌ Tests — Failures Detected

TypeScript — 15 failure(s)

  • connection_refused [2.80ms]
  • timeout [2.60ms]
  • permission_denied [2.82ms]
  • parse_error [2.38ms]
  • oom [2.70ms]
  • network_error [2.46ms]
  • auth_failure [2.69ms]
  • rate_limit [2.87ms]
  • internal_error [2.76ms]
  • empty_error [0.24ms]
  • connection_refused [0.15ms]
  • timeout [0.08ms]
  • permission_denied [0.08ms]
  • parse_error [0.08ms]
  • oom [0.07ms]

cc @VJ-yadav
Tested at 6edf2e59 | Run log | Powered by QA Autopilot

@anandgupta42
Copy link
Copy Markdown
Contributor

Review — Ready for merge

Scope: Fixes #455 — replaces hardcoded dialect: "snowflake" across 8 altimate-core tools with an explicit parameter (default "snowflake" for backward compat). Follows the established pattern from sql-analyze.ts/sql-optimize.ts/schema-diff.ts.

Analysis

  • Tools updated: altimate-core-{validate,fix,correct,semantics,equivalence,policy,check}.ts + impact-analysis.ts
  • Each tool now: (1) zod schema accepts optional dialect, (2) Dispatcher call passes it, (3) telemetry metadata includes it for sql_quality event completeness
  • Type interfaces in types.ts updated accordingly
  • Default "snowflake" preserves backward compat — no breaking change
  • 4 review findings from the dev-punia-altimate behavioral analyzer were auto-fixed (FINDING-001…004, including the noSchema early-return path that originally missed the dialect field in metadata)

Files changed: 13 files, +108 −46

CI status (commit 6edf2e59)

  • ✅ TypeScript, anti-slop, check-standards, check-compliance, Marker Guard, GitGuardian — all green
  • ✅ CodeRabbit: "No actionable comments" after auto-fixes
  • ⚠️ centralized-test-results — same pre-existing 15-failure flakiness as every other open PR in this batch

Recommendation
Ready for merge — rebase on main (BEHIND). This unblocks sql_quality telemetry dialect attribution for 8 tools that were silently mis-reporting as Snowflake. Fixes a clean observability gap.

cc @anandgupta42 — ready for /release once rebased.

VJ-yadav and others added 3 commits April 4, 2026 23:40
…ing snowflake

Add optional `dialect` parameter (default: "snowflake") to all 8
altimate-core tools that were missing it:

- altimate-core-validate, fix, correct, semantics,
  equivalence, policy, check, and impact-analysis

Each tool now:
1. Accepts `dialect` via its zod parameter schema
2. Passes it through to the Dispatcher call
3. Includes it in telemetry metadata

Follows the pattern established in sql-analyze.ts, sql-optimize.ts,
and schema-diff.ts. Type interfaces updated in types.ts.
Tests updated to pass dialect explicitly.

Fixes AltimateAI#455

Co-Authored-By: Vijay Yadav <vijay@studentsucceed.com>
Address behavioral analysis findings: the NO SCHEMA early returns in
validate, semantics, and equivalence tools, plus the NO MANIFEST and
MODEL NOT FOUND early returns in impact-analysis, were missing the
dialect field in their metadata. All return paths now consistently
include dialect for telemetry.

Co-Authored-By: Vijay Yadav <vijay@studentsucceed.com>
The dialect parameter was passed through the tool layer but dropped at
the schema resolution step. Six native handlers (validate, check, fix,
semantics, equivalence, correct) called schemaOrEmpty() without dialect,
so the fallback empty schema always used the default dialect.

Fix: add optional dialect param to schemaOrEmpty() and pass it to
Schema.fromDdl(). Update all six handlers to forward params.dialect.

Co-Authored-By: Vijay Yadav <vjyadav194@gmail.com>
@anandgupta42 anandgupta42 force-pushed the fix/hardcoded-snowflake-dialect branch from aaa1816 to 4ceea83 Compare April 5, 2026 06:41
Code review (Gemini 3.1 Pro) caught a missed handler in the
dialect-threading migration: 'altimate_core.policy' (altimate-core.ts:200)
called schemaOrEmpty() without params.dialect, while the 6 other policy-
family handlers (validate, check, fix, semantics, equivalence, correct,
explain) all pass it through.

AltimateCorePolicyParams already declares 'dialect?: string' in types.ts
and the tool definition plumbs it into Dispatcher.call(), so the param
was reaching the handler but being silently discarded at the schema
resolution step — meaning the fallback empty schema was always built
with the default (Snowflake) dialect instead of the user-selected one,
defeating the purpose of PR AltimateAI#550 for policy checks specifically.

1-line fix brings the policy handler into line with its 6 siblings.
@anandgupta42
Copy link
Copy Markdown
Contributor

Consensus code-review applied — fix pushed

Ran a 4-participant consensus review (Claude + GPT 5.4 + Gemini 3.1 Pro + self-review).

Real bug found and fixed

CRITICAL — altimate_core.policy handler ignored dialect (Gemini)

The dialect parameter was correctly plumbed through the tool → Dispatcher → type definition, but the native handler at packages/opencode/src/altimate/native/altimate-core.ts:200 called schemaOrEmpty(params.schema_path, params.schema_context) without params.dialect, while the 6 sibling handlers (validate, check, fix, semantics, equivalence, correct, explain) all pass it through.

Effect: policy checks with a user-provided dialect would silently build the fallback empty schema with the default (Snowflake) dialect instead of the user-selected one — defeating the purpose of this PR for policy checks specifically.

1-line fix brings the policy handler into line with its siblings.

Scope discussion

Gemini also flagged that the PR doesn't migrate dialect into the ~20 OTHER altimate_core handlers (rewrite, testgen, grade, prune_schema, etc.). That's intentionally out of scope — issue #455 explicitly lists the 8 tools this PR targets. The remaining handlers can get dialect as a follow-up if needed; no silent-fallback bug exists for tools that aren't updated (they don't accept dialect at the tool level yet).

Test coverage

29 existing altimate-core-native tests continue to pass. No new tests added because schemaOrEmpty's dialect parameter only affects the fallback empty-schema path (which is exercised via integration tests, not easily isolated for unit assertions without a real policy JSON + altimate-core binary).

Pushed as d2ad6ac846. Ready for merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hardcoded dialect: "snowflake" across altimate-core tools

3 participants