Databricks SQL & the Semantic Layer
Warehouses, AI/BI, Genie, and the BI-integration questions his background answers better than most.
Why this module punches above its weight for you
Databricks SQL (DBSQL) is where the Data Intelligence Platform meets the business: SQL warehouses serve BI tools, AI/BI Dashboards replace standalone reporting stacks, and Genie turns curated data into natural-language answers. Most data engineers treat this layer as someone else's problem. You can't afford to — and you shouldn't want to, because this is the module where your Power BI, SSAS/AAS, Dremio, and production Genie experience converts directly into interview answers nobody else in the room can give.
SQL warehouses: serverless vs pro vs classic
A SQL warehouse is the compute that runs DBSQL queries. It is still Spark under the hood — with Photon, the C++ vectorized engine, doing the heavy lifting — but presented as a T-shirt-sized, autoscaling endpoint instead of a cluster you configure node by node.
| Dimension | Serverless | Pro | Classic |
|---|---|---|---|
| Where compute lives | Databricks account (managed pool) | Your cloud account | Your cloud account |
| Startup time | Seconds | Minutes | Minutes |
| Photon | Yes | Yes | Yes |
| Intelligent workload management & rapid autoscaling | Yes | No | No |
| Predictive I/O | Yes | Yes | No |
| Remote result cache (survives restarts) | Yes | No | No |
| Best for | BI, spiky concurrency, Genie, MVs/streaming tables | Steady workloads where compute must stay in your VNet/account | Legacy; cheapest entry, fewest features |
Three sizing levers, and they answer different problems:
- Size (2X-Small → 4X-Large) scales up: each step roughly doubles compute. Pick a bigger size when individual queries are slow — large scans, heavy joins, disk spill in the query profile.
- Min/max clusters scales out: the warehouse adds clusters of the same size and load-balances queries across them. Raise max clusters when queries are individually fast but queue under concurrency (rule of thumb: plan for roughly ten concurrent queries per cluster).
- Auto-stop controls idle cost. Serverless starts in seconds, so an aggressive auto-stop (a few minutes) is nearly free in user experience; pro and classic take minutes to warm up, so cutting auto-stop too low just trades compute cost for angry dashboard users at 9am.
Memorize the diagnostic split: queuing → scale out (more clusters); slow individual queries → scale up (bigger size). Interviewers use warehouse sizing as a quick filter, and most candidates blur the two. Add that serverless intelligent workload management partially automates this, and you sound like you have run it, not read it.
Queries, alerts, and AI/BI Dashboards
The DBSQL surface area beyond warehouses:
- Queries — saved, parameterized SQL with scheduled refresh; the building block for alerts and legacy dashboards.
- Alerts — a query evaluated on a schedule, firing a notification (email, webhook, Slack/Teams via destinations) when a condition is met. Cheap operational monitoring: row-count drops, freshness SLAs, KPI thresholds.
- AI/BI Dashboards — the current name (they were briefly "Lakeview"; that name now survives only in the API namespace, and the older DBSQL dashboards are "legacy dashboards"). Built on datasets defined in the dashboard, with cross-filtering, publishing with embedded credentials, and Genie integration so consumers can ask follow-up questions of a curated dashboard.
Genie spaces: NL-to-SQL you can actually govern
AI/BI Genie (GA since June 2025) lets business users ask natural-language questions against a curated set of Unity Catalog tables. The word that matters is curated. A Genie space is not "point an LLM at the catalog" — it is a scoped, instructed, evaluated semantic surface:
- Scope: you pick a small set of tables/views. UC column comments, descriptions, and primary/foreign key metadata become the model's grounding.
- Instructions: plain-text business rules — "headcount means active employees only", "fiscal year starts in July", which filters to apply by default.
- Example queries: question→SQL pairs that teach the space your join paths and metric definitions.
- Trusted assets: parameterized queries or UC SQL functions you mark as trusted. When a user's question matches one, Genie executes your vetted logic instead of free-generating SQL — deterministic answers for the questions that matter most.
- Evaluation: benchmark question sets and user feedback (thumbs up/down) let you measure accuracy before and after you widen the audience.
And the design decision that builds trust: Genie shows the generated SQL with every answer. An analyst can expand the query, sanity-check the joins and filters, and escalate when something looks wrong. That turns a black-box chatbot into an auditable analytics tool.
At ADM you built and shipped a production Genie Space agent for Corporate Headcount & Salaries analytics over HR data (PeopleSoft + SAP labor data) — one of three GenAI agents you delivered, hosted as a Databricks App with a custom Streamlit UI, an embedded Genie space, Databricks dashboards, and Unity Catalog row- and column-level permissions protecting HR-sensitive fields. You deliberately surfaced the generated SQL to users so HR analysts could verify the logic behind every answer — exactly the trust mechanism interviewers ask about. Very few candidates have taken Genie from demo to production over salary data; lead with the governance story (UC RLS/column masking meant the agent could never leak what the user couldn't already see) and the curation loop (instructions and example queries tuned against real HR questions).
"How would you make business users trust a text-to-SQL agent over sensitive data?"
Outline: (1) Scope a Genie space to a curated Gold layer, never raw tables. (2) Ground it with UC comments, instructions, and example queries; promote the highest-stakes questions to trusted assets so they run vetted, parameterized SQL. (3) Enforce security in the platform, not the prompt — Unity Catalog row- and column-level permissions apply to Genie's queries, so the agent can only see what the asking user can see. (4) Show the generated SQL for auditability. (5) Run benchmark evaluations and monitor feedback before widening access. Then close with: "This is what I shipped at ADM for HR headcount and salary analytics."
Materialized views and streaming tables in DBSQL
DBSQL is no longer read-only serving — you can build incremental transformation logic directly in SQL:
- Materialized views (MVs) precompute a query's result and refresh it incrementally where possible. Ideal for the Gold aggregates dashboards hit hardest: consumers query the MV, not a five-table join, and the cost of computing the join is paid once per refresh instead of per query.
- Streaming tables ingest from streaming sources incrementally with exactly-once processing —
CREATE STREAMING TABLEwith aSTREAMorread_filessource gives you Auto-Loader-style incremental ingestion in pure SQL.
-- Gold aggregate for the P&L dashboard, refreshed on a schedule
CREATE MATERIALIZED VIEW finance_gold.pl_by_entity_month
SCHEDULE EVERY 1 HOUR
AS
SELECT entity, fiscal_period,
SUM(amount_usd) AS actuals,
SUM(budget_amount_usd) AS budget,
SUM(amount_usd) - SUM(budget_amount_usd) AS variance
FROM finance_silver.gl_postings g
JOIN finance_silver.dim_entity e ON g.entity_key = e.entity_key
GROUP BY entity, fiscal_period;
Both require Unity Catalog and a pro or serverless warehouse to create, and their refreshes actually execute on serverless Lakeflow Spark Declarative Pipelines infrastructure behind the scenes — the SQL surface is sugar over the same engine that runs declarative pipelines. Be straight in interviews: your production aggregations at ADM are built as Delta tables in orchestrated jobs (ADF + Lakeflow Jobs + RunMyJobs); MVs and streaming tables are lab knowledge for you, and you can articulate exactly which of your Gold tables you would convert and why (high-fanout dashboard joins with predictable refresh cadence first).
Query profile: tuning warehouse queries
Every DBSQL statement lands in Query History, and the query profile is your flame graph. Read it in this order:
- Time breakdown — scheduling/queuing vs execution vs result fetch. Heavy queuing means a concurrency problem (scale out), not a query problem.
- Pruning — files/partitions read vs pruned. Poor pruning on a large Delta table points to missing or wrong liquid clustering keys (remember: liquid clustering, ideally
CLUSTER BY AUTO, is the current recommendation for new tables — partitioning + Z-ORDER is legacy guidance). - Operator graph — exploding row counts after a join reveal fan-out mistakes; large shuffle and disk spill say the warehouse is undersized for the query shape.
- Cache and engine flags — whether the result came from cache and whether Photon executed the plan.
Result caching: know all the layers
"Why was it fast the second time?" has at least four answers, and naming them precisely is an easy credibility win:
- Query result cache (local) — exact-match results reused on the same running warehouse while the underlying data is unchanged.
- Remote result cache (serverless) — persisted result cache that survives warehouse stop/restart, so the Monday-morning dashboard storm doesn't recompute Friday's results.
- Disk cache — Parquet data files cached on the warehouse nodes' local SSDs; accelerates repeated scans of the same tables even when results differ.
- BI-tool caches — a Power BI import-mode semantic model is itself a giant cache, and dashboard tiles cache on top of that. Diagnose freshness complaints by walking the layers from the screen back to Delta.
Power BI on Databricks
The native Databricks connector in Power BI (Desktop and Service) speaks to SQL warehouses with Microsoft Entra ID SSO or OAuth — no gateway needed for cloud-to-cloud, and user-level identity flows through so Unity Catalog row filters and column masks apply per consumer. The architectural decision is storage mode:
| Mode | How it works | Choose when | Watch out for |
|---|---|---|---|
| Import | Data copied into the VertiPaq in-memory model on a refresh schedule | Bounded data volumes, sub-second slicer interactions, offline-from-warehouse cost profile | Refresh duration/frequency limits; data is stale between refreshes; model size limits |
| DirectQuery | Every visual interaction generates SQL against the warehouse | Large/fast-changing data, near-real-time KPIs, UC security must apply per user at query time | Warehouse becomes part of your page-load path; chatty visuals multiply query volume and DBU spend |
| Composite | Mix per table: big facts DirectQuery, dims and aggregates imported (dual mode) | Most real enterprise models — interactive feel with drill-to-detail on demand | Model complexity; aggregation tables must genuinely match query patterns to get hits |
Performance patterns that make DirectQuery viable: star schemas (narrow facts, conformed dimensions — DirectQuery over a wide flat table is how you DDoS your own warehouse), Power BI aggregation tables backed by DBSQL materialized views or pre-built Gold aggregates so common visuals never touch the base fact, dual-mode dimensions so slicers resolve in memory, and a dedicated warehouse for the BI workload sized for its concurrency profile.
Pitfall: treating DirectQuery as a default because "the data is always fresh." A busy report page can fire a dozen queries per user interaction; multiply by hundreds of users and you have a concurrency bill and a queuing problem that no warehouse size fixes cheaply. Default to composite: import or aggregate what is stable, DirectQuery only the paths that genuinely need live data and row-level security at source. And never demo a DirectQuery report against a warehouse with a 5-minute auto-stop on pro/classic — the first viewer of the day eats a multi-minute cold start.
Semantic layers are your deepest moat. At Maersk you migrated SSAS multidimensional cubes to Azure Analysis Services Tabular and delivered a Dremio + Power BI semantic-layer lakehouse for the Fact-Based Reporting program (SAP S/4HANA ACDOCA and HFM data into Delta on ADLS Gen2, published through Synapse) — so you have personally operated both a classic enterprise semantic model and a lakehouse query-virtualization layer, and you hold the Dremio Verified Lakehouse Associate cert. At ADM you now make the fit-gap calls — Power BI vs Dremio vs Denodo semantic layers — as part of architecture recommendations for Finance R2R, where the consumers are Executive Committee and CFO-level. When an interviewer asks "native DBSQL or external semantic layer?", you answer from having run the comparison for real stakeholders, not from a blog post.
When does an external semantic layer (Dremio/Denodo) still make sense?
- Choose native (DBSQL + UC + AI/BI) when Databricks is the center of gravity: one engine, one governance model, Genie and dashboards get the UC metadata for free, and Unity Catalog metric views (now GA) give you governed, reusable metric definitions in the catalog itself — Databricks' direct answer to the standalone semantic-layer pitch.
- Choose Dremio/Denodo when you must federate across systems that are not moving to the lakehouse soon (mainframe, multiple warehouses, operational databases), when many BI tools need one metric definition and the organization won't standardize on UC, or when query virtualization is a deliberate strategy to defer migration. Cost: another hop, another security model to reconcile with UC, another vendor.
"We have Power BI on Databricks and dashboards are slow and expensive. Walk me through your approach."
Outline: (1) Query History first — is time going to queuing (scale out / isolate the BI warehouse) or execution (profile the worst queries)? (2) Check the model: DirectQuery over a flat wide view → restructure to a star schema, move stable dims to dual mode, import or aggregate hot paths. (3) Push aggregations down: Gold aggregate tables or DBSQL materialized views matched to the report's grain, wired to Power BI aggregation tables. (4) Check pruning and clustering on the base tables (liquid clustering keys aligned to dashboard filters). (5) Then FinOps: right-size, set auto-stop, verify the result caches are actually being hit, and tag the warehouse for cost attribution. Anchor it: you orchestrate Power BI refreshes against Databricks in production at ADM today (via Redwood RunMyJobs alongside ADF and Lakeflow Jobs).
Workload isolation: separate warehouses per team
One warehouse for everything is a noisy-neighbor machine. The standard pattern is isolation by workload and team:
finance-bi-prod Serverless M, min 1 / max 4 auto-stop 10m (dashboards, exec consumers)
finance-adhoc Serverless S, min 1 / max 2 auto-stop 5m (analyst exploration)
finance-genie Serverless S, min 1 / max 2 auto-stop 5m (Genie space traffic)
finance-refresh-etl Pro L, min 1 / max 1 auto-stop 10m (Power BI refresh, alerts)
Why it works: a runaway ad-hoc query can no longer queue the CFO's dashboard; each warehouse gets a size and auto-stop tuned to its traffic shape; statement timeouts can be strict on ad-hoc and looser on refresh; and per-warehouse tags flow into system.billing.usage so chargeback per team is a query, not an argument. Connect BI-tool service principals to their own warehouse so refresh storms are visible and attributable.
Tie this module to your FinOps story: warehouse isolation plus tags is the DBSQL analog of the cluster right-sizing and autoscaling-policy work you already do at ADM. Same discipline, different compute surface — say it that way and two resume bullets become one coherent operating philosophy.
Self-check before you move on
- Queuing vs slow queries: which sizing lever fixes which?
- Name the three serverless-only advantages over pro (startup, intelligent workload management + rapid scaling, remote result cache).
- List the four Genie curation mechanisms and explain why showing generated SQL matters.
- Defend composite mode as the Power BI default for lakehouse-scale facts.
- Give one situation each where native UC metric views beat Dremio/Denodo — and one where they don't.