Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: integrate new rust sdk into python bindings #2850

Merged
merged 120 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
3a9352d
chore: rename glaredb -> cli crate
tychoish Mar 20, 2024
0cc08ec
chore: engine constructor
tychoish Mar 26, 2024
401d74e
feat: high level glaredb rust api/sdk
tychoish Mar 21, 2024
379f300
chore: refactor connection, create driver connect
tychoish Mar 27, 2024
f40c9df
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/0/ren…
tychoish Mar 28, 2024
280b9ce
Merge branch 'tycho/topic/sdk/0/rename-cli-package' into tycho/topic/…
tychoish Mar 28, 2024
64c96cf
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Mar 28, 2024
daa757d
wip
tychoish Mar 28, 2024
ae73d45
fix: merge related build failure
tychoish Mar 28, 2024
7a366fd
Merge branch 'tycho/topic/sdk/0/rename-cli-package' into tycho/topic/…
tychoish Mar 28, 2024
b92c760
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Mar 28, 2024
115d5ef
feat: implementation of the connection methods
tychoish Mar 28, 2024
7e14f4d
fix: unittest build
tychoish Mar 28, 2024
e150dc7
fix: explicit reference
tychoish Mar 28, 2024
c40fc24
Merge branch 'tycho/topic/sdk/0/rename-cli-package' into tycho/topic/…
tychoish Mar 28, 2024
1017c59
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Mar 28, 2024
c101221
fix: binary resolution
tychoish Mar 29, 2024
e1495b2
Merge branch 'tycho/topic/sdk/0/rename-cli-package' into tycho/topic/…
tychoish Mar 29, 2024
854bd8d
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Mar 29, 2024
592bda2
fix: python binding error handling
tychoish Mar 29, 2024
50070c2
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Mar 29, 2024
90f783d
fix: lint error
tychoish Mar 29, 2024
9486f21
feat: prql helpers and sync stream producers
tychoish Mar 29, 2024
f143eea
feat: addtional converter
tychoish Mar 29, 2024
a34f5db
chore: reorganization
tychoish Mar 29, 2024
e971d25
feat: iterator helpers for driver interfaces
tychoish Mar 29, 2024
6439f7e
fix: lint
tychoish Mar 29, 2024
087505b
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Mar 29, 2024
9393558
chore: integrate new driver with python connect
tychoish Mar 30, 2024
4cc0902
messy
tychoish Apr 1, 2024
dcf5ae7
Revert "feat: iterator helpers for driver interfaces"
tychoish Apr 2, 2024
851d7cd
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/0/ren…
tychoish Apr 2, 2024
a759963
Merge branch 'tycho/topic/sdk/0/rename-cli-package' into tycho/topic/…
tychoish Apr 3, 2024
c92cebd
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Apr 3, 2024
e300191
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 3, 2024
5e1fc70
fix: collapsed python implementation
tychoish Apr 3, 2024
1f64002
fix: clarify naming
tychoish Apr 3, 2024
bc67f4c
fix: python subquery references
tychoish Apr 3, 2024
50ff4b4
fix lint
tychoish Apr 4, 2024
14c7a61
chore: backport driver changes from python integration branch
tychoish Apr 5, 2024
0717d7d
feat: indirection for operations in rust SDK
tychoish Apr 5, 2024
d9890ce
Merge branch 'tycho/topic/sdk/5/operation-indirection' into tycho/top…
tychoish Apr 5, 2024
d03c26f
fix: operation output
tychoish Apr 5, 2024
74ef043
fix: backport additional features from binding integration
tychoish Apr 5, 2024
b47b1a6
Revert "chore: backport driver changes from python integration branch"
tychoish Apr 5, 2024
cbeef58
chore: backport from driver branch
tychoish Apr 5, 2024
d4f7ede
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 5, 2024
7d72e9e
fix: reverts to tests
tychoish Apr 5, 2024
b994e35
chore: port in sqlexec changes
tychoish Apr 5, 2024
5b3e287
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 5, 2024
e5fce78
fix: complete bindings fixes
tychoish Apr 5, 2024
7bebf63
chore: backport crates changes
tychoish Apr 5, 2024
2b9813d
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 5, 2024
1cfcbad
Merge branch 'main' into tycho/topic/sdk/1/engine-constructor
tychoish Apr 5, 2024
5d46218
fix: comple
tychoish Apr 7, 2024
3f8b138
fix: compile and lint
tychoish Apr 7, 2024
bd9f621
THIS IS AN EMPTY COMMIT
tychoish Apr 7, 2024
92fa346
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Apr 7, 2024
65079a9
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 7, 2024
b9b52b6
fix: non-deterministic http test
tychoish Apr 7, 2024
3402ab3
Merge branch 'tycho/fix-flaky-test' into tycho/topic/sdk/1/engine-con…
tychoish Apr 7, 2024
2903c1b
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Apr 7, 2024
b081f78
fix: non-deterministic http test
tychoish Apr 7, 2024
0823e3d
Merge branch 'main' into tycho/topic/sdk/1/engine-constructor
tychoish Apr 7, 2024
28b15a5
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Apr 7, 2024
b37802e
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 7, 2024
a67bba1
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/2/dri…
tychoish Apr 9, 2024
90b6ff7
fix: code review feedback
tychoish Apr 9, 2024
552cc1a
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/1/eng…
tychoish Apr 9, 2024
05c1ed7
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Apr 9, 2024
0bd8000
rename
tychoish Apr 9, 2024
b60cdc6
Merge branch 'tycho/topic/sdk/1/engine-constructor' into tycho/topic/…
tychoish Apr 9, 2024
82def41
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/2/dri…
tychoish Apr 9, 2024
48dbb21
fix merge
tychoish Apr 9, 2024
e780412
chore: df 36 upgrade (#2853)
universalmind303 Apr 8, 2024
7f65c84
chore: update docs links (#2852)
greyscaled Apr 8, 2024
91c9425
chore(deps): bump pymongo from 4.6.2 to 4.6.3 in /tests (#2870)
dependabot[bot] Apr 8, 2024
1954372
fix: nix agpl spec (#2833)
tychoish Apr 8, 2024
d389cd0
feat: Support cloud uploads for Excel/BSON (#2851)
vrongmeal Apr 9, 2024
a7f5b2a
fix(pytest): remove pysqlite3-binary dependency (#2872)
tychoish Apr 9, 2024
565daf9
fix: code review feedback
tychoish Apr 9, 2024
8b139f3
rename
tychoish Apr 9, 2024
3896a1b
chore: engine constructor cleanup (#2831)
tychoish Apr 9, 2024
7ff4761
rename
tychoish Apr 9, 2024
61e05f5
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 9, 2024
23603c9
fix compile
tychoish Apr 9, 2024
1ccec6c
plug in envreader differently
tychoish Apr 9, 2024
a12e401
unwinding
tychoish Apr 9, 2024
85af156
un/rewind
tychoish Apr 9, 2024
2727f10
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 9, 2024
288f713
fix lint
tychoish Apr 9, 2024
963fe8a
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 9, 2024
a680488
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/2/dri…
tychoish Apr 10, 2024
ecb5d6d
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 10, 2024
7fe4d59
fixup test
tychoish Apr 10, 2024
25aa40f
wip: remove clone
tychoish Apr 11, 2024
e5baf3c
fix: remove double box
tychoish Apr 11, 2024
1e9cc1b
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 11, 2024
34bf313
fix compile
tychoish Apr 11, 2024
0958fc9
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/2/dri…
tychoish Apr 11, 2024
9584d4d
fix lint
tychoish Apr 11, 2024
9622b79
Merge branch 'tycho/topic/sdk/2/driver-connect' into tycho/topic/sdk/…
tychoish Apr 11, 2024
08d3e02
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/4/pyt…
tychoish Apr 11, 2024
96a77f4
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/4/pyt…
tychoish Apr 11, 2024
33c128c
remove mutability
tychoish Apr 12, 2024
19bc69b
PRQL is never DDL/DML so can be fully lazy
tychoish Apr 12, 2024
2444f6c
use new operation interface
tychoish Apr 12, 2024
06faa49
fix: lazy sdk implementation
tychoish Apr 12, 2024
e4ba2ce
Merge branch 'tycho/topic/sdk/8/operation-interface' into tycho/topic…
tychoish Apr 12, 2024
eb32d64
whitespace
tychoish Apr 12, 2024
c0e2d23
rename type
tychoish Apr 12, 2024
faeca7c
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/8/ope…
tychoish Apr 12, 2024
0ecc883
backport method naming
tychoish Apr 12, 2024
d99967a
Merge remote-tracking branch 'origin/main' into tycho/topic/sdk/4/pyt…
tychoish Apr 12, 2024
22bd36d
backport
tychoish Apr 12, 2024
1a306e2
copypasta
tychoish Apr 12, 2024
40a1dcc
Merge branch 'tycho/topic/sdk/8/operation-interface' into tycho/topic…
tychoish Apr 12, 2024
2798c1d
Merge branch 'main' into tycho/topic/sdk/4/python-integration
tychoish Apr 16, 2024
2a40bd4
Merge branch 'main' into tycho/topic/sdk/4/python-integration
tychoish Apr 16, 2024
286242a
Merge branch 'main' into tycho/topic/sdk/4/python-integration
tychoish Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pgrepr = { path = "../../crates/pgrepr" }
datafusion_ext = { path = "../../crates/datafusion_ext" }
arrow_util = { path = "../../crates/arrow_util" }
terminal_util = { path = "../../crates/terminal_util" }
glaredb = { path = "../../crates/glaredb" }
datafusion = { workspace = true, features = ["pyarrow"] }
tokio = { workspace = true }
thiserror = { workspace = true }
Expand Down
91 changes: 16 additions & 75 deletions bindings/python/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,16 @@
//! queries.

use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;

use futures::lock::Mutex;
use pyo3::prelude::*;
use sqlexec::engine::{Engine, EngineStorage};
use sqlexec::remote::client::RemoteClientType;
use url::Url;

use crate::connection::Connection;
use crate::environment::PyEnvironmentReader;
use crate::error::PyGlareDbError;
use crate::runtime::wait_for_future;

#[derive(Debug, Clone)]
struct PythonSessionConf {
/// Where to store both metastore and user data.
data_dir: Option<PathBuf>,
/// URL for cloud deployment to connect to.
cloud_url: Option<Url>,
}

impl From<Option<String>> for PythonSessionConf {
fn from(value: Option<String>) -> Self {
match value {
Some(s) => match Url::parse(&s) {
Ok(u) => PythonSessionConf {
data_dir: None,
cloud_url: Some(u),
},
// Assume failing to parse a url just means the user provided a local path.
Err(_) => PythonSessionConf {
data_dir: Some(PathBuf::from(s)),
cloud_url: None,
},
},
None => PythonSessionConf {
data_dir: None,
cloud_url: None,
},
}
}
}

/// Connect to a GlareDB database.
///
/// # Examples
Expand Down Expand Up @@ -88,48 +54,23 @@ pub fn connect(
storage_options: Option<HashMap<String, String>>,
) -> PyResult<Connection> {
wait_for_future(py, async move {
let conf = PythonSessionConf::from(data_dir_or_cloud_url);

let storage = if let Some(location) = location.clone() {
EngineStorage::Remote {
location,
options: storage_options.unwrap_or_default(),
}
} else if let Some(data_dir) = conf.data_dir.clone() {
EngineStorage::Local(data_dir)
} else {
EngineStorage::Memory
};

let mut engine = Engine::from_storage(storage)
.await
.map_err(PyGlareDbError::from)?;

engine = engine
.with_spill_path(spill_path.map(|p| p.into()))
.map_err(PyGlareDbError::from)?;

let mut session = engine
.default_local_session_context()
.await
.map_err(PyGlareDbError::from)?;

session
.create_client_session(
conf.cloud_url.clone(),
cloud_addr,
disable_tls,
RemoteClientType::Python,
None,
)
.await
.map_err(PyGlareDbError::from)?;

session.register_env_reader(Some(Arc::new(PyEnvironmentReader)));

Ok(Connection {
session: Arc::new(Mutex::new(session)),
_engine: Arc::new(engine),
inner: Arc::new(
glaredb::ConnectOptionsBuilder::default()
.connection_target(data_dir_or_cloud_url.clone())
.set_storage_options(storage_options)
.location(location)
.spill_path(spill_path)
.cloud_addr(cloud_addr)
.disable_tls(disable_tls)
.client_type(RemoteClientType::Python)
.environment_reader(Arc::new(PyEnvironmentReader))
.build()
.map_err(PyGlareDbError::from)?
.connect()
.await
.map_err(PyGlareDbError::from)?,
),
})
})
}
120 changes: 42 additions & 78 deletions bindings/python/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
use std::sync::Arc;

use datafusion::logical_expr::LogicalPlan as DFLogicalPlan;
use datafusion_ext::vars::SessionVars;
use futures::lock::Mutex;
use once_cell::sync::OnceCell;
use pyo3::prelude::*;
use pyo3::types::PyType;
use sqlexec::engine::{Engine, EngineStorage, SessionStorageConfig, TrackedSession};
use sqlexec::{LogicalPlan, OperationInfo};

use crate::execution_result::PyExecutionResult;

pub(super) type PyTrackedSession = Arc<Mutex<TrackedSession>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a lot of ways, this Arc<Mutex<>> thing here serves the same purpose that the Arc<Mutex<>> around the Operation in the PyExecution object.

use sqlexec::remote::client::RemoteClientType;

use crate::environment::PyEnvironmentReader;
use crate::error::PyGlareDbError;
use crate::logical_plan::PyLogicalPlan;
use crate::execution::PyExecutionOutput;
use crate::runtime::wait_for_future;

/// A connected session to a GlareDB database.
#[pyclass]
#[derive(Clone)]
pub struct Connection {
pub(super) session: PyTrackedSession,
pub(super) _engine: Arc<Engine>,
pub(crate) inner: Arc<glaredb::Connection>,
}

impl Connection {
Expand All @@ -36,16 +28,15 @@ impl Connection {

let con = DEFAULT_CON.get_or_try_init(|| {
wait_for_future(py, async move {
let engine = Engine::from_storage(EngineStorage::Memory).await?;
let sess = engine
.new_local_session_context(
SessionVars::default(),
SessionStorageConfig::default(),
)
.await?;
Ok(Connection {
session: Arc::new(Mutex::new(sess)),
_engine: Arc::new(engine),
inner: Arc::new(
glaredb::ConnectOptionsBuilder::new_in_memory()
.client_type(RemoteClientType::Python)
.environment_reader(Arc::new(PyEnvironmentReader))
.build()?
.connect()
.await?,
),
}) as Result<_, PyGlareDbError>
})
})?;
Expand All @@ -56,12 +47,12 @@ impl Connection {

#[pymethods]
impl Connection {
fn __enter__(&mut self, _py: Python<'_>) -> PyResult<Self> {
fn __enter__(&self, _py: Python<'_>) -> PyResult<Self> {
Ok(self.clone())
}

fn __exit__(
&mut self,
&self,
py: Python<'_>,
_exc_type: Option<&PyType>,
_exc_value: Option<PyObject>,
Expand Down Expand Up @@ -110,39 +101,15 @@ impl Connection {
/// con = glaredb.connect()
/// con.sql('create table my_table (a int)').execute()
/// ```
pub fn sql(&mut self, py: Python<'_>, query: &str) -> PyResult<PyLogicalPlan> {
let cloned_sess = self.session.clone();
pub fn sql(&self, py: Python<'_>, query: &str) -> PyResult<PyExecutionOutput> {
wait_for_future(py, async move {
let mut sess = self.session.lock().await;

let plan = sess
.create_logical_plan(query)
Ok(self
.inner
.sql(query)
.evaluate()
.await
.map_err(PyGlareDbError::from)?;

let op = OperationInfo::new().with_query_text(query);

match plan
.to_owned()
.try_into_datafusion_plan()
.expect("resolving logical plan")
{
DFLogicalPlan::Extension(_)
| DFLogicalPlan::Dml(_)
| DFLogicalPlan::Ddl(_)
| DFLogicalPlan::Copy(_) => {
sess.execute_logical_plan(plan, &op)
.await
.map_err(PyGlareDbError::from)?;

Ok(PyLogicalPlan::new(
LogicalPlan::Noop,
cloned_sess,
Default::default(),
))
}
_ => Ok(PyLogicalPlan::new(plan, cloned_sess, op)),
}
.map_err(PyGlareDbError::from)?
.into())
})
}

Expand All @@ -159,14 +126,15 @@ impl Connection {
///
/// All operations execute lazily when their results are
/// processed.
pub fn prql(&mut self, py: Python<'_>, query: &str) -> PyResult<PyLogicalPlan> {
let cloned_sess = self.session.clone();
pub fn prql(&self, py: Python<'_>, query: &str) -> PyResult<PyExecutionOutput> {
wait_for_future(py, async move {
let mut sess = self.session.lock().await;
let plan = sess.prql_to_lp(query).await.map_err(PyGlareDbError::from)?;
let op = OperationInfo::new().with_query_text(query);

Ok(PyLogicalPlan::new(plan, cloned_sess, op))
Ok(self
.inner
.prql(query)
.evaluate()
.await
.map_err(PyGlareDbError::from)?
.into())
})
}

Expand All @@ -182,28 +150,24 @@ impl Connection {
/// con = glaredb.connect()
/// con.execute('create table my_table (a int)')
/// ```
pub fn execute(&mut self, py: Python<'_>, query: &str) -> PyResult<PyExecutionResult> {
let sess = self.session.clone();
let (_, exec_result) = wait_for_future(py, async move {
let mut sess = sess.lock().await;
let plan = sess
.create_logical_plan(query)
.await
.map_err(PyGlareDbError::from)?;

let op = OperationInfo::new().with_query_text(query);

sess.execute_logical_plan(plan, &op)
pub fn execute(&self, py: Python<'_>, query: &str) -> PyResult<PyExecutionOutput> {
wait_for_future(py, async move {
Ok(self
.inner
.execute(query)
.evaluate()
.await
.map_err(PyGlareDbError::from)
})?;

Ok(PyExecutionResult(exec_result))
.map_err(PyGlareDbError::from)?
.into())
})
}

/// Close the current session.
pub fn close(&mut self, _py: Python<'_>) -> PyResult<()> {
pub fn close(&self, _py: Python<'_>) -> PyResult<()> {
// TODO: Remove this method. No longer required.
//
// could we use this method to clear the environment/in memory
// database?
Ok(())
}
}
8 changes: 4 additions & 4 deletions bindings/python/src/environment.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::sync::Arc;

use datafusion::arrow::array::RecordBatch;
use datafusion::arrow::pyarrow::PyArrowType;
use datafusion::arrow::record_batch::RecordBatch;
use datafusion::datasource::{MemTable, TableProvider};
use pyo3::prelude::*;
use pyo3::types::{IntoPyDict, PyTuple, PyType};
use sqlexec::environment::EnvironmentReader;

use crate::logical_plan::PyLogicalPlan;
use crate::execution::PyExecutionOutput;

/// Read polars dataframes from the python environment.
#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -166,6 +166,6 @@ fn resolve_pandas(py: Python, var: &PyAny) -> PyResult<Option<Arc<dyn TableProvi
}

fn resolve_logical_plan(_py: Python, var: &PyAny) -> PyResult<Option<Arc<dyn TableProvider>>> {
let lp: PyLogicalPlan = var.extract()?;
Ok(Some(Arc::new(lp) as Arc<dyn TableProvider>))
let exec: PyExecutionOutput = var.extract()?;
Ok(Some(Arc::new(exec) as Arc<dyn TableProvider>))
}
20 changes: 18 additions & 2 deletions bindings/python/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::fmt::Display;

use datafusion::arrow::error::ArrowError;
use glaredb::DataFusionError;
use metastore::errors::MetastoreError;
use pyo3::exceptions::{PyException, PyRuntimeError};
use pyo3::{create_exception, PyErr};
Expand All @@ -10,12 +11,20 @@ use sqlexec::errors::ExecError;
pub enum PyGlareDbError {
#[error(transparent)]
Arrow(#[from] ArrowError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
#[error(transparent)]
DataFusion(#[from] DataFusionError),
#[error(transparent)]
PyErr(#[from] PyErr),

#[error(transparent)]
Metastore(#[from] MetastoreError),
#[error(transparent)]
Exec(#[from] ExecError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
ConfigurationBuilder(#[from] glaredb::ConnectOptionsBuilderError),

#[error("{0}")]
Other(String),
}
Expand All @@ -34,10 +43,17 @@ impl From<PyGlareDbError> for PyErr {
PyGlareDbError::Exec(err) => ExecutionException::new_err(err.to_string()),
PyGlareDbError::Anyhow(err) => PyRuntimeError::new_err(format!("{err:?}")),
PyGlareDbError::Other(msg) => PyRuntimeError::new_err(msg),
PyGlareDbError::DataFusion(err) => DataFusionErrorException::new_err(err.to_string()),
PyGlareDbError::PyErr(err) => err,
PyGlareDbError::ConfigurationBuilder(err) => {
ConfigurationException::new_err(err.to_string())
}
}
}
}

create_exception!(exceptions, ArrowErrorException, PyException);
create_exception!(exceptions, MetastoreException, PyException);
create_exception!(exceptions, ConfigurationException, PyException);
create_exception!(exceptions, DataFusionErrorException, PyException);
create_exception!(exceptions, ExecutionException, PyException);
create_exception!(exceptions, MetastoreException, PyException);
Loading