Skip to content

Commit b5d87b0

Browse files
committed
refactor: update py_obj_to_scalar_value to handle errors and use extract_bound for PyArrow scalar conversion
1 parent 82bf6f4 commit b5d87b0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/dataframe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ impl PyDataFrame {
720720
columns: Option<Vec<PyBackedStr>>,
721721
py: Python,
722722
) -> PyDataFusionResult<Self> {
723-
let scalar_value = py_obj_to_scalar_value(py, value);
723+
let scalar_value = py_obj_to_scalar_value(py, value)?;
724724

725725
let cols = match columns {
726726
Some(col_names) => col_names.iter().map(|c| c.to_string()).collect(),

src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use datafusion::common::ScalarValue;
2222
use datafusion::execution::context::SessionContext;
2323
use datafusion::logical_expr::Volatility;
2424
use pyo3::exceptions::PyValueError;
25+
use pyo3::prelude::*;
2526
use pyo3::types::PyCapsule;
26-
use pyo3::{prelude::*, BoundObject};
2727
use std::future::Future;
2828
use std::sync::OnceLock;
2929
use tokio::runtime::Runtime;
@@ -123,7 +123,7 @@ pub(crate) fn py_obj_to_scalar_value(py: Python, obj: PyObject) -> PyResult<Scal
123123
let scalar = pa.call_method1("scalar", (obj,))?;
124124

125125
// Convert PyArrow scalar to PyScalarValue
126-
let py_scalar = PyScalarValue::extract(scalar.as_ref())?;
126+
let py_scalar = PyScalarValue::extract_bound(scalar.as_ref())?;
127127

128128
// Convert PyScalarValue to ScalarValue
129129
Ok(py_scalar.into())

0 commit comments

Comments
 (0)