title: 'Query Federation' sidebar_label: 'Query Federation' description: 'Learn how to use federated SQL queries in Spice.ai Open Source' sidebar_position: 1 pagination_prev: null pagination_next: null tags:
import DocCardList from '@theme/DocCardList';
Spice provides a high-performance SQL query engine built on Apache DataFusion, supporting query federation across multiple data sources including databases (PostgreSQL, MySQL), data warehouses (Databricks, Snowflake, BigQuery), and data lakes (S3, MinIO).

For a full list of supported sources, see Data Connectors.
Query federation is useful when:
Query data from PostgreSQL and S3 through a single SQL interface:
Spice supports multiple ways to execute queries:
| Protocol | Endpoint | Description |
|---|---|---|
| HTTP | /v1/sql | Execute SQL queries over HTTP |
| Arrow Flight SQL | grpc://localhost:50051 | High-performance Arrow-native queries |
| JDBC/ODBC | Flight SQL compatible | Connect from BI tools and applications |
| ADBC | Flight SQL driver | Arrow Database Connectivity |
Execute a query using the HTTP API:
Connect using Arrow Flight SQL for high-performance data transfer:
Use the Spice CLI for interactive queries:
To start using federated queries in Spice, follow these steps:
Step 1. Install Spice by following the installation instructions.
Step 2. Clone the Spice Cookbook repository and navigate to the federation directory.
Step 3. Login to the demo Dremio.
Step 4. Create a new Spice app called demo.
Step 5. Add the spiceai/fed-demo Spicepod.
Note in the Spice runtime output several datasets are loaded.
Step 6. Start the Spice runtime.
Step 7. Show available tables and query them, regardless of source.
Show the available tables:
Execute the queries:
Step 8. Join tables across remote sources and locally accelerated source
Step 9. Join tables across locally accelerated sources and query
The query in step 8 returns results from federated remote data sources, but performance is affected by network latency and data transfer overhead.
Step 9 demonstrates the same query executed against locally materialized datasets using Data Accelerators. By storing data locally, queries avoid network round-trips and achieve significantly faster response times.
:::warning[Limitations]
:::