Skip to content

feat: add database parameter to execute_sql for managed database scoping#11

Merged
eddietejeda merged 1 commit into
mainfrom
feat/execute-sql-database-scope
May 25, 2026
Merged

feat: add database parameter to execute_sql for managed database scoping#11
eddietejeda merged 1 commit into
mainfrom
feat/execute-sql-database-scope

Conversation

@eddietejeda
Copy link
Copy Markdown
Contributor

Summary

Adds an optional database keyword argument to execute_sql so callers can scope queries to a managed database without dropping down to the QueryApi directly.

When database is provided, the name is resolved to a database ID once before the retry loop and sent as the X-Database-Id header on every attempt. When omitted, behaviour is identical to before (no header, fully backwards-compatible).

Inside a managed database the built-in catalog is always default, so callers should reference tables as "default"."schema"."table".

Why

Six downstream integration libraries (hotdata-langchain, hotdata-llamaindex, hotdata-langgraph, hotdata-jupyter, hotdata-marimo, hotdata-streamlit) all call execute_sql without database scoping. Any SQL referencing a managed database table returns a 400 today. Each library can fix the issue by adding database=... at their call sites with no other changes needed.

Changes

  • execute_sql(sql, *, database=None) resolves the name to an ID when provided
  • _execute_sql_once(sql, *, database_id=None) passes x_database_id to QueryApi.query when set
  • Two new tests: default path sends no header; database path resolves name and sends the header

Adds an optional keyword-only `database` parameter to `execute_sql`.
When provided, the database name is resolved to an ID once before the
retry loop and passed as the `X-Database-Id` header on every query
attempt. Inside a managed database the built-in catalog is always
"default", so callers should reference tables as
"default"."<schema>"."<table>".

Without the parameter, behaviour is unchanged (no header sent).

All downstream integration libraries (hotdata-langchain,
hotdata-llamaindex, hotdata-langgraph, hotdata-jupyter, hotdata-marimo,
hotdata-streamlit) were calling execute_sql without database scoping,
causing 400 errors when querying managed database tables. They can now
pass database="<name>" to fix the issue without any further changes.
@eddietejeda eddietejeda merged commit 629b018 into main May 25, 2026
2 checks passed
@claude claude Bot mentioned this pull request May 25, 2026
3 tasks
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