Repository navigation
feat(pyo3): metadata + ResultStream surface - #14
Merged
Merged
Conversation
Phase 1 step 3 of the PySQL × kernel integration plan. Wraps the kernel's `Metadata` API and adds a standalone `ResultStream` Python class for the bare streams the metadata calls return. New Python surface: - `Session.metadata() -> Metadata` - `Metadata.list_catalogs() -> ResultStream` - `Metadata.list_schemas(*, catalog=None, schema_pattern=None) -> ResultStream` - `Metadata.list_tables(*, catalog=None, schema_pattern=None, table_pattern=None, table_types=None) -> ResultStream` - `Metadata.list_columns(*, catalog, schema_pattern=None, table_pattern=None, column_pattern=None) -> ResultStream` - `Metadata.primary_keys(*, catalog, schema, table) -> ResultStream` - `Metadata.foreign_keys(*, parent_catalog=None, parent_schema=None, parent_table=None, foreign_catalog, foreign_schema, foreign_table) -> ResultStream` - `Metadata.functions / procedures(*, catalog=None, schema_pattern=None, name_pattern=None) -> ResultStream` - `Metadata.type_info() / table_types() -> ResultStream` (static, no wire call) - `ResultStream` — `arrow_schema()`, `fetch_next_batch()`, `fetch_all_arrow()`, `close()`. The Python surface collapses kernel `Identifier` / `LikePattern` back to `Option[str]`; the kernel still enforces empty / NUL / backtick / length-cap checks, surfacing bad input as `KernelError(code='InvalidArgument', ...)`. Implementation notes: - New `fetch.rs` shared helpers (`next_batch`, `drain`, `batches_to_pyarrow_table`) so `ExecutedStatement` and the new `ResultStream` produce identical Python objects from the same code path. - `ExecutedStatement::fetch_*` refactored to call the helpers; no behavior change. - `Metadata` methods are inline `block_on`s — the `for<'a> FnOnce(&'a Metadata) -> Fut` HRTB trick can't express the bound the borrow checker needs, and the inline form is simpler anyway. Smoke test (`pyo3/smoke.py`) extended with the metadata surface and validation checks; verified end-to-end against dogfood. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
This was referenced May 13, 2026
3 tasks
gopalldb
added a commit
that referenced
this pull request
May 22, 2026
…ject comments (#41) ## Summary Closes three audit findings related to CI and dependency hygiene. | Audit | Commit | What | |---|---|---| | #9 | `2acc8e5` | `dco-check.yml` checkout was `@v6.0.2`; all other workflows use `@v4`. Aligned to v4. Both SHA-pinned — no security delta. | | #10 | `820e69c` | No `.github/dependabot.yml`. Added one covering `cargo` + `github-actions`. `pip` intentionally omitted per `go/pinning-python-deps` (externally-published-library rule). | | #16 (dependency-pinning audit row 3) | `732827b` | `pyo3/pyproject.toml` comments claimed `uv sync --frozen` + committed `uv.lock` with SHA256 hashes. Actual CI uses `uv sync --group dev` (no `--frozen`, no committed lockfile) per the externally-published-library policy. Rewrote both comment blocks to match reality. Documentation-only fix. | ## #9 — Checkout pin alignment `dco-check.yml:37` was the only workflow using `actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2`. All other 7 workflows use `actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4`. Both are SHA-pinned, so no actual security delta — purely version-drift hygiene. ## #10 — Dependabot configuration New `.github/dependabot.yml`: - **`cargo`** ecosystem: tracks the Rust crate graph weekly, complements the existing `cargo-deny` gate. Patch + minor grouped to reduce PR churn; security advisories still surface as individual PRs. Limit: 10 open PRs. - **`github-actions`** ecosystem: tracks SHA-pinned action versions weekly. Patch + minor grouped. Limit: 5 open PRs. **`pip` ecosystem intentionally NOT included.** The kernel is treated as an externally-published library per [go/pinning-python-deps](https://docs.google.com/document/d/1thJsoOBW3NzvRV6pWpujcD8mn4KOXgAW8t10iw6Z6LA/edit): - Major-version upper bounds in `pyo3/pyproject.toml` (e.g. `pyarrow>=14,<19`). - `uv sync` re-resolves on each CI run within those bounds. - No committed lockfile (would impede downstream `pip install`). Letting Dependabot rewrite pinned pip versions would conflict with that policy. ## #16 — pyproject.toml comment accuracy The `[project].dependencies` block comment said: > The CI environment is fully hash-locked via `uv.lock` (see below), separately from this contract. And the `[dependency-groups].dev` block said: > `uv sync --frozen` installs from `uv.lock`, which carries SHA256 hashes for every artifact + transitive dep. Neither was true. The repo has **no `uv.lock`** committed; the workflow runs **`uv sync --group dev`** (no `--frozen`). The workflow's own inline comment correctly describes the policy ("No `--frozen` and no committed lockfile: per go/pinning-python-deps the externally-published-library rule says *not* to pin transitive deps") — only the pyproject comments were stale. This documentation drift was actively misleading dependency-pinning audits, contributing to false "unpinned pyarrow" findings. Both comment blocks now match the actual in-repo policy. No behavioural change. ## Audit items NOT addressed here - **#11** (audit-log alerts on `.github/workflows/**` changes) — org-level streaming, not a repo-admin action. - **#12** (`id-token: write` in 3 workflows) — audit confirms current scoping is correct. - **#13** (`persist-credentials: false` in rust-e2e) — audit confirms positive control, preserved. - **#14** (`azure-prod.can_admins_bypass: true`) — handled via repo settings PUT, already flipped to `false`. ## Test plan - [ ] Reviewer checks GitHub recognises the dependabot config (Insights → Dependency graph → Dependabot tab shows cargo + github-actions ecosystems active). - [ ] DCO check on this PR runs successfully with the new v4 checkout (the workflow runs on PR open, once Actions are enabled). - [ ] Reviewer skims the pyproject comment changes to confirm they match the workflow's actual behaviour (`uv sync --group dev`, no `--frozen`). This pull request and its description were written by Isaac. --------- Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
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.
Summary
MetadataAPI one-to-one and introduces a standaloneResultStreamPython class for the bare streams metadata calls return (no statement_id / no cancel — that surface is reserved forExecutedStatement).Surface added
Session.metadata()MetadataMetadata.list_catalogs()ResultStreamMetadata.list_schemas(*, catalog=None, schema_pattern=None)ResultStreamMetadata.list_tables(*, catalog=None, schema_pattern=None, table_pattern=None, table_types=None)ResultStreamMetadata.list_columns(*, catalog, schema_pattern=None, table_pattern=None, column_pattern=None)ResultStreamMetadata.primary_keys(*, catalog, schema, table)ResultStreamMetadata.foreign_keys(*, parent_*, foreign_catalog, foreign_schema, foreign_table)ResultStreamMetadata.functions / procedures(*, catalog=None, schema_pattern=None, name_pattern=None)ResultStreamMetadata.type_info() / table_types()ResultStream(static, no wire call)ResultStream.arrow_schema / fetch_next_batch / fetch_all_arrow / closeThe Python surface collapses kernel
Identifier/LikePatternback toOption[str]; the kernel still enforces empty / NUL / backtick / length-cap checks, surfacing bad input asKernelError(code='InvalidArgument', ...).Implementation notes
fetch.rsshared helpers (next_batch,drain,batches_to_pyarrow_table) soExecutedStatement.fetch_*andResultStream.fetch_*produce identical Python objects from the same code path.ExecutedStatement::fetch_*refactored to call the helpers; no behavior change.Metadatamethods are inlineblock_ons — thefor<'a> FnOnce(&'a Metadata) -> FutHRTB trick can't express the bound the borrow checker needs, and the inline form is simpler anyway.Test plan
cargo build --workspacecargo clippy --workspace --all-targets -- -D warningscargo +stable fmt --all -- --checkcargo test --workspace— kernel suite unchangedpyo3/smoke.pyexercises every metadata method, theResultStreamsurface (drain + close + use-after-close), and input validation. All 30+ checks pass. Notable live numbers: 74 catalogs visible, 142 schemas inmain, 47 tables insystem.information_schema, 24type_inforows, 4table_types.meta.list_schemas(catalog="")correctly raisesKernelError(code='InvalidArgument', message='identifier must not be empty').This pull request and its description were written by Isaac.