Skip to content

Commit 04878a0

Browse files
Jeadieclaudespice
andauthored
Make cayenne-flightsql tool (spiceai#10356)
* make cayenne-flightsql tool * Fix cayenne-flightsql lint and review feedback --------- Co-authored-by: claudespice <claude@spice.ai>
1 parent 9041eae commit 04878a0

6 files changed

Lines changed: 440 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ members = [
6565
"tools/flightpublisher/",
6666
"tools/flightsubscriber/",
6767
"tools/flight-cookie-server/",
68+
"tools/cayenne-flightsql/",
6869
"tools/otelpublisher/",
6970
"tools/spicepodschema/",
7071
"tools/spiceschema",

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ build-spidapter-dev:
4444
build-spidapter:
4545
cargo build --release -p spidapter --all-features
4646

47+
.PHONY: build-cayenne-flightsql-dev
48+
build-cayenne-flightsql-dev:
49+
cargo build -p cayenne-flightsql --all-features
50+
51+
.PHONY: build-cayenne-flightsql
52+
build-cayenne-flightsql:
53+
cargo build --release -p cayenne-flightsql --all-features
54+
4755
.PHONY: ci
4856
ci:
4957
make -C bin/spice
@@ -335,6 +343,16 @@ install-spidapter: build-spidapter
335343
mkdir -p ~/.spice/bin
336344
install -m 755 target/release/spidapter ~/.spice/bin/spidapter
337345

346+
.PHONY: install-cayenne-flightsql-dev
347+
install-cayenne-flightsql-dev: build-cayenne-flightsql-dev
348+
mkdir -p ~/.spice/bin
349+
install -m 755 target/debug/cayenne-flightsql ~/.spice/bin/cayenne-flightsql
350+
351+
.PHONY: install-cayenne-flightsql
352+
install-cayenne-flightsql: build-cayenne-flightsql
353+
mkdir -p ~/.spice/bin
354+
install -m 755 target/release/cayenne-flightsql ~/.spice/bin/cayenne-flightsql
355+
338356
.PHONY: install-cli
339357
install-cli: build-cli
340358
mkdir -p ~/.spice/bin

tools/cayenne-flightsql/Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
description = "Standalone Flight SQL server with a single Cayenne catalog"
3+
edition.workspace = true
4+
homepage.workspace = true
5+
license.workspace = true
6+
name = "cayenne-flightsql"
7+
repository.workspace = true
8+
rust-version.workspace = true
9+
version.workspace = true
10+
11+
[dependencies]
12+
cayenne = { path = "../../crates/cayenne" }
13+
clap = { workspace = true, features = ["derive", "env"] }
14+
data_components = { path = "../../crates/data_components" }
15+
datafusion = { workspace = true }
16+
datafusion-flightsql = { path = "../../crates/datafusion-flightsql" }
17+
snafu = { workspace = true }
18+
tokio = { workspace = true }
19+
tonic = { workspace = true }
20+
tracing = { workspace = true }
21+
tracing-subscriber = { workspace = true, features = ["env-filter"] }
22+
util = { path = "../../crates/util" }

tools/cayenne-flightsql/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# cayenne-flightsql
2+
3+
A standalone Arrow Flight SQL server backed by a single Cayenne catalog.
4+
5+
## Run
6+
7+
```bash
8+
cargo run -p cayenne-flightsql -- \
9+
--addr 127.0.0.1:50051 \
10+
--catalog cayenne \
11+
--default-schema public
12+
```
13+
14+
## Key options
15+
16+
- `--addr` (`FLIGHTSQL_ADDR`) - listen address.
17+
- `--catalog` (`FLIGHTSQL_CATALOG`) - catalog name registered in DataFusion.
18+
- `--default-schema` (`FLIGHTSQL_DEFAULT_SCHEMA`) - schema used for unqualified table names.
19+
- `--spice-data-base-path` (`CAYENNE_SPICE_DATA_BASE_PATH`) - base path used when explicit Cayenne data/metadata directories are omitted.
20+
- `--cayenne-data-dir` / `--cayenne-metadata-dir` - explicit data + metadata directories.
21+
- `--refresh-interval-secs` (`CAYENNE_REFRESH_INTERVAL_SECS`) - optional periodic catalog refresh.
22+
23+
## Querying
24+
25+
By default, unqualified names resolve to `<catalog>.<default-schema>.<table>`.
26+
27+
On startup, if the configured `--default-schema` does not exist in Cayenne, it is created automatically.
28+
29+
If your table is in a different Cayenne namespace/schema, query with fully-qualified names:
30+
31+
```sql
32+
SELECT * FROM cayenne.analytics.events;
33+
```

0 commit comments

Comments
 (0)