SQL Scope
What this does
Section titled “What this does”The SQL editor can consume the current Analyze context instead of making you rebuild it manually.
That means you can:
- brush dies in
Analyze - stage what-if limits
- switch to
SQL - query the same scoped population directly
This is a one-way flow: Analyze -> SQL. Selections and limits do not push back from SQL to Analyze.
Large results page automatically. Use SQL LIMIT and OFFSET for manual control.
Execution limits
Section titled “Execution limits”The public SQL endpoint is intentionally constrained:
- exactly one statement per request
- only
SELECTandEXPLAIN - read-only validation before execution
- blocked filesystem, network, export, and system helpers
30stimeout- hard cap of
100,000rows - default page size of
1,000rows whenlimitis omitted
So the SQL surface is powerful, but it is not an unrestricted DuckDB shell.
What propagates
Section titled “What propagates”When Analyze has an active lot, the SQL editor receives:
- lot id
- current notebook snapshot id
- current die selection
- active what-if limit overrides
- current test and wafer context
That scope is exposed through helper tables and views.
Helper views
Section titled “Helper views”current_scope
Section titled “current_scope”One-row summary of the propagated context.
current_scope_limits
Section titled “current_scope_limits”Notebook what-if limits for the current scope.
Columns:
test_numbertest_namelslusl
current_scope_selected_dies
Section titled “current_scope_selected_dies”The exact brushed die identities from Analyze.
Columns:
wafer_numberxy
current_scope_die
Section titled “current_scope_die”The die view filtered to the current selection.
If no selection is active, it resolves to the whole current lot.
If Analyze is pinned to a historical snapshot, this helper follows that snapshot.
current_scope_test_results
Section titled “current_scope_test_results”The test_results view filtered to the current selection and enriched with the active notebook what-if limits.
Important columns:
has_scope_overridescope_limit_sourcescope_low_limitscope_high_limitraw_passscope_pass
has_scope_override and scope_limit_source tell you whether a row is using baseline limits or notebook what-if limits.
scope_pass uses the current notebook what-if limits when they exist.
If Analyze is pinned to a historical snapshot, this helper follows that snapshot too.
current_scope_active_test_results
Section titled “current_scope_active_test_results”The current scoped results filtered to the active Analyze test when one exists.
Use this when you want SQL to stay anchored to the test you were just inspecting in scatter or histogram.
Suggested first queries
Section titled “Suggested first queries”SELECT * FROM current_scope;SELECT * FROM current_scope_limits ORDER BY test_number;SELECT * FROM current_scope_active_test_results LIMIT 200;SELECT test_number, test_name, COUNT(*) AS n, AVG(result) AS mean_result, SUM(CASE WHEN scope_pass THEN 1 ELSE 0 END) AS pass_count, SUM(CASE WHEN NOT scope_pass THEN 1 ELSE 0 END) AS fail_countFROM current_scope_test_resultsGROUP BY test_number, test_nameORDER BY fail_count DESC, test_numberLIMIT 20;