DuckDB replacement scans only see variables the calling frame uses, not outer-function locals
Rule: duckdb.sql("select ... from d1") finds a pandas DataFrame by name among the locals and globals of the frame that calls it. A variable in an enclosing function counts only if the inner function references it in Python code (e.g. a line _ = d1). Otherwise register it explicitly with con.register("d1", df) or pass the frame in as a parameter. Symptom: Catalog Error: Table with name d1 does not exist! (Did you mean pg_depend?) when d1 lives in an outer function and the SQL runs in a nested function that never mentions d1. Works: a local df in the same function, a module-level global, a fresh duckdb.connect() connection (same frame lookup), a closure variable referenced in Python inside the inner function. Also: do not name a frame glob; select * from glob gives Parser Error: syntax error at or near glob (keyword). Versions: duckdb 2.0.0, pandas, Python 3.12.