Skip to content

Commit 2e1d80b

Browse files
committed
fix table lookup error
1 parent 51e1267 commit 2e1d80b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/context.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,19 @@ impl PySessionContext {
825825
}
826826

827827
pub fn table(&self, name: &str, py: Python) -> PyResult<PyDataFrame> {
828-
let x = wait_for_future(py, self.ctx.table(name))
829-
.map_err(|e| PyKeyError::new_err(e.to_string()))?
830-
.map_err(py_datafusion_err)?;
831-
Ok(PyDataFrame::new(x))
828+
let res = wait_for_future(py, self.ctx.table(name))
829+
.map_err(|e| PyKeyError::new_err(e.to_string()))?;
830+
match res {
831+
Ok(df) => Ok(PyDataFrame::new(df)),
832+
Err(e) => {
833+
if let datafusion::error::DataFusionError::Plan(msg) = &e {
834+
if msg.contains("No table named") {
835+
return Err(PyKeyError::new_err(msg.to_string()));
836+
}
837+
}
838+
Err(py_datafusion_err(e))
839+
}
840+
}
832841
}
833842

834843
pub fn table_exist(&self, name: &str) -> PyDataFusionResult<bool> {

0 commit comments

Comments
 (0)