8000 refactor: simplify py_obj_to_scalar_value by removing direct extracti… · kosiew/datafusion-python@d7cf099 · GitHub
[go: up one dir, main page]

Skip to content

Commit d7cf099

Browse files
committed
refactor: simplify py_obj_to_scalar_value by removing direct extraction of basic types
1 parent 3065773 commit d7cf099

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

src/utils.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,17 @@ pub(crate) fn validate_pycapsule(capsule: &Bound<PyCapsule>, name: &str) -> PyRe
8989

9090
Ok(())
9191
}
92-
/// Convert a Python object to ScalarValue using PyArrow
92+
/// Convert a Python object to ScalarValue
9393
///
9494
/// Args:
9595
/// py: Python interpreter
9696
/// obj: Python object to convert
9797
///
9898
/// Returns:
9999
/// Result containing ScalarValue representation of the Python object
100-
///
101-
/// This function handles basic Python types directly and uses PyArrow
102-
/// for complex types like datetime.
103100
pub(crate) fn py_obj_to_scalar_value(py: Python, obj: PyObject) -> PyResult<ScalarValue> {
104-
if let Ok(value) = obj.extract::<bool>(py) {
105-
return Ok(ScalarValue::Boolean(Some(value)));
106-
} else if let Ok(value) = obj.extract::<i64>(py) {
107-
return Ok(ScalarValue::Int64(Some(value)))< 8000 /span>;
108-
} else if let Ok(value) = obj.extract::<u64>(py) {
109-
return Ok(ScalarValue::UInt64(Some(value)));
110-
} else if let Ok(value) = obj.extract::<f64>(py) {
111-
return Ok(ScalarValue::Float64(Some(value)));
112-
} else if let Ok(value) = obj.extract::<String>(py) {
113-
return Ok(ScalarValue::Utf8(Some(value)));
114-
}
101+
// convert Python object to PyScalarValue to ScalarValue
115102

116-
// For datetime and other complex types, convert via PyArrow
117103
let pa = py.import("pyarrow")?;
118104

119105
// Convert Python object to PyArrow scalar

0 commit comments

Comments
 (0)
0