Skip to content

Commit 9cb4882

Browse files
committed
Revert "pull breaking changes from column capture draft PR"
This reverts commit 5b42e48.
1 parent c6324c4 commit 9cb4882

3 files changed

Lines changed: 8 additions & 39 deletions

File tree

datafusion/expr/src/higher_order_function.rs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{ColumnarValue, Documentation, Expr};
2222
use arrow::array::{ArrayRef, RecordBatch};
2323
use arrow::datatypes::{DataType, FieldRef, Schema};
2424
use datafusion_common::config::ConfigOptions;
25-
use datafusion_common::{Result, ScalarValue, exec_err, not_impl_err};
25+
use datafusion_common::{Result, ScalarValue, not_impl_err};
2626
use datafusion_expr_common::dyn_eq::{DynEq, DynHash};
2727
use datafusion_expr_common::signature::Volatility;
2828
use datafusion_physical_expr_common::physical_expr::PhysicalExpr;
@@ -208,45 +208,20 @@ pub struct LambdaArgument {
208208
/// For example, for `array_transform([2], v -> -v)`,
209209
/// this will be the physical expression of `-v`
210210
body: Arc<dyn PhysicalExpr>,
211-
/// A RecordBatch with the captured columns inside the lambda body, if any
212-
///
213-
/// For example, for `array_transform([2], v -> v + a + b)`,
214-
/// this will be a `RecordBatch` with columns `a` and `b`
215-
captures: Option<RecordBatch>,
216211
}
217212

218213
impl LambdaArgument {
219-
/// Create a new LambdaArgument
220-
///
221-
/// Note that capture is not supported yet and must be `None` for now,
222-
/// otherwise [LambdaArgument::evaluate] will fail
223-
pub fn new(
224-
params: Vec<FieldRef>,
225-
body: Arc<dyn PhysicalExpr>,
226-
captures: Option<RecordBatch>,
227-
) -> Self {
228-
Self {
229-
params,
230-
body,
231-
captures,
232-
}
214+
pub fn new(params: Vec<FieldRef>, body: Arc<dyn PhysicalExpr>) -> Self {
215+
Self { params, body }
233216
}
234217

235218
/// Evaluate this lambda
236219
/// `args` should evaluate to the value of each parameter
237220
/// of the correspondent lambda returned in [HigherOrderUDF::lambda_parameters].
238-
///
239-
/// `adjust` should adjust the length of captured columns of this
240-
/// lambda relative to it's parameters
241221
pub fn evaluate(
242222
&self,
243223
args: &[&dyn Fn() -> Result<ArrayRef>],
244-
_adjust: impl FnOnce(&[ArrayRef]) -> Result<Vec<ArrayRef>>,
245224
) -> Result<ColumnarValue> {
246-
if self.captures.is_some() {
247-
return exec_err!("lambda column capture is not supported yet");
248-
}
249-
250225
let columns = args
251226
.iter()
252227
.take(self.params.len())

datafusion/functions-nested/src/array_transform.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use arrow::{
2222
datatypes::{DataType, Field, FieldRef},
2323
};
2424
use datafusion_common::{
25-
Result, ScalarValue, exec_err, not_impl_err, plan_err,
25+
Result, ScalarValue, exec_err, plan_err,
2626
utils::{adjust_offsets_for_slice, list_values, take_function_args},
2727
};
2828
use datafusion_expr::{
@@ -203,11 +203,7 @@ impl HigherOrderUDF for ArrayTransform {
203203

204204
// call the transforming lambda
205205
let transformed_values = lambda
206-
.evaluate(&[&values_param], |_| {
207-
not_impl_err!(
208-
"array_transform column capture support is not implemented yet"
209-
)
210-
})?
206+
.evaluate(&[&values_param])?
211207
.into_array(list_values.len())?;
212208

213209
let field = match args.return_field.data_type() {

datafusion/physical-expr/src/higher_order_function.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ impl PhysicalExpr for HigherOrderFunctionExpr {
340340
Ok(ValueOrLambda::Lambda(LambdaArgument::new(
341341
params,
342342
Arc::clone(lambda.body()),
343-
None,
344343
)))
345344
} else {
346345
let value = arg.evaluate(batch)?;
@@ -536,10 +535,9 @@ mod tests {
536535
args: HigherOrderFunctionArgs,
537536
) -> Result<ColumnarValue> {
538537
match &args.args[0] {
539-
ValueOrLambda::Lambda(lambda) => lambda.evaluate(
540-
&[&|| Ok(Arc::new(NullArray::new(args.number_rows)))],
541-
|_| unimplemented!("mock_function"),
542-
),
538+
ValueOrLambda::Lambda(lambda) => {
539+
lambda.evaluate(&[&|| Ok(Arc::new(NullArray::new(args.number_rows)))])
540+
}
543541
ValueOrLambda::Value(value) => Ok(value.clone()),
544542
}
545543
}

0 commit comments

Comments
 (0)