Skip to content

[SEA-NodeJS] (5/9) executeStatement + openSession (sessionConfig, initialCatalog/Schema)#382

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

[SEA-NodeJS] (5/9) executeStatement + openSession (sessionConfig, initialCatalog/Schema)#382
msrathore-db wants to merge 8 commits into
mainfrom
msrathore/sea-execution

Conversation

@msrathore-db
Copy link
Copy Markdown
Contributor

Summary

Implements `SeaSessionBackend.executeStatement()` and `openSession()` — the core SEA execution surface. Honors `sessionConfig`, `initialCatalog`, `initialSchema` on connect.

Stack position

PR 5/9. M0 e2e at 535ms vs pecotesting; runAsync polling is internal to the kernel.

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
SeaSessionBackend wraps the napi Connection handle. executeStatement
passes through to napi.executeStatement and returns an
IOperationBackend (SeaOperationBackend in sea-results feature).
Session config + initialCatalog/initialSchema flow to napi
openSession. M0 stops at executeStatement; metadata methods +
per-stmt overrides defer to M1.

No new dependencies. Reuses existing ConnectionOptions / Session
config shapes.

Co-authored-by: Isaac
@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