Data 360 SQL and Tableau Hyper API
Window Functions
unnest
external
generate_series (Numerical)
generate_series (Time-based)
regexp_matches
result_scan
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
result_scanApplies to: ✅ Data 360 SQL
Returns the result set of a completed query as a table. Use result_scan in the FROM clause to query cached results without rerunning the original query.
1result_scan('<query_id>')<query_id>: The query identifier returned by the Data 360 Query API when the source query was submitted. Pass it as a string literal. You can’t use a column reference or a computed expression.Returns a set of rows whose column names and data types match the result set of the referenced query. Use it anywhere a table reference is valid in a FROM clause.
result_scan is a set-returning function that must appear in the FROM clause, not in a SELECT list or WHERE clause.
result_scan against it. Queries that are still running, have failed, don’t exist, or return no rows result in an error.queryId and pass it to subsequent result_scan calls. A single query can contain multiple calls referencing the same or different IDs.result_scan might not match the order of the original query. Use an explicit ORDER BY clause if sorting matters.| SQLSTATE | Condition | Message |
|---|---|---|
| 42704 | Query ID not found, not yours, not finished, or expired | The result of the query '<queryId>' cannot be scanned. Either the query id does not exist, the query was issued by another user, the query execution has not finished yet or the result expired. |
| 42704 | Query still running | The result of the query '<queryId>' cannot be scanned. The query execution has not finished yet. |
| 22023 | Source query produced no result set | The query '<queryId>' did not produce a result. |
Because result_scan returns the schema of the source query, expected output depends on your data. The examples below show query structure only.
Submit an initial query and store the returned queryId. Use result_scan to aggregate the cached results without rerunning the source query. Pass the queryId value (for example, '3442db1a-ecef-42b3-b0d8-971ee459efa4') returned by the Data 360 Query API.
1SELECT region, SUM(revenue) AS total_revenue
2FROM result_scan('3442db1a-ecef-42b3-b0d8-971ee459efa4')
3GROUP BY region
4ORDER BY total_revenue DESC;Filter results from a completed query without rescanning the source table.
1SELECT customer_id, order_date, amount
2FROM result_scan('3442db1a-ecef-42b3-b0d8-971ee459efa4')
3WHERE amount > 500;Reference two different cached result sets in a single query.
1SELECT a.customer_id, a.segment, b.total_spend
2FROM result_scan('3442db1a-ecef-42b3-b0d8-971ee459efa4') AS a
3JOIN result_scan('7f9c21ba-ab12-4d3c-9e45-0b8c6d2f1a3e') AS b
4 ON a.customer_id = b.customer_id
5WHERE b.total_spend > 1000;