DataFusion Server Usage Guide
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Using crate for your project

Pre-require (MSRV)

Add DataFusion Server crate to your Cargo.toml

If you do not need the plugin feature, simply use cargo add datafusion-server or edit Cargo.toml manually.

[dependencies]
datafusion-server = "x.y.z"

or enables Python plugin feature:

[dependencies]
datafusion-server = { version = "x.y.z", features = ["plugin"] }

Refer to the next section for the configurable feature flags.

Feature flags

flagsfeature
pluginData source connector and post processor plugin
flightArrow Flight RPC client / server
avroApache Avro format for using data source
webdavHTTP extended WebDAV store
deltalakeDelta Lake integration
postgresSeamless integration with PostgreSQL database server
mysqlSeamless integration with MySQL / MariaDB database server
telemetryTrack and expose metric information to Prometheus

Example of call the DataFusion Server entry function

Configuration programmatically.

use datafusion_server::settings::Settings;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // making configuration for the DataFusion Server
    let mut settings = Settings::new()?;
    settings.server.port = 80;
    settings.log.level = "debug".to_string();

    // executing the DataFusion Server with custom configuration
    datafusion_server::execute(settings)?;

    Ok(())
}

Configuration from file.

use datafusion_server::settings::Settings;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // making configuration from file
    let config_file = std::path::PathBuf::from("./config.toml");
    let settings = Settings::new_with_file(&config_file)?;

    // executing the DataFusion Server
    datafusion_server::execute(settings)?;

    Ok(())
}

Example configuration file (config.toml).

[server]
port = 80
flight_grpc_port = 50051
metrics_address = "0.0.0.0"
metrics_port = 9100
base_url = "/"
data_dir = "./data"
plugin_dir = "./plugins"

[session]
default_keep_alive = 3600 # 1 hour
upload_limit_size = 2000 # 2GB

[log]
level = "debug"

Configuration parameters

ParameterDescriptionDefault
server.addressAcceptable host address0.0.0.0
server.portListening port for HTTP4000
server.flight_addressAcceptable host address for Flight gRPC0.0.0.0
server.flight_grpc_portListening port for Flight gRPC50051
server.metrics_addressAcceptable host address for metrics information for Prometheus127.0.0.1
server.metrics_portListening port for metrics information for Prometheus9100
server.base_urlURL prefix/
server.data_dirStatic data source directory./data
server.plugin_dirPython plugin directory./plugin
server.disable_stateful_featuresDisables stateful endpoints, like a /session/createfalse
session.default_keep_aliveDefault session timeout value in seconds3600
session.upload_limit_sizeSize limit in MB for /session/:id/datasource/upload endpoint20
log.levelLogging level (trace, debug, info, warn, error)info