From e31e478616e3d1295b544778fcaef0ec7d68ee8a Mon Sep 17 00:00:00 2001 From: Tim Saucer Date: Tue, 12 Nov 2024 05:32:00 -0500 Subject: [PATCH] Raise an error if method is not implemented when it is expected --- src/context.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/context.rs b/src/context.rs index 547916c4..8675e97d 100644 --- a/src/context.rs +++ b/src/context.rs @@ -28,7 +28,7 @@ use object_store::ObjectStore; use url::Url; use uuid::Uuid; -use pyo3::exceptions::{PyKeyError, PyTypeError, PyValueError}; +use pyo3::exceptions::{PyKeyError, PyNotImplementedError, PyTypeError, PyValueError}; use pyo3::prelude::*; use crate::catalog::{PyCatalog, PyTable}; @@ -582,8 +582,13 @@ impl PySessionContext { let provider: ForeignTableProvider = provider.into(); let _ = self.ctx.register_table(name, Arc::new(provider))?; + + Ok(()) + } else { + Err(PyNotImplementedError::new_err( + "__datafusion_table_provider__ does not exist on Table Provider object.", + )) } - Ok(()) } pub fn register_record_batches(