status, name, and type repeat across dozens of tables. The SQL table
function search_available_data searches what data exists, the tables and
columns themselves rather than their rows, so a query can start from the right
names.
It searches both Pools:
Arguments
The function takes up to three arguments, by position only:search_available_data(query [, scope [, kind]]). Named arguments
(query => ...) are refused.
The scope keeps a search to one Pool, one Provider, or one table, and applies
before ranking. It matches one dotted segment at a time:
A scope that stops above the table level means everything under it; one that
reaches the table level without a trailing
* means the tables alone. A scope
must start with providers or workspace. Underscores are literal. A
double-quoted segment is one literal name, dots and * included, so a
column_name from a result works as a scope. A scope and kind that can never
match together, such as providers.jiracloud.issues with 'column', are
refused with the scope to use instead.
Results
Each row is one table, column, or field, best first.
One search returns at most its 500 best results. Page through them with
ORDER BY score DESC, qualified_name and LIMIT/OFFSET; qualified_name
orders results with equal scores, so pages neither repeat nor skip one:
WHERE filters only those 500 results, after ranking. Restrict by Pool,
Provider, or table with scope, and use WHERE to narrow what came back, such
as WHERE column_name LIKE '%email%'.
How results are ranked
The search is keyword ranking (BM25) over the Workspace’s live catalog. Each table, column, and field is matched on:- its names: the Provider’s connector name, the table, the column, and the
field path, split on
_,., and changes of case, soassignee_account_idmatches “assignee account”; - its description and title;
- its Provider’s name;
- for a table, its data stream’s purpose, at half weight.
github issue labels finds the issues__labels table before its
bookkeeping columns. Entries that match more of the query’s words rank above
entries that match fewer. Plural and singular forms match (issue finds
issues), and common words such as “which” and “the” are ignored. The search matches
words, not meaning: “who is responsible” does not find assignee unless a
description says so, so describe the data in the words a name or description
would use.
The live catalog decides what exists: a dropped or renamed column is never
returned, and a column added a moment ago is found on the next catalog build.
Fields inside struct columns
Some Provider tables keep an object in one struct column, such as thefields
column of providers.jiracloud.issues, which holds an issue’s priority,
assignee, and status. Each field inside a struct column is its own result,
down to three levels below the column, at most 500 per table, shallowest
first. Its column_name is the path to select, quoted where SQL needs it:
Where the function runs
The function runs in interactive SQL against the query layer: Workspace API Flight SQL, Preview a Plot, and Ponder. It needs the same data access as any other query in the Workspace and reads only that Workspace’s catalog. A Plot cannot call it. Saving a Plot whose SQL callssearch_available_data
records the error PV_STMT_003 on the Plot, and the Plot cannot publish until
the call is removed; planning the Plot fails with QL-PL-004. Use a search to
find names, then write the Plot’s SQL with those names.
A listed table can still be empty; check with a bounded query.