Repository navigation
feat(pyo3): statement query tags + custom HTTP headers (match Thrift behavior) - #119
Conversation
a239658 to
c2053f6
Compare
|
P1 — Should fix
P2 — Minor
|
Wire two more connection features onto the kernel surface so the databricks-sql-python use_kernel path can reach Thrift parity: statement-level query tags, and caller-supplied HTTP headers (which also carries user_agent_entry). Query tags (statement-level): - spec.rs: `StatementSpec::query_tags` now takes `HashMap<String, Option<String>>` — a `None` value emits a BARE KEY (no colon), matching the Python connector's `Dict[str, Optional[str]]` serializer. The escaping already matched byte-for-byte; this closes the last parity gap (key-only tags). Serializes into the SEA `query_tags` statement_conf key. - pyo3 Statement gains `set_query_tags(dict[str, str | None])`. Custom HTTP headers (carries user_agent_entry): - config.rs: add `custom_headers: Vec<(String,String)>` to public HttpConfig. - http.rs: apply caller headers FIRST, then the kernel's own Authorization / x-databricks-org-id LAST so they win — matching the Thrift connector's precedence. A caller header named Authorization / x-databricks-org-id is skipped (warn). - **User-Agent is special-cased: APPENDED to the kernel base UA, never replacing it.** The base UA carries the `DatabricksJDBCDriverOSS` token the SEA server keys on to enable the INLINE_OR_EXTERNAL_LINKS result disposition; a caller UA that *replaced* it breaks result fetching (HTTP 400 "not a supported disposition") — caught by the live e2e below. Appending preserves the gating and still surfaces the caller's identity (the connector's PyDatabricksSqlConnector/x UA). - session.rs: thread HttpConfig.custom_headers into the HTTP client. - pyo3 Session gains an `http_headers` kwarg. Tests: - wiremock unit test: custom header + appended User-Agent reach the wire; a bogus caller Authorization is overridden by the real token. - live e2e (tests/v0_query_tags_headers_e2e.rs, wired into rust-e2e.yml): tagged queries (valued + None/bare-key) and a custom-header session (with appended UA) all round-trip green against a dogfood warehouse. These are smoke tests — query.history ingestion lag (minutes) makes a sync tag-readback assertion infeasible; exact wire shapes are pinned by the unit/wiremock tests. cargo fmt + clippy clean under tls-native and tls-rustls; 612 kernel lib tests pass; 11 pyo3 Rust tests pass; 3 e2e pass live. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
c2053f6 to
81da32e
Compare
|
Thanks @gopalldb — all addressed in the latest push ( P1
P2 fmt + clippy clean under tls-native, tls-rustls, and napi; 613 lib tests pass; 4 e2e pass live. |
What
Two more
use_kernel-parity features on the kernel surface, designed to mirror the Thrift connector's behavior:StatementSpec::query_tags; this closes the last parity gap and exposes it through pyo3.user_agent_entry.Follow-up connector PR wires both + bumps
KERNEL_REV.Query tags
spec.rs:query_tagsnow takesHashMap<String, Option<String>>. ANonevalue emits a bare key (no colon) — matching the Python connector'sDict[str, Optional[str]]serializer (the only parity gap; escaping already matched byte-for-byte). Serializes into the SEAquery_tagsstatement-conf key.Statement.set_query_tags(dict[str, str | None]).Custom HTTP headers (Thrift precedence + UA append)
config.rs:custom_headers: Vec<(String,String)>on publicHttpConfig.http.rs: caller headers applied first, thenAuthorization/x-databricks-org-idlast so they win (matching Thrift). Those two caller names are skipped (warn).User-Agentis special-cased — appended to the kernel base UA, never replacing it. The base UA carries theDatabricksJDBCDriverOSStoken the SEA server keys on to enable theINLINE_OR_EXTERNAL_LINKSresult disposition; a caller UA that replaced it breaks result fetching (HTTP 400 "not a supported disposition"). This was caught by the live e2e — appending preserves the gating and still surfaces the caller's identity.Session(http_headers=...).Tests
Authorizationoverridden by the real token.tests/v0_query_tags_headers_e2e.rs, wired intorust-e2e.yml): tagged queries (valued + None/bare-key) and a custom-header session (appended UA) all round-trip green against a dogfood warehouse. Smoke-level —query.historyingestion lag (minutes) makes a sync tag-readback infeasible; exact wire shapes pinned by the unit/wiremock tests.Verification
cargo fmt+clippy -D warningsclean undertls-nativeandtls-rustls.This pull request and its description were written by Isaac.