Skip to content

Commit 92f8a66

Browse files
abarmatMaxteabag
andauthored
Add Apache Arrow Flight SQL adapter (#51)
* Add an Apache Flight adapter * delete old --------- Co-authored-by: Peter Adams <18162810+Maxteabag@users.noreply.github.com>
1 parent bb761c2 commit 92f8a66

File tree

15 files changed

+1814
-268
lines changed

15 files changed

+1814
-268
lines changed

CONTRIBUTING.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pytest tests/ -v -k sqlite
4040

4141
### Full Test Suite (Requires Docker)
4242

43-
To run the complete test suite including SQL Server, PostgreSQL, MySQL, MariaDB, FirebirdSQL, Oracle, ClickHouse, Turso (libsql), D1 (miniflare), SSH tunnel, DuckDB, and CockroachDB tests:
43+
To run the complete test suite including SQL Server, PostgreSQL, MySQL, MariaDB, FirebirdSQL, Oracle, ClickHouse, Turso (libsql), D1 (miniflare), SSH tunnel, DuckDB, CockroachDB, and Flight SQL tests:
4444

4545
1. Start the test database containers:
4646
```bash
@@ -76,6 +76,7 @@ pytest tests/ -v -k PostgreSQL # PostgreSQL only
7676
pytest tests/ -v -k MySQL # MySQL only
7777
pytest tests/ -v -k cockroach # CockroachDB only
7878
pytest tests/ -v -k firebird # FirebirdSQL only
79+
pytest tests/ -v -k flight # Flight SQL only
7980
```
8081

8182
### Environment Variables
@@ -175,6 +176,15 @@ The database tests can be configured with these environment variables:
175176
| `ORACLE11G_CLIENT_MODE` | `thick` | Oracle client mode |
176177
| `ORACLE11G_CLIENT_LIB_DIR` | `` | Oracle Instant Client library directory |
177178

179+
**Flight SQL:**
180+
| Variable | Default | Description |
181+
|----------|---------|-------------|
182+
| `FLIGHT_HOST` | `localhost` | Flight SQL server hostname |
183+
| `FLIGHT_PORT` | `31337` | Flight SQL server port |
184+
| `FLIGHT_USER` | `` | Flight SQL username (optional) |
185+
| `FLIGHT_PASSWORD` | `` | Flight SQL password (optional) |
186+
| `FLIGHT_DATABASE` | `` | Flight SQL database/catalog (optional) |
187+
178188
### CockroachDB Quickstart (Docker)
179189

180190
1. Start the included CockroachDB container:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
---
2626

2727
### Connect
28-
Supports all major databases: SQL Server, PostgreSQL, MySQL, SQLite, MariaDB, FirebirdSQL, Oracle, DuckDB, CockroachDB, ClickHouse, Snowflake, Supabase, CloudFlare D1, Turso, Athena, BigQuery and Redshift.
28+
Supports all major databases: SQL Server, PostgreSQL, MySQL, SQLite, MariaDB, FirebirdSQL, Oracle, DuckDB, CockroachDB, ClickHouse, Snowflake, Supabase, CloudFlare D1, Turso, Athena, BigQuery, RedShift and Apache Flight SQL.
2929

3030
![Database Providers](docs/demos/demo-providers.gif)
3131

@@ -252,6 +252,7 @@ Most of the time you can just run `sqlit` and connect. If a Python driver is mis
252252
| Snowflake | `snowflake-connector-python` | `pipx inject sqlit-tui snowflake-connector-python` | `python -m pip install snowflake-connector-python` |
253253
| Firebird | `firebirdsql` | `pipx inject sqlit-tui firebirdsql` | `python -m pip install firebirdsql` |
254254
| Athena | `pyathena` | `pipx inject sqlit-tui pyathena` | `python -m pip install pyathena` |
255+
| Apache Arrow Flight SQL | `adbc-driver-flightsql` | `pipx inject sqlit-tui adbc-driver-flightsql` | `python -m pip install adbc-driver-flightsql` |
255256

256257
### SSH Tunnel Support
257258

infra/docker/docker-compose.test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,20 @@ services:
264264
timeout: 5s
265265
retries: 10
266266
start_period: 10s
267+
268+
# Flight SQL server (using voltrondata/sqlflite - Flight SQL over DuckDB)
269+
flight-sql:
270+
image: voltrondata/sqlflite:latest
271+
container_name: sqlit-test-flight-sql
272+
environment:
273+
TLS_ENABLED: "0"
274+
SQLFLITE_PASSWORD: "test_password"
275+
PRINT_QUERIES: "1"
276+
ports:
277+
- "31337:31337"
278+
healthcheck:
279+
test: ["CMD", "nc", "-vz", "localhost", "31337"]
280+
interval: 5s
281+
timeout: 5s
282+
retries: 10
283+
start_period: 10s

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ all = [
5656
"paramiko>=2.0.0,<4.0.0",
5757
"snowflake-connector-python>=3.7.0",
5858
"pyathena>=3.22.0",
59+
"adbc-driver-flightsql>=1.0.0",
5960
]
6061
postgres = ["psycopg2-binary>=2.9.0"]
6162
cockroachdb = ["psycopg2-binary>=2.9.0"]
@@ -75,6 +76,7 @@ turso = ["libsql>=0.1.0"]
7576
firebird = ["firebirdsql>=1.3.5"]
7677
snowflake = ["snowflake-connector-python>=3.7.0"]
7778
athena = ["pyathena>=3.22.0"]
79+
flight = ["adbc-driver-flightsql>=1.0.0"]
7880
ssh = [
7981
"sshtunnel>=0.4.0",
8082
"paramiko>=2.0.0,<4.0.0",
@@ -180,6 +182,7 @@ markers = [
180182
"oracle: Oracle database tests",
181183
"firebird: Firebird database tests",
182184
"clickhouse: ClickHouse database tests",
185+
"flight: Apache Arrow Flight SQL database tests",
183186
"asyncio: async tests",
184187
"integration: integration tests (may require external services)",
185188
]
@@ -230,6 +233,10 @@ module = [
230233
"prestodb.dbapi",
231234
"prestodb.auth",
232235
"pyarrow",
236+
"pyarrow.flight",
237+
"adbc_driver_flightsql",
238+
"adbc_driver_flightsql.dbapi",
239+
"adbc_driver_manager",
233240
"textual_fastdatatable"
234241
]
235242
ignore_missing_imports = true

sqlit/domains/connections/domain/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class DatabaseType(str, Enum):
1717
DUCKDB = "duckdb"
1818
DB2 = "db2"
1919
FIREBIRD = "firebird"
20+
FLIGHT = "flight"
2021
HANA = "hana"
2122
MARIADB = "mariadb"
2223
MSSQL = "mssql"
@@ -59,6 +60,7 @@ class DatabaseType(str, Enum):
5960
DatabaseType.D1,
6061
DatabaseType.ATHENA,
6162
DatabaseType.FIREBIRD,
63+
DatabaseType.FLIGHT,
6264
]
6365

6466

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Apache Arrow Flight SQL provider."""
2+
3+
from sqlit.domains.connections.providers.flight.provider import SPEC
4+
5+
__all__ = ["SPEC"]

0 commit comments

Comments
 (0)