From 5e65a85bc0627810dcb2aee6ec9c20d29042d341 Mon Sep 17 00:00:00 2001 From: Andrew Gazelka Date: Mon, 9 Dec 2024 23:14:45 -0800 Subject: [PATCH] fix blocking --- Cargo.lock | 1 + src/daft-connect/Cargo.toml | 1 + src/daft-connect/src/op/execute/root.rs | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index fd01681f0b..844e77a8a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1981,6 +1981,7 @@ dependencies = [ "color-eyre", "common-daft-config", "common-file-formats", + "common-runtime", "daft-core", "daft-dsl", "daft-local-execution", diff --git a/src/daft-connect/Cargo.toml b/src/daft-connect/Cargo.toml index b1d1f63052..51e7fae1d8 100644 --- a/src/daft-connect/Cargo.toml +++ b/src/daft-connect/Cargo.toml @@ -4,6 +4,7 @@ async-stream = "0.3.6" color-eyre = "0.6.3" common-daft-config = {workspace = true} common-file-formats = {workspace = true} +common-runtime = {workspace = true} daft-core = {workspace = true} daft-dsl = {workspace = true} daft-local-execution = {workspace = true} diff --git a/src/daft-connect/src/op/execute/root.rs b/src/daft-connect/src/op/execute/root.rs index d00071522e..fb18318708 100644 --- a/src/daft-connect/src/op/execute/root.rs +++ b/src/daft-connect/src/op/execute/root.rs @@ -33,7 +33,13 @@ impl Session { tokio::spawn(async move { let execution_fut = async { let Plan { builder, psets } = translation::to_logical_plan(command).await?; - let optimized_plan = builder.optimize()?; + + // todo: convert optimize to async (looks like A LOT of work)... it touches a lot of API + // I tried and spent about an hour and gave up ~ Andrew Gazelka 🪦 2024-12-09 + let optimized_plan = tokio::task::spawn_blocking(move || builder.optimize()) + .await + .unwrap()?; + let cfg = Arc::new(DaftExecutionConfig::default()); let native_executor = NativeExecutor::from_logical_plan_builder(&optimized_plan)?; let mut result_stream = native_executor.run(psets, cfg, None)?.into_stream();