Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use datafusion::prelude::SessionContext;
use datafusion_postgres::{serve, ServerOptions};

// Create datafusion SessionContext
let session_context = SessionContext::new();
let session_context = Arc::new(SessionContext::new());
// Configure your `session_context`
// ...

Expand Down
3 changes: 2 additions & 1 deletion datafusion-postgres-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::ffi::OsStr;
use std::fs;
use std::sync::Arc;

use datafusion::execution::options::{
ArrowReadOptions, AvroReadOptions, CsvReadOptions, NdJsonReadOptions, ParquetReadOptions,
Expand Down Expand Up @@ -184,7 +185,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_host(opts.host)
.with_port(opts.port);

serve(session_context, &server_options)
serve(Arc::new(session_context), &server_options)
.await
.map_err(|e| format!("Failed to run server: {}", e))?;

Expand Down
3 changes: 1 addition & 2 deletions datafusion-postgres/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ pub struct DfSessionService {
}

impl DfSessionService {
pub fn new(session_context: SessionContext) -> DfSessionService {
let session_context = Arc::new(session_context);
pub fn new(session_context: Arc<SessionContext>) -> DfSessionService {
let parser = Arc::new(Parser {
session_context: session_context.clone(),
});
Expand Down
2 changes: 1 addition & 1 deletion datafusion-postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Default for ServerOptions {

/// Serve the Datafusion `SessionContext` with Postgres protocol.
pub async fn serve(
session_context: SessionContext,
session_context: Arc<SessionContext>,
opts: &ServerOptions,
) -> Result<(), std::io::Error> {
// Create the handler factory with the session context and catalog name
Expand Down
Loading