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 = "0.12.1"

or enables Python plugin feature:

[dependencies]
datafusion-server = { version = "0.12.1", features = ["plugin"] }

Example of call the DataFusion Server entry function

Configuration programatically.

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
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_grpc_portListening port for Flight gRPC50051
server.base_urlURL prefix/
server.data_dirStatic data source directory./data
server.plugin_dirPython plugin directory./plugin
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