Can I query external databases and warehouses without moving the data?
Yes. Lakehouse Federation lets you query external systems such as Snowflake, Redshift, BigQuery, PostgreSQL, MySQL, Oracle, and SQL Server in place, with automatic query pushdown. Access is governed through Unity Catalog foreign catalogs, with table-level access controls applied to the external data. Because the data stays where it is, teams avoid building separate ETL pipelines just to run analysis across systems.
How does Databricks govern business metrics for BI?
Metric views centrally define business metrics in Unity Catalog, keeping measure definitions separate from the dimensions used to group, filter, and aggregate them, so each metric is defined once and queried consistently. They can be queried from dashboards, SQL editors, notebooks, alerts, and external BI tools such as Power BI and Tableau. Genie can also use metric views to answer natural-language questions, which keeps self-service analytics grounded in approved definitions.
Does Databricks SQL support procedural scripting?
Yes, SQL scripting is available in Databricks Runtime 16.3 and above. It supports BEGIN and END compound statements, variables, and control flow such as IF, WHILE, LOOP, and FOR, with error handling through SIGNAL and RESIGNAL. Cursor statements (OPEN, FETCH, CLOSE) require Databricks Runtime 18.1 or above. See the scripting reference for the statements available in your runtime.
Can I join Databricks data with an external Postgres or MySQL database?
Yes. Lakehouse Federation lets you query PostgreSQL, MySQL, SQL Server, Snowflake, Redshift, BigQuery, and other external databases in place, with queries pushed down to the source over JDBC. You can write SQL that joins those sources with lakehouse tables without copying the data first. Check the federation docs for the release status of each connector before you use it in production.
How do I build interactive dashboards on governed lakehouse data?
AI/BI dashboards let you build interactive dashboards on Databricks data, with datasets defined from tables, views, or custom queries. Global, page-level, and widget-level filters, plus cross-filtering and drill-through, let viewers explore the data. Published dashboards can refresh on a schedule and send email or Slack subscriptions, and AI-assisted authoring helps you build visualizations.
Which external systems can Lakehouse Federation connect to?
Lakehouse Federation connects to PostgreSQL, MySQL, SQL Server, Oracle, Teradata, Snowflake, Redshift, Azure Synapse, BigQuery, and Databricks, and pushes queries down to the source over JDBC. Catalog federation also reads tables from Hive metastores and AWS Glue. Write unified SQL that joins these sources with lakehouse tables.
Can I schedule queries and set alerts in Databricks SQL?
Yes, you can schedule queries and set alerts in Databricks SQL. Alerts run a query on a schedule, evaluate a condition on the result, and move between OK, TRIGGERED and ERROR states, with an alert history for review. When a condition triggers, the alert sends notifications through configured notification destinations, such as webhooks, so an on-call system or chat tool can pick it up. This gives teams lightweight, governed monitoring on the same data they already query.
How do I migrate existing BI dashboards to Databricks AI/BI with Genie Code?
In Genie Code's Agent mode, run /importBI with a dashboard file or volume path, and Genie Code inspects the data model and proposes metric views and views that you approve before anything is built. The post recommends migrating the semantic layer first, then refining visuals one type of change at a time, with a manual checklist to validate metrics, filters, and charts. Calculated fields, data source connections, and dashboard filters migrate well, while chart types, layout, and drill-down behavior need review. Promote local metric views to Unity Catalog so dashboards, Genie Agents, and notebooks can reuse them.
What SQL data types does Databricks provide for date and time values?
Databricks SQL provides DATE for year, month, and day values without a time zone, TIMESTAMP for year-through-second values in the session local time zone, and TIMESTAMP_NTZ, whose operations ignore time zones. Use DATE for calendar dates such as order or birth dates, TIMESTAMP for events that should display in the user's session time zone, and TIMESTAMP_NTZ when values should not be adjusted for time zones.
What JOIN types does Databricks SQL support?
Databricks SQL supports standard join syntax, including inner, outer, semi, anti, and cross joins. SEMI and ANTI joins filter left rows by whether they have a match on the right without duplicating rows. Stream-stream joins support inner, left outer, right outer, full outer, and left semi, and Databricks recommends watermarks on both inputs. Range join hints can speed up slow inequality joins.
How do I replace NULLs using COALESCE in Databricks SQL?
COALESCE returns its first non-NULL argument and evaluates arguments left to right, stopping at the first non-NULL value. For example, COALESCE(NULL, 1, NULL) returns 1 and COALESCE(NULL, 'hello') returns 'hello'. All arguments must share a compatible type, so choose a default that matches the column type, such as COALESCE(col, 0) for an integer column.
Can I query Snowflake, Redshift, and BigQuery data without migrating it to Databricks?
Yes. Lakehouse Federation lets Databricks query Snowflake, Redshift, BigQuery, PostgreSQL, MySQL, Oracle, Teradata, SQL Server, and Azure Synapse without moving the data, with filters, joins, and aggregates pushed down to the source. Access is governed through Unity Catalog foreign catalogs with table-level access controls, so you can start analyzing external data now and migrate on your own schedule.
Can Databricks access data from multiple cloud providers (AWS, Azure, GCP) in one query?
Yes. Lakehouse Federation lets one Databricks SQL query join data across sources such as Redshift, Azure Synapse, and BigQuery, and across on-premises or self-hosted systems such as Oracle, Teradata, and SQL Server, with filters, joins, and aggregates pushed down to each source. Access is governed through Unity Catalog foreign catalogs, so you manage permissions in one place. This supports hybrid and phased migrations without copying the data first.
Can Databricks query Snowflake data in real-time without copying or replicating it?
Yes. Lakehouse Federation connects to Snowflake over JDBC and pushes filters, joins, aggregates, limit and offset, and sorting down to Snowflake's engine, with window functions (Rank, RowNumber, DenseRank) also pushed down. Top-N queries (sort plus limit) are pushed down on Databricks Runtime 17.3 and above, and only result sets return to Databricks. This makes Databricks a practical query layer for hybrid Snowflake environments during a migration.
Can I query BigQuery, Redshift, and Snowflake simultaneously from Databricks without replicating data?
Yes. Lakehouse Federation lets a single Databricks query span BigQuery, Redshift, Snowflake, Oracle, Teradata, MySQL, PostgreSQL, SQL Server, and Azure Synapse, with each source's part of the query pushed down to it. Access is governed through Unity Catalog foreign catalogs with table-level access controls, so permissions are managed in one place rather than in each source.
What built-in SQL functions support array and map operations?
Databricks SQL provides array_distinct, array_remove, array_contains, and array_intersect for arrays, and map_keys, map_values, map_concat, map_filter, and map_zip_with for maps. Higher-order functions transform, filter, and reduce apply functions to array elements directly in SQL. These built-in functions let you manipulate nested ARRAY and MAP columns without writing custom code.
Can I run a phased migration to Databricks instead of a risky big-bang cutover?
Yes. Lakehouse Federation lets Databricks query sources such as PostgreSQL, Oracle, Teradata, Snowflake, Redshift, and BigQuery, pushing queries down to external databases. Unity Catalog governance applies to those federated sources, so you can start analyzing and building on Databricks while legacy systems stay live. Migrating workloads incrementally reduces risk compared with a single large cutover.
Can Databricks query my PostgreSQL database without moving the data into the lakehouse?
Yes. Lakehouse Federation connects Databricks to PostgreSQL, so you can query Postgres tables through a foreign catalog without ingesting them first. Unity Catalog governance and query syntax apply to the federated tables. This helps you analyze operational data alongside lakehouse tables, or run a phased migration while Postgres stays the source of record.
Databricks vs Trino or Presto for interactive and federated queries?
Trino and Presto are strong distributed SQL engines for querying across sources. Databricks Lakehouse Federation queries many external databases and catalogs in place, including PostgreSQL, Oracle, Teradata, and Snowflake, under Unity Catalog governance. Databricks also brings Spark engineering, streaming, and AI to the same platform, so the choice depends on whether you need a query engine alone or a full platform.
How do you connect SQL Server to Databricks with Lakehouse Federation?
Lakehouse Federation supports SQL Server, Azure SQL Database, and Azure SQL Managed Instance. Create a Unity Catalog connection with CREATE CONNECTION ... TYPE sqlserver, providing the host, port, and authentication details, either in Catalog Explorer or in the SQL editor. Then run CREATE FOREIGN CATALOG <catalog> USING CONNECTION <connection> with OPTIONS (database '<database-name>') so the SQL Server tables are queryable with Unity Catalog governance. You need a Unity Catalog-enabled workspace, the CREATE CONNECTION privilege to create the connection, and CREATE CATALOG on the metastore plus connection ownership or CREATE FOREIGN CATALOG to create the foreign catalog. Compute must be Databricks Runtime 13.3 LTS or above in Standard or Dedicated access mode, or Pro or serverless SQL warehouses on 2023.40 or above.
How do you debug a slow Databricks SQL query?
Use the query profile, which visualizes the details of a query execution by operator. The DAG shows metrics such as time spent, memory peak, and rows, and the Top operators panel lists the longest-running operators. The Performance insights tab ranks opportunities by their projected effect on total task duration, and filter icons show the percent of data pruned during scanning. Look for exploding joins, full table scans, and expensive shuffles, which are common causes of slow queries, and if a query runs from the query cache it has no profile, so change it slightly, such as the LIMIT, to rerun it.
Is the system.query.history table useful for monitoring Databricks SQL queries?
Yes. The system.query.history table records queries run on SQL warehouses and on serverless compute used by notebooks, jobs, and Lakeflow pipelines, and records are typically available within one hour. It includes columns such as total_duration_ms, execution_status (FINISHED, FAILED, or CANCELED), read_bytes, spilled_local_bytes, and query_tags for cost attribution. The statement_text column is redacted unless you are an account admin or a member of the databricks_pii_access group, and by default only admins can access system tables, so share access with dynamic views for other users.
How do you monitor Databricks costs with system tables?
The system.billing.usage table centralizes your account's billable usage and routes it to all regions, and records are typically available within 12 hours. Each record includes the quantity, unit, time range, SKU, cloud, and tags, along with IDs for compute resources and jobs where applicable. Databricks provides a guide with sample queries for monitoring costs with system tables, including an hourly usage query by job_id that stays correct after corrections.
How do you use collations in Databricks SQL?
A collation is a set of rules that determines how string comparisons are performed. The default collation is UTF8_BINARY, which compares strings byte by byte on their UTF-8 representation, and UTF8_LCASE is a lightweight case-insensitive collation. Locale collations such as DE or FR_CAN, or UNICODE, can be combined with CS or CI, AS or AI, and RTRIM modifiers. Apply a collation with the COLLATE clause, for example ORDER BY col COLLATE UTF8_LCASE, and collations require Databricks Runtime 16.1 and above, with RTRIM requiring 16.2 and above.
How do you query string data that is in JSON format in Databricks?
Databricks recommends the VARIANT data type over JSON strings for semi-structured data, and VARIANT is available in Databricks Runtime 15.4 and above. Convert JSON text into a VARIANT with parse_json, then extract fields with colon paths such as raw:owner, bracket notation, or variant_get with a target type, noting that field names are case sensitive. Use try_variant_get when a cast might fail, and cast with :: or CAST for supported types. VARIANT columns cannot be used as clustering, partition, or Z-order keys, nor for comparisons, grouping, or ordering.
How do you submit a SQL query to a Databricks SQL warehouse through the REST API and get the result back?
POST the statement to /api/2.0/sql/statements with the required warehouse_id and statement fields, and optionally catalog, schema, parameters, and wait_timeout. wait_timeout accepts 0s or a value from 5 to 50 seconds, with a default of 10 seconds, and if the statement is still running the response returns a PENDING state and a statement ID. Results come back inline in JSON_ARRAY format by default, and inline results over 25 MiB fail the statement, so large results should use external links.
Can Databricks SQL alerts be used as a data quality tool?
Yes, alerts can support data quality checks. A scheduled alert runs its query, evaluates the condition, and resolves each evaluation to OK, TRIGGERED, or ERROR, and you can review past evaluations in the alert history. Write the condition as a data quality check on the query result, such as a row count or metric threshold, so a bad value triggers a notification.
What are Databricks AI/BI dashboards and what do they offer?
AI/BI dashboards let you build data visualizations and share reports with your team, with AI-assisted authoring, an enhanced visualization library, and a streamlined configuration experience. Datasets can be defined from tables, views, or custom queries, and filters can be scoped globally, per page, or per widget. Published dashboards can be shared with anyone registered to your Databricks account, even without workspace access, and they can be embedded in external sites and apps.
Where do I monitor a SQL warehouse's live activity in Databricks?
Click the name of a SQL warehouse and then the Monitoring tab to watch its live activity. Live statistics near the top of the page show warehouse status, running queries, queued queries, and the current cluster count. The peak query chart shows the maximum number of concurrent running and queued queries in each 5-minute window, and the default time range is 8 hours, with 24 hours, 7 days, 14 days, or a custom period also available.
What is Photon in Databricks SQL?
Photon is the Databricks-native vectorized query engine. It processes data in columnar batches on a C++ runtime, while Spark's Catalyst optimizer still plans the query, and it works with Spark APIs so existing code generally needs no changes. Photon is the default engine for all SQL warehouses and powers dashboards, ad hoc queries, and scheduled reports. Batch ETL and DataFrame workloads that use SQL or the DataFrame API also benefit from faster scans, joins, aggregations, and writes, and unsupported operations fall back to Spark automatically.
Does Photon accelerate stateful Structured Streaming workloads?
Photon accelerates stateless streaming, including workloads that write to a Delta or Parquet sink from sources such as Delta, Parquet, CSV, JSON, Kafka, and Kinesis. Stateful streaming is not supported by Photon, so stateful queries run on the standard Spark runtime. Photon also accelerates Lakeflow pipelines when it is enabled in the pipeline configuration.
How do I start a SQL script with procedural logic in Databricks?
A SQL script starts with a compound statement block, BEGIN ... END, which can declare local variables, cursors, user-defined conditions, and condition handlers before its body. The body can contain flow control, DDL, DML, queries, SET statements, EXECUTE IMMEDIATE, and nested compound statements. SQL scripting is available on Databricks Runtime 16.3 and above, and cursor statements require Databricks Runtime 18.1 or above.
Which control flow statements does Databricks SQL scripting support?
SQL scripting supports IF THEN ELSE, CASE, WHILE, REPEAT, LOOP, and FOR for control flow, with LEAVE to exit a loop and ITERATE to skip to the next iteration. It also includes SIGNAL and RESIGNAL for raising conditions, GET DIAGNOSTICS for condition details, and nested BEGIN ... END blocks. The cursor statements OPEN, FETCH, and CLOSE require Databricks Runtime 18.1 or above. Exception handlers can target named conditions, SQLSTATE values, a generic SQLEXCEPTION, or NOT FOUND.
Which external data sources does query federation support?
Query federation supports MySQL, PostgreSQL, Teradata, Oracle, Amazon Redshift, Salesforce Data 360, Snowflake, Microsoft SQL Server, Azure Synapse (SQL Data Warehouse), Google BigQuery, and Databricks. Catalog federation supports the legacy Databricks Hive metastore, external Hive metastores, AWS Glue, Salesforce Data 360, Snowflake, Palantir Foundry, and Workday Data Connect. Federated access is read-only, and it follows Unity Catalog privileges.
What does the COPY INTO command do in Databricks SQL?
COPY INTO loads data from a file location into a Delta table, and it is a retryable and idempotent operation. Files in the source location that have already been loaded are skipped, even if they have been modified since they were loaded. Supported file formats include CSV, JSON, AVRO, ORC, PARQUET, TEXT, and BINARYFILE.
What is Query History in Databricks SQL used for?
Query History is the record of previous query runs, and it helps you debug query issues by showing each query's status, duration, user and compute details, and full statement. Query owners can see their own runs, and other users need at least CAN VIEW permission on the SQL warehouse that ran the query. Cancel a running query with the Cancel button next to its status, and open its query profile from the details panel for execution details.
How can I filter the Query History page in Databricks SQL?
Use the filters near the top of Query History to narrow the list by user, date range, compute, duration, query status (Queued, Running, Finished, Failed, or Cancelled), statement type, statement ID, and query tags. Query tags are one of these filters, so you can isolate workloads that you tagged for cost attribution or team tracking. Statements that run on Lakeflow pipelines compute can only be canceled from the Pipelines UI.
What is the Databricks SQL Statement Execution API?
The Databricks SQL Statement Execution API 2.0 runs SQL statements on Databricks SQL warehouses over REST, with endpoints to submit a statement, get its status and results, fetch result chunks, and cancel it. A request can wait for the statement to finish up to a configured timeout, or return a statement ID immediately and let you poll for status. Results can come back inline or as external links, and the API supports parameterized queries with :name placeholders, which Databricks strongly recommends to reduce SQL injection risk.
What do wait_timeout and on_wait_timeout control in the Statement Execution API?
wait_timeout sets how long the request waits for the statement to finish, from 5 to 50 seconds with a default of 10 seconds, and 0s returns the statement ID immediately in a PENDING state. on_wait_timeout defaults to CONTINUE, which keeps the statement running and returns an ID for polling, while CANCEL stops the statement and returns a CANCELED state. The statement state can be PENDING, RUNNING, SUCCEEDED, FAILED, CANCELED, or CLOSED.
What can I do in the Databricks SQL editor?
The SQL editor lets you write, run, and analyze SQL in the Databricks UI, with autocomplete and Genie Code assistance. You can run single or multi-statement queries, browse catalogs and schemas after connecting to a SQL warehouse, and visualize, filter, and download results. Share queries with collaborators, who can edit together in real time, and review changes with version history.
What filter types can I use in AI/BI dashboards?
Field filters support single value, multiple values, date picker, date range picker, text entry, and range slider. Parameter filters support single value, multiple values, date picker, and date range. Both appear as interactive filter widgets, and the filter scope determines which visualizations each filter affects.
What is Genie in Databricks and who uses it?
Genie is the Databricks AI experience for users, giving everyone in an organization one place to ask data questions in natural language. Genie One is the simplified interface for business users to discover and interact with data assets, while Genie Agents let data teams configure trusted data, metrics, business rules, and verified answers. Genie Code is the AI coding and data assistant for developers and technical practitioners, and Genie One and Genie Agents usage by users is free through January 31, 2027.
What AI functions are built into Databricks SQL?
Databricks provides built-in AI Functions for SQL, which require Databricks Runtime 15.4 LTS or above and are not available on Classic SQL warehouses. The general-purpose function is ai_query, and document functions include ai_parse_document, ai_extract, and ai_classify. Text functions include ai_summarize, ai_translate, ai_fix_grammar, and ai_analyze_sentiment, and ai_forecast handles time series forecasting. Several functions, including ai_search, ai_enrich, and ai_decide, are in Beta.
What does CREATE PROCEDURE do in Databricks, and which runtime does it need?
CREATE PROCEDURE persists a SQL script in Unity Catalog as a procedure that takes or modifies arguments, runs SQL statements, and optionally returns a result set. It applies to Databricks SQL and Databricks Runtime 17.0 and above, and you invoke it with CALL, as in CALL add(1, 2, sum, total). Access is granted with GRANT, and the SQL SECURITY INVOKER or DEFINER characteristic controls whose authority the body runs under.
How do metric view materializations speed up queries and stay fresh?
Materialization for metric views uses materialized views to pre-compute aggregations, and Databricks refreshes them on a schedule set in the metric view's materialization configuration. The optimizer rewrites queries to a suitable materialization automatically, trying an exact match, then a rollup match, then an unaggregated match, and reading source tables if none applies. An aggregated materialization pre-computes specific dimensions and measures, while an unaggregated one materializes the full data model, and each metric view allows only one unaggregated materialization.
Can metric views define rolling seven-day totals and running totals once, in a governed way?
Yes, on Databricks Runtime 19 and above with YAML specification version 1.1 or later. Metric views support window measures, which define rolling, cumulative and current-row aggregations in one governed definition. You set an order field and a range: trailing for a rolling window, cumulative for a running total, or current with semiadditive last for a snapshot balance. Numeric offsets and ranges require an integral order column (TINYINT, SMALLINT, INT, or BIGINT), so check your order column against that rule for the range you choose.
What is Lakehouse Real-Time for AI/BI dashboards, and what are its current limits?
Lakehouse Real-Time (Beta) is a warehouse type for AI/BI dashboards that need sub-second responses for hundreds to thousands of concurrent users. It works best for selective queries that read small amounts of data. Its Beta guardrails are a 2-minute query runtime, a 1-minute default statement timeout (configurable up to 2 minutes), 300 GB of shuffle bytes written per stage, 30 GB of spill when enabled, and 10,000 files after pruning (adjustable up to 50,000); these values may change. It requires account enablement, supports only Unity Catalog managed tables and ANSI-compliant SELECT statements, and does not support Genie or local metric view materialization.
Why does a tiny SQL query still feel slow even when my SQL warehouse is already running?
The query history system table splits each statement's time into parts: waiting_for_compute_duration_ms, waiting_at_capacity_duration_ms, compilation_duration_ms, and execution_duration_ms. total_duration_ms excludes result fetch time, which the table reports separately in result_fetch_duration_ms, so compare it with your client's wall-clock timing. If the waiting columns are near zero, the remaining time sits in compilation, execution, or result fetch, and the breakdown shows which one.
Do lakehouses really match traditional warehouses on SQL feature depth and performance?
Databricks SQL runs on the same lakehouse data as your notebooks and pipelines, using serverless SQL warehouses with Photon as the execution engine. Photon is a native C++ vectorized runtime: Spark's Catalyst optimizer still plans the query, and Photon executes it, with the greatest benefit on longer-running queries over large datasets. If Photon cannot run part of an operation, it falls back to the Spark runtime for the rest of that operation, so you do not rewrite SQL to use it. The honest gap is that Photon does not accelerate UDFs or RDD and Dataset APIs, so check feature coverage and performance against your own SQL and procedural workload with a proof of concept.