Skip to content

fix(selectors): drain Snowflake result partitions - #7357

Merged
waleedlatif1 merged 1 commit into
stagingfrom
investigate/snowflake-selector-partitions
Sep 1, 2026
Merged

fix(selectors): drain Snowflake result partitions#7357
waleedlatif1 merged 1 commit into
stagingfrom
investigate/snowflake-selector-partitions

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

  • Drain every partition advertised by the initial Snowflake SQL API selector response so dropdowns are not silently truncated.
  • Keep the drain bounded by row, option, per-response byte, aggregate byte, partition, timeout, abort, origin, handle, and partition-number constraints.
  • Preserve the existing one-partition runtime tool contract. HTTP 202 polling remains a separate concern and fails closed for selectors.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • bun run --cwd apps/sim test lib/selectors/server/providers/snowflake.test.ts tools/snowflake/utils.test.ts (34 tests passed)
  • bunx biome check apps/sim/lib/selectors/server/providers/snowflake.ts apps/sim/lib/selectors/server/providers/snowflake.test.ts apps/sim/tools/snowflake/utils.ts apps/sim/tools/snowflake/utils.test.ts
  • bun run --cwd apps/sim type-check

Review focus: ordered all-or-nothing partition draining, aggregate limits, cancellation, and unchanged runtime tool behavior.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

Not applicable; server-side selector behavior only.

@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 1, 2026 6:27pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates Snowflake server selectors to drain all advertised result partitions atomically while retaining the runtime tool’s existing single-response behavior.

  • Fetches later partitions sequentially and preserves result ordering.
  • Enforces partition, row, option, response-size, aggregate-size, timeout, cancellation, origin, handle, and consistency constraints.
  • Adds selector and transport tests for successful draining, fail-closed errors, cancellation, metadata validation, and shared byte budgets.

Confidence Score: 5/5

The PR appears safe to merge, with the partition-draining path bounded and fail-closed while preserving caller cancellation and existing runtime behavior.

The changed selector validates every partition before returning options, rejects incomplete or inconsistent aggregate results, and maintains independent per-response and aggregate resource limits without exposing a concrete correctness or security failure.

Important Files Changed

Filename Overview
apps/sim/lib/selectors/server/providers/snowflake.ts Adds bounded, ordered partition draining with consistent error mapping, cancellation preservation, and aggregate validation.
apps/sim/tools/snowflake/utils.ts Extends response parsing with optional abort propagation and shared aggregate byte-budget accounting without changing default callers.
apps/sim/lib/selectors/server/providers/snowflake.test.ts Covers ordered multi-partition results, all-or-nothing failure, later-fetch cancellation, and invalid initial metadata.
apps/sim/tools/snowflake/utils.test.ts Verifies successful shared-budget accounting and rejection after aggregate budget exhaustion.

Sequence Diagram

sequenceDiagram
  participant S as Selector
  participant API as Snowflake SQL API
  S->>API: POST statement
  API-->>S: Partition 0, handle, metadata
  loop Each advertised later partition
    S->>API: GET statement handle and partition number
    API-->>S: Ordered partition rows
    S->>S: Validate status, handle, limits, and budget
  end
  S->>S: Verify aggregate row count
  S-->>S: Build all-or-nothing selector options
Loading

Reviews (1): Last reviewed commit: "fix(selectors): drain Snowflake result p..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 11b10fb into staging Sep 1, 2026
27 checks passed
@waleedlatif1
waleedlatif1 deleted the investigate/snowflake-selector-partitions branch September 1, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants