DE Track · Module 08

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.

DimensionServerlessProClassic
Where compute livesDatabricks account (managed pool)Your cloud accountYour cloud account
Startup timeSecondsMinutesMinutes
PhotonYesYesYes
Intelligent workload management & rapid autoscalingYesNoNo
Predictive I/OYesYesNo
Remote result cache (survives restarts)YesNoNo
Best forBI, spiky concurrency, Genie, MVs/streaming tablesSteady workloads where compute must stay in your VNet/accountLegacy; cheapest entry, fewest features

Three sizing levers, and they answer different problems:

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:

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:

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:

-- 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:

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:

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:

ModeHow it worksChoose whenWatch out for
ImportData copied into the VertiPaq in-memory model on a refresh scheduleBounded data volumes, sub-second slicer interactions, offline-from-warehouse cost profileRefresh duration/frequency limits; data is stale between refreshes; model size limits
DirectQueryEvery visual interaction generates SQL against the warehouseLarge/fast-changing data, near-real-time KPIs, UC security must apply per user at query timeWarehouse becomes part of your page-load path; chatty visuals multiply query volume and DBU spend
CompositeMix per table: big facts DirectQuery, dims and aggregates imported (dual mode)Most real enterprise models — interactive feel with drill-to-detail on demandModel 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?

"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