Databricks

Lakehouse Federation: Virtualize External Databases with CONNECTION, FOREIGN CATALOG & Pushdown

2026-03-26
更新: 2026-03-27
NicheeLab Editorial Team

Lakehouse Federation lets you query tables in external databases (PostgreSQL, MySQL, Snowflake, BigQuery, and more) from Databricks without moving any data. It uses Unity Catalog CONNECTION and FOREIGN CATALOG objects to virtually map external databases into the Databricks namespace, so you can access them with ordinary SQL. The biggest advantage is bringing external data into Databricks analytics without writing any ETL.

What is Lakehouse Federation?

Federation is a "don't move the data, forward the query to the external database" approach. External database tables appear to live in Databricks and are accessed through the standard three-level namespace (catalog.schema.table).

  • No data is copied: requests hit the external database in real time when the query runs
  • Read-only: only SELECT is supported. INSERT, UPDATE, and DELETE are not allowed
  • Unity Catalog integration: UC access controls (GRANT/REVOKE) apply to external tables as well
  • Pushdown optimization: WHERE-clause filters and column projection are pushed down to the external database to reduce transfer volume

Supported Databases

External databaseCONNECTION TYPEAuthenticationNotes
PostgreSQLPOSTGRESQLUsername / passwordAllow the Databricks IP range in pg_hba.conf
MySQLMYSQLUsername / passwordSSL recommended
SQL ServerSQLSERVERUsername / passwordWorks with Azure SQL Database as well
SnowflakeSNOWFLAKEUsername / passwordSpecify the Snowflake account identifier
BigQueryBIGQUERYService account JSONConnects at the GCP project level
Amazon RedshiftREDSHIFTUsername / passwordVPC peering or public access

Creating a CONNECTION

A CONNECTION is a Unity Catalog object that holds the connection details for an external database (host, port, and credentials). Creating one requires the CREATE CONNECTION privilege.

PostgreSQL

CREATE CONNECTION pg_production
TYPE POSTGRESQL
OPTIONS (
  host     'prod-db.example.com',
  port     '5432',
  user     'databricks_reader',
  password SECRET('federation-scope', 'pg-password')
);

Snowflake

CREATE CONNECTION sf_analytics
TYPE SNOWFLAKE
OPTIONS (
  host     'myorg-myaccount.snowflakecomputing.com',
  user     'DATABRICKS_SVC',
  password SECRET('federation-scope', 'sf-password'),
  sfWarehouse 'COMPUTE_WH'
);

BigQuery

CREATE CONNECTION bq_data_warehouse
TYPE BIGQUERY
OPTIONS (
  GoogleServiceAccountKeyJson SECRET('federation-scope', 'bq-sa-key')
);

The cardinal rule is to use Databricks Secrets (the SECRET function) for credentials rather than hard-coding passwords in SQL. Create the Secret Scope ahead of time with commands like databricks secrets create-scope.

Creating a FOREIGN CATALOG

A FOREIGN CATALOG uses a CONNECTION to map the schemas and tables of an external database into the Unity Catalog namespace.

-- PostgreSQLのデータベースをFOREIGN CATALOGとしてマッピング
CREATE FOREIGN CATALOG pg_catalog
USING CONNECTION pg_production
OPTIONS (database 'production_db');

-- Snowflakeのデータベースをマッピング
CREATE FOREIGN CATALOG sf_catalog
USING CONNECTION sf_analytics
OPTIONS (database 'ANALYTICS_DB');

-- BigQueryのプロジェクトをマッピング
CREATE FOREIGN CATALOG bq_catalog
USING CONNECTION bq_data_warehouse
OPTIONS (project 'my-gcp-project');

Once created, you can access these tables using the same three-level namespace as any other Unity Catalog table.

-- PostgreSQLのテーブルをクエリ
SELECT * FROM pg_catalog.public.customers WHERE region = 'APAC';

-- SnowflakeのテーブルとローカルのテーブルをクロスデータベースJOIN
SELECT
  c.customer_name,
  o.total_amount
FROM pg_catalog.public.customers c
JOIN main.gold.orders o ON c.customer_id = o.customer_id
WHERE o.order_date >= '2026-01-01';

-- BigQueryのテーブルを参照
SELECT * FROM bq_catalog.my_dataset.events LIMIT 100;

Access Control

Unity Catalog GRANT/REVOKE applies to FOREIGN CATALOG tables as well. Access is gated by two layers — the external database's native privileges and Unity Catalog privileges — so only operations allowed by both can run.

-- FOREIGN CATALOGの使用権限をグループに付与
GRANT USE CATALOG ON CATALOG pg_catalog TO data_analysts;
GRANT USE SCHEMA ON SCHEMA pg_catalog.public TO data_analysts;
GRANT SELECT ON TABLE pg_catalog.public.customers TO data_analysts;

-- CONNECTIONの管理権限
GRANT CREATE FOREIGN CATALOG ON CONNECTION pg_production TO catalog_admins;
  • Creating a CONNECTION: metastore admins or holders of the CREATE CONNECTION privilege
  • Creating a FOREIGN CATALOG: holders of the CREATE FOREIGN CATALOG privilege on the CONNECTION
  • Querying a table: requires both a UC GRANT SELECT and read access on the external database

Pushdown Optimization

When a federated query runs, some operations are pushed down to the external database. Pushdown reduces the volume of data transferred from the external database to Databricks, which improves performance.

OperationPushdownNotes
WHERE-clause filtersSupportedEquality, range, IN, and similar predicates are pushed down
Column projection (SELECT narrowing)SupportedUnused columns are not transferred
LIMIT clauseSupportedRow count is capped on the external database
JOINNot supportedProcessed on the Spark side
GROUP BY / aggregate functionsNot supportedProcessed on the Spark side
ORDER BYNot supportedSorted on the Spark side
-- プッシュダウンの確認(EXPLAIN文)
EXPLAIN FORMATTED
SELECT customer_id, customer_name
FROM pg_catalog.public.customers
WHERE region = 'APAC' AND created_at >= '2026-01-01';

-- 結果の PushedFilters セクションに
-- [region = 'APAC', created_at >= '2026-01-01'] が表示されれば
-- フィルタがプッシュダウンされている

Constraints and Caveats

  • Read-only: SELECT only. DML (INSERT/UPDATE/DELETE/MERGE) is not supported
  • Performance: transferring large volumes of data can become a network bottleneck. Filter aggressively with WHERE or periodically ingest into Delta
  • Type mapping: external database types are mapped to Spark types automatically, but some types (geometry, array, etc.) may not be supported
  • Transaction isolation: depends on the isolation level of the external database. Dirty-read potential is determined by that system's configuration
  • Network requirements: the Databricks compute plane must be able to reach the external database (VPC peering, Private Link, etc.)
  • Joins with Delta tables: you can JOIN FOREIGN CATALOG tables with local Delta tables, but all data on the external side is shipped to Spark, so joining two large tables is not recommended

Federation vs. ETL: When to Use Which

Decision criterionFederation recommendedETL (ingest into Delta) recommended
Data volumeSmall to medium (can be narrowed with filters)Large (frequently querying the full dataset)
Query frequencyLow (ad-hoc analysis, exploratory queries)High (scheduled reports, dashboards)
Freshness requirementReal-time (always need the latest)Batch (daily or hourly updates are sufficient)
PerformanceExternal database has enough resources to spareNeed fast scans and joins
Write requirementNone (read-only)Transform and persist into Delta

Real-World Operating Pattern

[外部DB: PostgreSQL / MySQL / Snowflake / BigQuery]
       │
       │  CONNECTION (認証情報はSecretで管理)
       v
[FOREIGN CATALOG] → UC名前空間にマッピング
       │
       ├── アドホック分析: SELECT ... WHERE で直接クエリ
       │     → Pushdownで転送量を最小化
       │
       └── ETLパイプライン: 定期的にDelta Lakeに取り込み
             → CTAS/MERGEでDeltaテーブルにマテリアライズ
             → 大量データの結合・集約はDelta上で高速処理

A practical hybrid pattern is to use Federation during the exploration phase, then ingest the data that proves valuable into Delta via ETL.

Check Your Understanding

Data Engineer Associate / Professional

問題 1

A data analyst wants to query a customers table in a PostgreSQL database from Databricks without copying the data, while still applying Unity Catalog access control to the external table. Which approach is best?

  1. Create a CONNECTION and use a FOREIGN CATALOG to map the external database into the UC namespace, then SELECT from it
  2. Use the JDBC driver to issue a query from Spark to PostgreSQL and read the results into a DataFrame
  3. Export the PostgreSQL data to CSV and upload it to Databricks DBFS
  4. Register PostgreSQL as a Delta Sharing recipient and share the data that way

正解: A

With Lakehouse Federation, a CONNECTION defines the connection details and a FOREIGN CATALOG maps the external database into the UC namespace. SELECT queries run without copying data, and UC GRANT/REVOKE applies. JDBC can also run queries, but UC access control would not apply. CSV export copies the data. Delta Sharing is for sharing Delta data across organizations and cannot be used to connect directly to PostgreSQL.

Frequently Asked Questions

Can I write to an external database (INSERT/UPDATE/DELETE) through Lakehouse Federation?

No. Lakehouse Federation is read-only (SELECT only). INSERT, UPDATE, and DELETE against external databases are not supported. If you need to modify external data, use the database's native interface or build a separate write path (for example, writing directly via the JDBC driver from foreachBatch).

What exactly gets pushed down to the external database with pushdown optimization?

WHERE-clause filters, column projection (limiting which SELECT columns are returned), and LIMIT clauses are all pushed down. This reduces the volume of data transferred from the external database. More complex operations like JOIN and GROUP BY are handled on the Spark side and are not pushed down. You can verify which filters were actually pushed down with the Databricks SQL EXPLAIN statement.

Is Unity Catalog required to use Lakehouse Federation?

Yes. Lakehouse Federation relies on the Unity Catalog metastore to manage CONNECTION and FOREIGN CATALOG objects, so it is only available on workspaces with Unity Catalog enabled. The upside is that external database tables fall under the same UC access controls (GRANT/REVOKE), unifying your governance model.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Databricks

Databricks Certifications: All 7 Exams, Difficulty & Study Plan (2026)

Complete guide to all 7 Databricks certifications — Data Eng...

Databricks

Databricks Exam Difficulty Ranking: All 7 Certs Compared (2026)

Every Databricks certification ranked by difficulty, with st...

Databricks

Databricks Study Guide: Fastest Pass Route & Time Estimates (2026)

How to pass Databricks certifications efficiently. Official ...

Databricks

Databricks Data Engineer Associate: Complete Guide (2026)

Domain-by-domain breakdown of the Databricks Certified Data ...

Databricks

Databricks Data Engineer Professional: Complete Guide (2026)

Tactics for the Databricks Certified Data Engineer Professio...

Browse all Databricks articles (110)
© 2026 NicheeLab All rights reserved.