Repository navigation
feat(napi): expose metadata methods on Connection - #97
Closed
msrathore-db wants to merge 6 commits into
Closed
msrathore-db wants to merge 6 commits into
msrathore-db wants to merge 6 commits into
Conversation
Adds Statement::from_result_stream (internal constructor wrapping a bare ResultStream) and a new napi/src/metadata.rs that wires all 10 kernel Metadata methods onto the JS Connection class: listCatalogs, listSchemas, listTables, listColumns, listFunctions, listProcedures, listTableTypes, listTypeInfo, getPrimaryKeys, getCrossReference Each returns the same Statement type as executeStatement so the JS SeaOperationBackend wraps them uniformly. Cancel on metadata-derived Statements is a no-op (no server-side cancellation surface today). The kernel Metadata methods hold a tracing::EnteredSpan (!Send) across their await points. The fix: acquire the session lock, clone the Send Metadata handle, drop the lock, then run the !Send future inside tokio::task::spawn_blocking via Handle::block_on — a standard pattern for escaping the Send bound without LocalSet. Also fixes: - pre-existing unused StatementState import in src/client/transport.rs - pre-existing dead_code lint on open_session + ConnectionOptions in napi/src/database.rs (exported via napi macro codegen, not called from Rust directly) - AnyInner::Executed variant boxed to satisfy large_enum_variant lint Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
…nly identifiers H1: `run_on_blocking`'s closure type was `FnOnce(Handle) -> Fut`, giving callers access to the runtime handle inside a `spawn_blocking` thread. Any future caller using that handle to call `block_on_in_runtime` would trigger `block_in_place` inside a blocking thread — the PECOBLR-2917 abort vector. Drop the parameter; callers that needed it for `Handle::block_on` already have a captured `handle`. All 10 call sites updated from `move |_h|` to `move ||`. H2: `Identifier::new` and `LikePattern::new` accepted whitespace-only strings (e.g., `" "`) that would produce meaningless or empty tokens at the SQL layer. Add `s.trim().is_empty()` guard after the `s.is_empty()` check in both. Two unit tests added covering space, tab, newline, and mixed whitespace inputs. Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Databricks SHOW TABLES does not accept a table-type filter server-side; the kernel applies it client-side after the result returns. Mirror the language already present in src/metadata_v0.rs:310-313 so napi callers are not misled into expecting server-side enforcement. Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
… docblocks The whitespace-only check was added in code but the /// Rejects: bullet list in each constructor docblock didn't mention it. Add a bullet to both Identifier::new and LikePattern::new explaining the rejection and the reason (blank token / use None for "match all"). Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Leftover from the H1 fixup that removed the `Handle` parameter from `run_on_blocking`'s signature. With no callers of `Handle` as a type remaining in metadata.rs, the import is dead and trips `cargo clippy --all-targets -- -D warnings`. Doc-comment references to `Handle::block_on` and `Handle::current()` remain (they describe behavior, not Rust paths). Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Rebasing the metadata-methods work onto main surfaced a clean conflict: main's status accessors (num_modified_rows / display_message / diagnostic_info / error_details_json, merged via PR #23) read `inner_state.executed` directly, but the metadata work wraps the Statement inner in an `AnyInner::{Executed, Metadata}` enum (the Metadata variant holds a bare ResultStream from `Metadata::list_*`). Match on the enum: the Executed variant delegates to the executed handle as before; the Metadata variant returns None — metadata result streams carry no operation-status fields. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
msrathore-db
force-pushed
the
msrathore/krn-napi-metadata-exposure
branch
from
June 1, 2026 00:55
6cda5ec to
52b680f
Compare
Collaborator
Author
|
Closing as superseded by #101, which is now the main-based kernel SEA parity mega PR for agent review. The branch is preserved and this can be reopened if we decide to return to smaller stacked reviews. |
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Exposes the JDBC
DatabaseMetaData-style metadata methods on the napiConnection, backed by the kernel's flatMetadataAPI —listCatalogs,listSchemas,listTables,listColumns,listFunctions,listTableTypes,listTypeInfo, plusgetPrimaryKeys/getCrossReference(with whitespace-only identifier rejection andtableTypesadvisory-filter docs). Each returns aStatementhandle that streams JDBC-shaped Arrow batches, so JS consumes metadata results through the same surface asexecuteStatement.Scope (rebased + slimmed onto
main, 2026-06-01)This branch was previously a broad bundle (metadata + status accessors + TLS config + pool default + the napi Connection/Statement surface) built ~16 commits behind
main. Since thenmainmerged the decomposed stack that already contains all of those:TlsConfigfields → onmain(napi exposure is feat(napi): bundle SEA kernel parity surface #101)maxConnections→ feat(napi): expose maxConnections on openSession ConnectionOptions #74; JDBC type-code alignment inmetadata_v0→ feat(metadata): align JDBC type codes with Thrift backend; unify the two surfaces #73So this PR was rebased
--onto mainto drop all the already-merged content. What's left is just the metadata exposure — 4 files:napi/src/metadata.rs(new), the metadata wiring +AnyInnerenum innapi/src/statement.rs,src/metadata_v0.rs, and themod metadataline.Rebase adaptation
The metadata work wraps the Statement inner in an
AnyInner::{Executed, Metadata}enum (theMetadatavariant holds a bareResultStreamfromMetadata::list_*). One commit adapts main's #23 status accessors (num_modified_rows/display_message/diagnostic_info/error_details_json) to match on that enum — theExecutedvariant delegates as before; theMetadatavariant returnsNone(metadata streams have no operation-status fields).Routing
Targets
mainas the next single-concern item in the kernel decomposed stack. Independent of the param (#84) / async / TLS-napi (#101) PRs.Testing
Builds clean against
main; 26 napi tests pass; clippy/fmt clean.This pull request and its description were written by Isaac.