A demonstration of DataFusion's federation capabilities with a Flight SQL server that connects to MySQL, PostgreSQL, and SQLite databases simultaneously.
# Copy the environment template
cp .env.example .env
# Edit .env with your database credentials (optional)
# Default values will work with the provided docker-compose# Start MySQL and PostgreSQL containers
docker-compose up -d
# This will:
# - Start MySQL on port 3306 with sample user_table
# - Start PostgreSQL on port 5432 with sample product_table# Run the Flight SQL server
RUST_LOG=info cargo runThe server will start on 0.0.0.0:50051 by default.
The minimal storage rewrite rule demonstrates API-to-storage name transformation:
| API Name | Storage Name (Database) |
|---|---|
users |
user_table (MySQL) |
products |
product_table (PostgreSQL) |
orders |
order_table (SQLite) |
Users Table:
| API Name | Storage Name |
|---|---|
userId |
user_id |
firstName |
first_name |
lastName |
last_name |
email |
email_address |
createdAt |
created_at |
Products Table:
| API Name | Storage Name |
|---|---|
productId |
product_id |
productName |
product_name |
price |
unit_price |
ownerId |
owner_id |
stockQuantity |
stock_qty |
Orders Table:
| API Name | Storage Name |
|---|---|
orderId |
order_id |
userId |
user_id |
productId |
product_id |
orderDate |
order_date |
totalAmount |
total_amount |
Once the server is running, you can connect with any Flight SQL client and run queries using the API names:
-- This queries MySQL (user_table)
SELECT userId, firstName, lastName
FROM users
WHERE email = 'john.doe@example.com';-- Joins across MySQL, PostgreSQL, and SQLite
SELECT
u.firstName,
u.lastName,
p.productName,
o.totalAmount,
o.orderDate
FROM users u -- MySQL
JOIN orders o ON u.userId = o.userId -- SQLite
JOIN products p ON o.productId = p.productId -- PostgreSQL
WHERE o.totalAmount > 100
ORDER BY o.orderDate DESC;