You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(kernel): statement query tags + http_headers/user_agent_entry on use_kernel (#823)
* feat(kernel): wire statement query tags + http_headers/user_agent on use_kernel
Consume the kernel surface from kernel PR (query tags + custom HTTP
headers) on the use_kernel path. Bumps KERNEL_REV.
Query tags (statement-level):
- execute_command no longer raises NotSupportedError for query_tags;
it calls stmt.set_query_tags(query_tags) after set_sql. The connector
already passes Dict[str, Optional[str]], which the kernel accepts
(None value -> bare key in the SEA query_tags conf).
http_headers + user_agent_entry:
- The kernel client now forwards http_headers to the kernel Session as
the `http_headers` kwarg (was accept-and-ignore). session.py already
passes all_headers, which carries the connector's composed User-Agent
(PyDatabricksSqlConnector/x (entry)) + caller headers + SPOG org-id.
- The kernel applies them per request: its own Authorization / org-id
win; a caller User-Agent is APPENDED to the kernel base UA (the base
carries the DatabricksJDBCDriverOSS token that gates the SEA result
disposition, so it's never replaced). So user_agent_entry is honored
end-to-end via the existing http_headers forwarding — no separate
kwarg needed.
Tests:
- unit: query_tags forwarded to set_query_tags (was: rejection test);
http_headers forwarded to the kernel Session (and omitted when empty).
- e2e (test_kernel_backend.py): a query_tagged query and a connection
with user_agent_entry + a custom http_header both round-trip green
against a dogfood warehouse. The UA case specifically guards the
append behavior (replacing the base UA would 400 on the result
disposition).
KERNEL_REV -> c2053f68b75fef4a29425096dc6bbafb774d8b83 (kernel PR #119
branch HEAD; re-pin to the squash-merge SHA once #119 lands).
194 kernel unit tests pass; black + mypy clean; 3 e2e pass live.
Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
* fix(kernel): address review — secret-scrub ordering, drop reserved headers
Addresses @gopalldb's review on #823.
P1.1 — secret scrub now covers a kwarg-build failure:
- open_session built auth/tls/retry/http_headers kwargs OUTSIDE the try
whose finally scrubs oauth_client_secret. A raise in
kernel_auth_kwargs (e.g. OAuth token-exchange failure with the M2M
secret in hand) would skip the scrub, leaking the secret onto the
long-lived connector. Moved all kwarg builds inside the try
(auth_kwargs / tls_kwargs pre-declared empty so the finally can
reference them on an early raise).
P1.3 / P2 — don't forward kernel-managed headers:
- The connector now drops Authorization and x-databricks-org-id from
http_headers before forwarding to the kernel (new
_KERNEL_MANAGED_HEADERS set). The kernel manages both (auth from the
provider; org-id re-derived from ?o= in http_path), so forwarding is
redundant — and the connector always injects the SPOG org-id, which
the kernel skips-and-warns per request, so this also kills the WARN
spam. Double-walls the kernel's own reserved-name skip.
Tests:
- unit: Authorization / x-databricks-org-id dropped before forwarding;
only-reserved-headers omits the kwarg entirely (test_kernel_client).
- P1.2: user_agent_entry reaches the kernel client's http_headers
on use_kernel=True (test_session) — guards a regression where
session.py stops folding the entry into the composed User-Agent.
CHANGELOG: deferred to release-cut per repo convention (entries are
added at version bump, not per-PR; #819/#820 followed the same).
197 kernel unit tests pass; black + mypy clean; 3 e2e pass live.
Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
* chore: re-pin KERNEL_REV to merged kernel main (101aa46)
#119 (statement query tags + custom HTTP headers) is now merged to
kernel main. Re-pin from the orphaned branch HEAD (c2053f6) to the
current merged main HEAD (101aa46), which contains #119's merge
commit (df8302f) and is reachable from main — no orphan-SHA risk.
Verified end-to-end against a wheel built from 101aa46: kernel
e2e (query_tags_round_trip, user_agent_entry + http_headers
round_trip, select_one) all pass.
Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
---------
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
0 commit comments