Skip to content

Commit f72830f

Browse files
timsaucerclaude
andcommitted
Raise KeyError from table_provider for consistency with table()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0cfcbb4 commit f72830f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

crates/core/src/context.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,8 +1086,10 @@ impl PySessionContext {
10861086
self.ctx.remove_optimizer_rule(name)
10871087
}
10881088

1089-
pub fn table_provider(&self, name: &str, py: Python) -> PyDataFusionResult<PyTable> {
1090-
let provider = wait_for_future(py, self.ctx.table_provider(name))??;
1089+
pub fn table_provider(&self, name: &str, py: Python) -> PyResult<PyTable> {
1090+
let provider = wait_for_future(py, self.ctx.table_provider(name))
1091+
.map_err(|e| PyKeyError::new_err(e.to_string()))?
1092+
.map_err(|e| PyKeyError::new_err(e.to_string()))?;
10911093
Ok(PyTable { table: provider })
10921094
}
10931095

python/tests/test_context.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,11 @@ def test_table_provider(ctx):
593593
assert tbl.schema == pa.schema([("x", pa.int64())])
594594

595595

596+
def test_table_provider_not_found(ctx):
597+
with pytest.raises(KeyError):
598+
ctx.table_provider("nonexistent_table")
599+
600+
596601
def test_read_json(ctx):
597602
path = pathlib.Path(__file__).parent.resolve()
598603

0 commit comments

Comments
 (0)