Execute SQL across governed and remote sources
Combine warehouse execution, federation, derived objects and review of AI-generated SQL.
Execute SQL across governed and remote sources
Work through the decision
A financial analyst asks Genie Code for a query joining last month’s Delta ticket sales to a remote station registry. The proposed SQL runs but includes closed stations twice. Should a larger warehouse fix the result?
Check your reasoning
Validate grain and keys before sizing compute. Inspect whether a foreign catalog points at the intended remote source, whether the registry stores historical versions, and which row per station is valid for each sale. Compare a few manually reconciled keys with the proposed SQL. Then use the plan to see where filtering and computation occur.
Compare the choices
- SQL warehouse
- Execute SQL on a selected compute resource and distinguish startup, queue and operator time. Data and object permissions still apply.
- Lakehouse Federation
- Use an authorized connection and foreign catalog to query supported remote data alongside local tables. Inspect pushdown and transfer volume.
- Materialized view
- Maintain stored results of a defined query under a refresh policy. Check acceptable freshness and supported refresh behavior.
- Dynamic view
- Evaluate access-aware SQL logic at query time to expose different rows or columns to different viewers.
- Genie Code review
- Use contextual assistance to draft or debug SQL and validate its grain, filters and permissions against known results before relying on it.
Test the decision
A SQL warehouse supplies compute and may spend time starting or queuing. A materialized view maintains a persisted derived result, a streaming table incrementally processes input, and a dynamic view can apply query-time identity logic. Choose the object according to freshness, access and output grain.
Trace the two sides of a federated query
SELECT s.station_id, d.city, SUM(s.net_cents) AS net_cents
FROM ticketing.gold.daily_station_sales AS s
JOIN partner_pg.public.stations AS d ON s.station_id = d.id
WHERE s.service_day = DATE '2026-10-20'
GROUP BY s.station_id, d.city
Check the result
The example assumes partner_pg is an authorized foreign catalog and its stations table has one row per ID. The date restricts local sales. Inspect the plan for remote work and transfer before assuming a predicate ran in PostgreSQL. An unmatched station disappears with this inner join.
Practice the guide skills
- Genie Code proposes a query that gives an unexpected total. Watch 47:00 · Continue at 48:17
Check your answer
Supply schema and desired grain, review the generated joins and filters in the SQL editor or notebook, and test with rows whose expected answer is known.
- A query needs to execute on a SQL warehouse. Watch 44:54
Check your answer
Check the selected warehouse, its running state, user access and catalog context. Distinguish compute start or queue time from time spent executing operators.
- Combine a Delta sales table with a remote station lookup. Watch 1:06:22 · Continue at 1:07:34
Check your answer
Query a foreign catalog through a configured connection and join on compatible keys. Inspect which filters push down and how many rows move from the remote source.
- Choose among a streaming table, materialized view and dynamic view. Watch 1:02:25 · Continue at 1:03:41 · Continue at 12:20
Check your answer
A streaming table incrementally processes input. A materialized view stores a refreshed derived result. A dynamic view evaluates logic such as user-dependent filtering at query time.
Official objectives for this lesson
Related lesson · Tables and views
Execute SQL across governed and remote sources quiz
Answer 3 questions. Check each answer for an explanation.