Skip to content

Commit 3b194f3

Browse files
return not implemented error for unimplemnted variants in PyExpr::to_variant
1 parent 886a776 commit 3b194f3

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/expr.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use datafusion_expr::{
3333
};
3434

3535
use crate::common::data_type::{DataTypeMap, RexType};
36-
use crate::errors::{py_runtime_err, py_type_err, DataFusionError};
36+
use crate::errors::{py_runtime_err, py_type_err, py_unsupported_variant_err, DataFusionError};
3737
use crate::expr::aggregate_expr::PyAggregateFunction;
3838
use crate::expr::binary_expr::PyBinaryExpr;
3939
use crate::expr::column::PyColumn;
@@ -121,7 +121,8 @@ pub fn py_expr_list(expr: &[Expr]) -> PyResult<Vec<PyExpr>> {
121121
impl PyExpr {
122122
/// Return the specific expression
123123
fn to_variant(&self, py: Python) -> PyResult<PyObject> {
124-
Python::with_gil(|_| match &self.expr {
124+
Python::with_gil(|_| {
125+
match &self.expr {
125126
Expr::Alias(alias) => Ok(PyAlias::from(alias.clone()).into_py(py)),
126127
Expr::Column(col) => Ok(PyColumn::from(col.clone()).into_py(py)),
127128
Expr::ScalarVariable(data_type, variables) => {
@@ -149,8 +150,14 @@ impl PyExpr {
149150
Expr::Cast(value) => Ok(cast::PyCast::from(value.clone()).into_py(py)),
150151
Expr::TryCast(value) => Ok(cast::PyTryCast::from(value.clone()).into_py(py)),
151152
Expr::Sort(value) => Ok(sort_expr::PySortExpr::from(value.clone()).into_py(py)),
152-
Expr::ScalarFunction(_) => todo!(),
153-
Expr::WindowFunction(_) => todo!(),
153+
Expr::ScalarFunction(value) => Err(py_unsupported_variant_err(format!(
154+
"Converting Expr::ScalarFunction to a Python object is not implemented: {:?}",
155+
value
156+
))),
157+
Expr::WindowFunction(value) => Err(py_unsupported_variant_err(format!(
158+
"Converting Expr::WindowFunction to a Python object is not implemented: {:?}",
159+
value
160+
))),
154161
Expr::InList(value) => Ok(in_list::PyInList::from(value.clone()).into_py(py)),
155162
Expr::Exists(value) => Ok(exists::PyExists::from(value.clone()).into_py(py)),
156163
Expr::InSubquery(value) => {
@@ -159,18 +166,22 @@ impl PyExpr {
159166
Expr::ScalarSubquery(value) => {
160167
Ok(scalar_subquery::PyScalarSubquery::from(value.clone()).into_py(py))
161168
}
162-
Expr::Wildcard { qualifier } => {
163-
let _ = qualifier;
164-
todo!()
165-
}
169+
Expr::Wildcard { qualifier } => Err(py_unsupported_variant_err(format!(
170+
"Converting Expr::Wildcard to a Python object is not implemented : {:?}",
171+
qualifier
172+
))),
166173
Expr::GroupingSet(value) => {
167174
Ok(grouping_set::PyGroupingSet::from(value.clone()).into_py(py))
168175
}
169176
Expr::Placeholder(value) => {
170177
Ok(placeholder::PyPlaceholder::from(value.clone()).into_py(py))
171178
}
172-
Expr::OuterReferenceColumn(_, _) => todo!(),
179+
Expr::OuterReferenceColumn(data_type, column) => Err(py_unsupported_variant_err(format!(
180+
"Converting Expr::OuterReferenceColumn to a Python object is not implemented: {:?} - {:?}",
181+
data_type, column
182+
))),
173183
Expr::Unnest(value) => Ok(unnest_expr::PyUnnestExpr::from(value.clone()).into_py(py)),
184+
}
174185
})
175186
}
176187

0 commit comments

Comments
 (0)