Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ impl PyCatalog {
match self.catalog.schema(name) {
Some(database) => Ok(PyDatabase::new(database)),
None => Err(PyKeyError::new_err(format!(
"Database with name {} doesn't exist.",
name
"Database with name {name} doesn't exist."
))),
}
}
Expand All @@ -94,7 +93,7 @@ impl PyDatabase {
if let Some(table) = wait_for_future(py, self.database.table(name)) {
Ok(PyTable::new(table))
} else {
Err(DataFusionError::Common(format!("Table not found: {}", name)).into())
Err(DataFusionError::Common(format!("Table not found: {name}")).into())
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,7 @@ fn convert_table_partition_cols(
.map(|(name, ty)| match ty.as_str() {
"string" => Ok((name, DataType::Utf8)),
_ => Err(DataFusionError::Common(format!(
"Unsupported data type '{}' for partition column",
ty
"Unsupported data type '{ty}' for partition column"
))),
})
.collect::<Result<Vec<_>, _>>()
Expand Down
3 changes: 1 addition & 2 deletions src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ impl PyDataFrame {
"anti" => JoinType::LeftAnti,
how => {
return Err(DataFusionError::Common(format!(
"The join type {} does not exist or is not implemented",
how
"The join type {how} does not exist or is not implemented"
))
.into());
}
Expand Down
14 changes: 7 additions & 7 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ pub enum DataFusionError {
impl fmt::Display for DataFusionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
DataFusionError::ExecutionError(e) => write!(f, "DataFusion error: {:?}", e),
DataFusionError::ArrowError(e) => write!(f, "Arrow error: {:?}", e),
DataFusionError::PythonError(e) => write!(f, "Python error {:?}", e),
DataFusionError::Common(e) => write!(f, "{}", e),
DataFusionError::ExecutionError(e) => write!(f, "DataFusion error: {e:?}"),
DataFusionError::ArrowError(e) => write!(f, "Arrow error: {e:?}"),
DataFusionError::PythonError(e) => write!(f, "Python error {e:?}"),
DataFusionError::Common(e) => write!(f, "{e}"),
}
}
}
Expand Down Expand Up @@ -72,13 +72,13 @@ impl From<DataFusionError> for PyErr {
impl Error for DataFusionError {}

pub fn py_type_err(e: impl Debug) -> PyErr {
PyErr::new::<pyo3::exceptions::PyTypeError, _>(format!("{:?}", e))
PyErr::new::<pyo3::exceptions::PyTypeError, _>(format!("{e:?}"))
}

pub fn py_runtime_err(e: impl Debug) -> PyErr {
PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!("{:?}", e))
PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!("{e:?}"))
}

pub fn py_datafusion_err(e: impl Debug) -> PyErr {
PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!("{:?}", e))
PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!("{e:?}"))
}
15 changes: 5 additions & 10 deletions src/pyarrow_filter_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ fn operator_to_py<'py>(
Operator::Or => op.getattr("or_")?,
_ => {
return Err(DataFusionError::Common(format!(
"Unsupported operator {:?}",
operator
"Unsupported operator {operator:?}"
)))
}
};
Expand All @@ -71,13 +70,11 @@ fn extract_scalar_list(exprs: &[Expr], py: Python) -> Result<Vec<PyObject>, Data
ScalarValue::Float64(Some(f)) => Ok(f.into_py(py)),
ScalarValue::Utf8(Some(s)) => Ok(s.into_py(py)),
_ => Err(DataFusionError::Common(format!(
"PyArrow can't handle ScalarValue: {:?}",
v
"PyArrow can't handle ScalarValue: {v:?}"
))),
},
_ => Err(DataFusionError::Common(format!(
"Only a list of Literals are supported got {:?}",
expr
"Only a list of Literals are supported got {expr:?}"
))),
})
.collect();
Expand Down Expand Up @@ -117,8 +114,7 @@ impl TryFrom<&Expr> for PyArrowFilterExpression {
ScalarValue::Float64(Some(f)) => Ok(pc.getattr("scalar")?.call1((*f,))?),
ScalarValue::Utf8(Some(s)) => Ok(pc.getattr("scalar")?.call1((s,))?),
_ => Err(DataFusionError::Common(format!(
"PyArrow can't handle ScalarValue: {:?}",
v
"PyArrow can't handle ScalarValue: {v:?}"
))),
},
Expr::BinaryExpr(BinaryExpr { left, op, right }) => {
Expand Down Expand Up @@ -180,8 +176,7 @@ impl TryFrom<&Expr> for PyArrowFilterExpression {
Ok(if *negated { invert.call1((ret,))? } else { ret })
}
_ => Err(DataFusionError::Common(format!(
"Unsupported Datafusion expression {:?}",
expr
"Unsupported Datafusion expression {expr:?}"
))),
};
Ok(PyArrowFilterExpression(pc_expr?.into()))
Expand Down
12 changes: 6 additions & 6 deletions src/udaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ impl RustAccumulator {
impl Accumulator for RustAccumulator {
fn state(&self) -> Result<Vec<ScalarValue>> {
Python::with_gil(|py| self.accum.as_ref(py).call_method0("state")?.extract())
.map_err(|e| DataFusionError::Execution(format!("{}", e)))
.map_err(|e| DataFusionError::Execution(format!("{e}")))
}

fn evaluate(&self) -> Result<ScalarValue> {
Python::with_gil(|py| self.accum.as_ref(py).call_method0("evaluate")?.extract())
.map_err(|e| DataFusionError::Execution(format!("{}", e)))
.map_err(|e| DataFusionError::Execution(format!("{e}")))
}

fn update_batch(&mut self, values: &[ArrayRef]) -> Result<()> {
Expand All @@ -64,7 +64,7 @@ impl Accumulator for RustAccumulator {
self.accum
.as_ref(py)
.call_method1("update", py_args)
.map_err(|e| DataFusionError::Execution(format!("{}", e)))?;
.map_err(|e| DataFusionError::Execution(format!("{e}")))?;

Ok(())
})
Expand All @@ -78,13 +78,13 @@ impl Accumulator for RustAccumulator {
let state = state
.data()
.to_pyarrow(py)
.map_err(|e| DataFusionError::Execution(format!("{}", e)))?;
.map_err(|e| DataFusionError::Execution(format!("{e}")))?;

// 2. call merge
self.accum
.as_ref(py)
.call_method1("merge", (state,))
.map_err(|e| DataFusionError::Execution(format!("{}", e)))?;
.map_err(|e| DataFusionError::Execution(format!("{e}")))?;

Ok(())
})
Expand All @@ -100,7 +100,7 @@ pub fn to_rust_accumulator(accum: PyObject) -> AccumulatorFunctionImplementation
let accum = Python::with_gil(|py| {
accum
.call0(py)
.map_err(|e| DataFusionError::Execution(format!("{}", e)))
.map_err(|e| DataFusionError::Execution(format!("{e}")))
})?;
Ok(Box::new(RustAccumulator::new(accum)))
})
Expand Down
2 changes: 1 addition & 1 deletion src/udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn to_rust_function(func: PyObject) -> ScalarFunctionImplementation {
let value = func
.as_ref(py)
.call(py_args, None)
.map_err(|e| DataFusionError::Execution(format!("{:?}", e)))?;
.map_err(|e| DataFusionError::Execution(format!("{e:?}")))?;

// 3. cast to arrow::array::Array
let array_data = ArrayData::from_pyarrow(value).unwrap();
Expand Down
5 changes: 2 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ pub(crate) fn parse_volatility(value: &str) -> Result<Volatility, DataFusionErro
"volatile" => Volatility::Volatile,
value => {
return Err(DataFusionError::Common(format!(
"Unsupportad volatility type: `{}`, supported \
values are: immutable, stable and volatile.",
value
"Unsupportad volatility type: `{value}`, supported \
values are: immutable, stable and volatile."
)))
}
})
Expand Down