Skip to content

[SEA-NodeJS] (6/9) CloudFetch + Inline Arrow result fetching#381

Draft
msrathore-db wants to merge 8 commits into
mainfrom
msrathore/sea-results
Draft

[SEA-NodeJS] (6/9) CloudFetch + Inline Arrow result fetching#381
msrathore-db wants to merge 8 commits into
mainfrom
msrathore/sea-results

Conversation

@msrathore-db
Copy link
Copy Markdown
Contributor

Summary

`SeaOperationBackend` + `SeaResultsProvider` + `SeaArrowIpc` wire the kernel's CloudFetch and Inline Arrow paths to JS row-shape conversion. M0 parity gate clean against pecotesting at 23.2 MB/s on a 100k×17-column run.

Stack position

PR 6/9. INTERVAL YEAR-MONTH / DAY-TIME handling is added in PR 8/9 (`sea-integration`) via `SeaArrowIpcDurationFix`.

Creates the napi-rs binding skeleton: Cargo.toml + lib.rs + module
stubs for database/connection/statement/result/error/logger. Captures
napi-rs tokio Handle via OnceCell in runtime.rs. Single working
#[napi] fn version() proves the binding loads + executes end-to-end
in Node.

Depends on krn-async-public-api branch (path dep on kernel).

Round 2 will add open/execute/fetch methods.
…kend

Refactors DBSQLClient/Session/Operation to dispatch through three
backend interfaces. ThriftBackend (lib/thrift-backend/) contains the
relocated existing thrift logic. SeaBackend (lib/sea/) is a stub for
M0; the sea-napi-binding feature wires the real impl.

Public surface (lib/index.ts) unchanged.
No new dependencies. All existing tests pass.

Files:
- lib/contracts/IBackend.ts (new)
- lib/contracts/ISessionBackend.ts (new)
- lib/contracts/IOperationBackend.ts (new)
- lib/contracts/IDBSQLClient.ts (adds useSEA?: boolean to ConnectionOptions)
- lib/thrift-backend/ThriftBackend.ts (new)
- lib/thrift-backend/ThriftSessionBackend.ts (new)
- lib/thrift-backend/ThriftOperationBackend.ts (new)
- lib/sea/SeaBackend.ts (new, M0 stub)
- lib/DBSQLClient.ts (dispatch through IBackend; useSEA picks SeaBackend)
- lib/DBSQLSession.ts (facade over ISessionBackend; staging stays here)
- lib/DBSQLOperation.ts (facade over IOperationBackend; iterators/fetchAll stay here)
- tests/unit/DBSQLClient.test.ts (retarget internal state lookup through backend; pre-seed client.backend in tests that bypass connect())
- tests/unit/DBSQLOperation.test.ts (retarget internal state lookup through backend)
Single mapping function in lib/sea/SeaErrorMapping.ts converts the
napi-binding's surfaced kernel error (code+message+sqlstate) to the
appropriate existing JS error class. M0 minimum: PAT auth errors
land as AuthenticationError; cancel/timeout as OperationStateError;
network/internal as HiveDriverError. SQLSTATE preserved on the
error object via .sqlState property.

No new error classes. M1 may add nuance.
…wired

Adds real async methods on the opaque wrappers backing M0:
- openSession (free function) with PAT → kernel Session
- Connection::execute_statement → kernel ExecutedStatement
- Statement::fetch_next_batch / schema / cancel / close → kernel ResultStream
- Arrow batches returned as IPC bytes (per Layer 2 design)
- Error mapping preserves kernel ErrorCode + SQLSTATE for TS layer
- All entry points wrapped in catch_unwind

End-to-end smoke test against pecotesting passes.
No new dependencies beyond arrow-{ipc,array,schema} + futures.
Uses kernel async public API (no block_on).

Co-authored-by: Isaac
Implements IOperationBackend over the napi binding's Statement.
fetchChunk decodes Arrow IPC bytes → apache-arrow RecordBatch →
ArrowResultConverter (Phase 1+2 reused unchanged) → JS rows.

All M0 datatypes round-trip via the same converter the thrift path
uses (BOOL, INT8/16/32/64, FLOAT, DOUBLE, DECIMAL, STRING, BINARY,
DATE, TIMESTAMP, INTERVAL, ARRAY, MAP, STRUCT). Unit tests
construct synthetic IPC batches; e2e test against pecotesting
confirms byte-identical parity vs thrift.

No new dependencies. ArrowResultConverter / ResultSlicer /
OperationIterator all reused unchanged (DRY).
@github-actions
Copy link
Copy Markdown

Thanks for your contribution! To satisfy the DCO policy in our contributing guide every commit message must include a sign-off message. One or more of your commits is missing this message. You can reword previous commit messages with an interactive rebase (git rebase -i main).

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.

1 participant