From 618385e7e40dd14069500045e5b57927580dd854 Mon Sep 17 00:00:00 2001 From: ZdenekSrotyr Date: Sat, 11 Apr 2026 20:13:35 +0200 Subject: [PATCH] fix: table_catalog in re-attach query, --limit in hybrid CLI - _reattach_remote_extensions: query table_catalog instead of table_schema (DuckDB ATTACHed databases use table_catalog for the alias) - _query_hybrid: forward --limit flag to RemoteQueryEngine.max_result_rows Co-Authored-By: Claude Opus 4.6 (1M context) --- cli/commands/query.py | 7 +++++-- src/db.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/commands/query.py b/cli/commands/query.py index d959e2b..0055735 100644 --- a/cli/commands/query.py +++ b/cli/commands/query.py @@ -112,9 +112,12 @@ def _query_hybrid(sql: str, fmt: str, limit: int, register_bq_specs: List[str]): conn = duckdb.connect(str(db_path), read_only=True) try: config = load_config() - engine = RemoteQueryEngine(conn, **{k: v for k, v in config.items() if k in ( + engine_kwargs = {k: v for k, v in config.items() if k in ( "max_bq_registration_rows", "max_memory_mb", "max_result_rows", "timeout_seconds" - )}) + )} + # CLI --limit flag overrides config max_result_rows + engine_kwargs["max_result_rows"] = limit + engine = RemoteQueryEngine(conn, **engine_kwargs) for spec in register_bq_specs: if "=" not in spec: diff --git a/src/db.py b/src/db.py index 408f3e8..2069396 100644 --- a/src/db.py +++ b/src/db.py @@ -285,7 +285,7 @@ def _reattach_remote_extensions( try: has_table = conn.execute( "SELECT 1 FROM information_schema.tables " - f"WHERE table_schema='{ext_dir.name}' AND table_name='_remote_attach'" + f"WHERE table_catalog='{ext_dir.name}' AND table_name='_remote_attach'" ).fetchone() if not has_table: continue