Skip to content

Commit 91957d9

Browse files
committed
Fixes daft-connect table replacement
1 parent af87a4f commit 91957d9

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/daft-connect/src/execute.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,13 @@ impl ConnectSession {
234234
)
235235
})?;
236236

237-
{
238-
// TODO session should handle the pre-existence error
239-
if !replace && self.session().has_table(&name.clone().into()) {
240-
return Err(Status::internal("Dataframe view already exists"));
241-
}
237+
let session = self.session_mut();
238+
239+
if replace {
240+
_ = session.detach_table(&name);
242241
}
243242

244-
let session = self.session_mut();
245243
let view = View::from(input.build()).arced();
246-
247244
session.attach_table(view, name).map_err(|e| {
248245
Status::internal(textwrap::wrap(&format!("Error in Daft server: {e}"), 120).join("\n"))
249246
})?;

src/daft-sql/src/python.rs

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ impl SQLFunctionStub {
3434
}
3535
}
3636

37-
// TODO replace with session.exec to invert responsibilities
3837
#[pyfunction]
3938
pub fn sql(
4039
sql: &str,

tests/connect/test_basics.py

+2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ def test_show(spark_session, capsys):
241241
"│ 9 │\n"
242242
"╰───────╯\n"
243243
)
244+
# This may fail locally depending on your terminal and how you run the test.
245+
# The show() command uses ANSI escape sequences to make the header bold.
244246
assert captured.out == expected
245247

246248

0 commit comments

Comments
 (0)