Skip to content

Commit c111d03

Browse files
committed
chore(CI) Update workspace / CI to Rust 1.87
1 parent 64fb51f commit c111d03

File tree

33 files changed

+130
-142
lines changed

33 files changed

+130
-142
lines changed

datafusion/common/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl Error for DataFusionError {
397397

398398
impl From<DataFusionError> for io::Error {
399399
fn from(e: DataFusionError) -> Self {
400-
io::Error::new(io::ErrorKind::Other, e)
400+
io::Error::other(e)
401401
}
402402
}
403403

datafusion/common/src/stats.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,13 @@ impl Statistics {
356356
/// The column is taken and put into the specified statistics location
357357
Taken(usize),
358358
/// The original columns is present
359-
Present(ColumnStatistics),
359+
Present(Box<ColumnStatistics>),
360360
}
361361

362362
// Convert to Vec<Slot> so we can avoid copying the statistics
363363
let mut columns: Vec<_> = std::mem::take(&mut self.column_statistics)
364364
.into_iter()
365-
.map(Slot::Present)
365+
.map(|stats| Slot::Present(Box::new(stats)))
366366
.collect();
367367

368368
for idx in projection {
@@ -373,7 +373,7 @@ impl Statistics {
373373
);
374374
match slot {
375375
// The column was there, so just move it
376-
Slot::Present(col) => self.column_statistics.push(col),
376+
Slot::Present(col) => self.column_statistics.push(*col),
377377
// The column was taken, so copy from the previous location
378378
Slot::Taken(prev_idx) => self
379379
.column_statistics

datafusion/datasource-avro/src/avro_to_arrow/arrow_array_reader.rs

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
use apache_avro::schema::RecordSchema;
2121
use apache_avro::{
2222
schema::{Schema as AvroSchema, SchemaKind},
23-
types::Value,
24-
AvroResult, Error as AvroError, Reader as AvroReader,
23+
types::Value, Error as AvroError, Reader as AvroReader,
2524
};
2625
use arrow::array::{
2726
make_array, Array, ArrayBuilder, ArrayData, ArrayDataBuilder, ArrayRef,
@@ -938,40 +937,37 @@ fn resolve_string(v: &Value) -> ArrowResult<Option<String>> {
938937
.map_err(|e| SchemaError(format!("expected resolvable string : {e:?}")))
939938
}
940939

941-
fn resolve_u8(v: &Value) -> AvroResult<u8> {
942-
let int = match v {
943-
Value::Int(n) => Ok(Value::Int(*n)),
944-
Value::Long(n) => Ok(Value::Int(*n as i32)),
945-
other => Err(AvroError::GetU8(other.into())),
946-
}?;
947-
if let Value::Int(n) = int {
948-
if n >= 0 && n <= From::from(u8::MAX) {
949-
return Ok(n as u8);
950-
}
951-
}
940+
fn resolve_u8(v: &Value) -> Option<u8> {
941+
let v = match v {
942+
Value::Union(_, inner) => inner.as_ref(), // &Box<Value> -> &Value
943+
_ => v,
944+
};
952945

953-
Err(AvroError::GetU8(int.into()))
946+
match v {
947+
Value::Int(n) if (0..=u8::MAX as i32).contains(n) => Some(*n as u8),
948+
Value::Long(n) if (0..=u8::MAX as i64).contains(n) => Some(*n as u8),
949+
_ => None,
950+
}
954951
}
955952

956953
fn resolve_bytes(v: &Value) -> Option<Vec<u8>> {
957-
let v = if let Value::Union(_, b) = v { b } else { v };
954+
let v = match v {
955+
Value::Union(_, inner) => inner.as_ref(),
956+
_ => v,
957+
};
958+
958959
match v {
959-
Value::Bytes(_) => Ok(v.clone()),
960-
Value::String(s) => Ok(Value::Bytes(s.clone().into_bytes())),
961-
Value::Array(items) => Ok(Value::Bytes(
962-
items
960+
Value::Bytes(bytes) => Some(bytes.clone()),
961+
Value::String(s) => Some(s.as_bytes().to_vec()),
962+
Value::Array(items) => {
963+
let bytes: Option<Vec<u8>> = items
963964
.iter()
964965
.map(resolve_u8)
965-
.collect::<Result<Vec<_>, _>>()
966-
.ok()?,
967-
)),
968-
other => Err(AvroError::GetBytes(other.into())),
969-
}
970-
.ok()
971-
.and_then(|v| match v {
972-
Value::Bytes(s) => Some(s),
966+
.collect();
967+
bytes
968+
}
973969
_ => None,
974-
})
970+
}
975971
}
976972

977973
fn resolve_fixed(v: &Value, size: usize) -> Option<Vec<u8>> {

datafusion/expr/src/planner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ pub struct RawWindowExpr {
314314
#[derive(Debug, Clone)]
315315
pub enum PlannerResult<T> {
316316
/// The raw expression was successfully planned as a new [`Expr`]
317-
Planned(Expr),
317+
Planned(Box<Expr>),
318318
/// The raw expression could not be planned, and is returned unmodified
319319
Original(T),
320320
}

datafusion/expr/src/simplify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl SimplifyInfo for SimplifyContext<'_> {
112112
#[derive(Debug)]
113113
pub enum ExprSimplifyResult {
114114
/// The function call was simplified to an entirely new Expr
115-
Simplified(Expr),
115+
Simplified(Box<Expr>),
116116
/// The function call could not be simplified, and the arguments
117117
/// are return unmodified.
118118
Original(Vec<Expr>),

datafusion/expr/src/window_state.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,7 @@ impl WindowFrameContext {
193193
// UNBOUNDED PRECEDING
194194
WindowFrameBound::Preceding(ScalarValue::UInt64(None)) => 0,
195195
WindowFrameBound::Preceding(ScalarValue::UInt64(Some(n))) => {
196-
if idx >= n as usize {
197-
idx - n as usize
198-
} else {
199-
0
200-
}
196+
idx.saturating_sub(n as usize)
201197
}
202198
WindowFrameBound::CurrentRow => idx,
203199
// UNBOUNDED FOLLOWING
@@ -602,11 +598,7 @@ impl WindowFrameStateGroups {
602598

603599
// Find the group index of the frame boundary:
604600
let group_idx = if SEARCH_SIDE {
605-
if self.current_group_idx > delta {
606-
self.current_group_idx - delta
607-
} else {
608-
0
609-
}
601+
self.current_group_idx.saturating_sub(delta)
610602
} else {
611603
self.current_group_idx + delta
612604
};

datafusion/functions-aggregate/src/planner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl ExprPlanner for AggregateFunctionPlanner {
108108
));
109109

110110
let new_expr = saved_name.restore(new_expr);
111-
return Ok(PlannerResult::Planned(new_expr));
111+
return Ok(PlannerResult::Planned(Box::new(new_expr)));
112112
}
113113

114114
Ok(PlannerResult::Original(raw_expr))

datafusion/functions-nested/src/array_has.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,20 @@ impl ScalarUDFImpl for ArrayHas {
150150
.map(Expr::Literal)
151151
.collect();
152152

153-
return Ok(ExprSimplifyResult::Simplified(Expr::InList(InList {
153+
return Ok(ExprSimplifyResult::Simplified(Box::new(Expr::InList(InList {
154154
expr: Box::new(std::mem::take(needle)),
155155
list,
156156
negated: false,
157-
})));
157+
}))));
158158
}
159159
} else if let Expr::ScalarFunction(ScalarFunction { func, args }) = haystack {
160160
// make_array has a static set of arguments, so we can pull the arguments out from it
161161
if func == &make_array_udf() {
162-
return Ok(ExprSimplifyResult::Simplified(Expr::InList(InList {
162+
return Ok(ExprSimplifyResult::Simplified(Box::new(Expr::InList(InList {
163163
expr: Box::new(std::mem::take(needle)),
164164
list: std::mem::take(args),
165165
negated: false,
166-
})));
166+
}))));
167167
}
168168
}
169169

datafusion/functions-nested/src/planner.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ impl ExprPlanner for NestedFunctionPlanner {
6969
// TODO: concat function ignore null, but string concat takes null into consideration
7070
// we can rewrite it to concat if we can configure the behaviour of concat function to the one like `string concat operator`
7171
} else if left_list_ndims == right_list_ndims {
72-
return Ok(PlannerResult::Planned(array_concat(vec![left, right])));
72+
return Ok(PlannerResult::Planned(Box::new(array_concat(vec![left, right]))));
7373
} else if left_list_ndims > right_list_ndims {
74-
return Ok(PlannerResult::Planned(array_append(left, right)));
74+
return Ok(PlannerResult::Planned(Box::new(array_append(left, right))));
7575
} else if left_list_ndims < right_list_ndims {
76-
return Ok(PlannerResult::Planned(array_prepend(left, right)));
76+
return Ok(PlannerResult::Planned(Box::new(array_prepend(left, right))));
7777
}
7878
} else if matches!(
7979
op,
@@ -88,10 +88,10 @@ impl ExprPlanner for NestedFunctionPlanner {
8888
if left_list_ndims > 0 && right_list_ndims > 0 {
8989
if op == sqlparser::ast::BinaryOperator::AtArrow {
9090
// array1 @> array2 -> array_has_all(array1, array2)
91-
return Ok(PlannerResult::Planned(array_has_all(left, right)));
91+
return Ok(PlannerResult::Planned(Box::new(array_has_all(left, right))));
9292
} else {
9393
// array1 <@ array2 -> array_has_all(array2, array1)
94-
return Ok(PlannerResult::Planned(array_has_all(right, left)));
94+
return Ok(PlannerResult::Planned(Box::new(array_has_all(right, left))));
9595
}
9696
}
9797
}
@@ -104,7 +104,7 @@ impl ExprPlanner for NestedFunctionPlanner {
104104
exprs: Vec<Expr>,
105105
_schema: &DFSchema,
106106
) -> Result<PlannerResult<Vec<Expr>>> {
107-
Ok(PlannerResult::Planned(make_array(exprs)))
107+
Ok(PlannerResult::Planned(Box::new(make_array(exprs))))
108108
}
109109

110110
fn plan_make_map(&self, args: Vec<Expr>) -> Result<PlannerResult<Vec<Expr>>> {
@@ -117,20 +117,20 @@ impl ExprPlanner for NestedFunctionPlanner {
117117
let keys = make_array(keys.into_iter().map(|(_, e)| e).collect());
118118
let values = make_array(values.into_iter().map(|(_, e)| e).collect());
119119

120-
Ok(PlannerResult::Planned(Expr::ScalarFunction(
120+
Ok(PlannerResult::Planned(Box::new(Expr::ScalarFunction(
121121
ScalarFunction::new_udf(map_udf(), vec![keys, values]),
122-
)))
122+
))))
123123
}
124124

125125
fn plan_any(&self, expr: RawBinaryExpr) -> Result<PlannerResult<RawBinaryExpr>> {
126126
if expr.op == sqlparser::ast::BinaryOperator::Eq {
127-
Ok(PlannerResult::Planned(Expr::ScalarFunction(
127+
Ok(PlannerResult::Planned(Box::new(Expr::ScalarFunction(
128128
ScalarFunction::new_udf(
129129
array_has_udf(),
130130
// left and right are reversed here so `needle=any(haystack)` -> `array_has(haystack, needle)`
131131
vec![expr.right, expr.left],
132132
),
133-
)))
133+
))))
134134
} else {
135135
plan_err!("Unsupported AnyOp: '{}', only '=' is supported", expr.op)
136136
}
@@ -150,7 +150,7 @@ impl ExprPlanner for FieldAccessPlanner {
150150
match field_access {
151151
// expr["field"] => get_field(expr, "field")
152152
GetFieldAccess::NamedStructField { name } => {
153-
Ok(PlannerResult::Planned(get_field(expr, name)))
153+
Ok(PlannerResult::Planned(Box::new(get_field(expr, name))))
154154
}
155155
// expr[idx] ==> array_element(expr, idx)
156156
GetFieldAccess::ListIndex { key: index } => {
@@ -167,40 +167,40 @@ impl ExprPlanner for FieldAccessPlanner {
167167
null_treatment,
168168
},
169169
}) if is_array_agg(&func) => Ok(PlannerResult::Planned(
170-
Expr::AggregateFunction(AggregateFunction::new_udf(
170+
Box::new(Expr::AggregateFunction(AggregateFunction::new_udf(
171171
nth_value_udaf(),
172172
args.into_iter().chain(std::iter::once(*index)).collect(),
173173
distinct,
174174
filter,
175175
order_by,
176176
null_treatment,
177-
)),
177+
))),
178178
)),
179179
// special case for map access with
180180
Expr::Column(ref c)
181181
if matches!(schema.data_type(c)?, DataType::Map(_, _)) =>
182182
{
183-
Ok(PlannerResult::Planned(Expr::ScalarFunction(
183+
Ok(PlannerResult::Planned(Box::new(Expr::ScalarFunction(
184184
ScalarFunction::new_udf(
185185
get_field_inner(),
186186
vec![expr, *index],
187187
),
188-
)))
188+
))))
189189
}
190-
_ => Ok(PlannerResult::Planned(array_element(expr, *index))),
190+
_ => Ok(PlannerResult::Planned(Box::new(array_element(expr, *index)))),
191191
}
192192
}
193193
// expr[start, stop, stride] ==> array_slice(expr, start, stop, stride)
194194
GetFieldAccess::ListRange {
195195
start,
196196
stop,
197197
stride,
198-
} => Ok(PlannerResult::Planned(array_slice(
198+
} => Ok(PlannerResult::Planned(Box::new(array_slice(
199199
expr,
200200
*start,
201201
*stop,
202202
Some(*stride),
203-
))),
203+
)))),
204204
}
205205
}
206206
}

datafusion/functions-window/src/planner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl ExprPlanner for WindowFunctionPlanner {
107107

108108
let new_expr = saved_name.restore(new_expr);
109109

110-
return Ok(PlannerResult::Planned(new_expr));
110+
return Ok(PlannerResult::Planned(Box::new(new_expr)));
111111
}
112112

113113
Ok(PlannerResult::Original(raw_expr))

datafusion/functions/src/core/arrow_cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl ScalarUDFImpl for ArrowCastFunc {
165165
})
166166
};
167167
// return the newly written argument to DataFusion
168-
Ok(ExprSimplifyResult::Simplified(new_expr))
168+
Ok(ExprSimplifyResult::Simplified(Box::new(new_expr)))
169169
}
170170

171171
fn documentation(&self) -> Option<&Documentation> {

datafusion/functions/src/core/planner.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ impl ExprPlanner for CoreFunctionPlanner {
3838
args.push(k);
3939
args.push(v);
4040
}
41-
Ok(PlannerResult::Planned(named_struct().call(args)))
41+
Ok(PlannerResult::Planned(Box::new(named_struct().call(args))))
4242
}
4343

4444
fn plan_struct_literal(
4545
&self,
4646
args: Vec<Expr>,
4747
is_named_struct: bool,
4848
) -> Result<PlannerResult<Vec<Expr>>> {
49-
Ok(PlannerResult::Planned(Expr::ScalarFunction(
49+
Ok(PlannerResult::Planned(Box::new(Expr::ScalarFunction(
5050
ScalarFunction::new_udf(
5151
if is_named_struct {
5252
named_struct()
@@ -55,13 +55,13 @@ impl ExprPlanner for CoreFunctionPlanner {
5555
},
5656
args,
5757
),
58-
)))
58+
))))
5959
}
6060

6161
fn plan_overlay(&self, args: Vec<Expr>) -> Result<PlannerResult<Vec<Expr>>> {
62-
Ok(PlannerResult::Planned(Expr::ScalarFunction(
62+
Ok(PlannerResult::Planned(Box::new(Expr::ScalarFunction(
6363
ScalarFunction::new_udf(crate::core::overlay(), args),
64-
)))
64+
))))
6565
}
6666

6767
fn plan_compound_identifier(
@@ -84,6 +84,6 @@ impl ExprPlanner for CoreFunctionPlanner {
8484
));
8585
}
8686

87-
Ok(PlannerResult::Planned(expr))
87+
Ok(PlannerResult::Planned(Box::new(expr)))
8888
}
8989
}

datafusion/functions/src/datetime/current_date.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ impl ScalarUDFImpl for CurrentDateFunc {
106106
.unwrap()
107107
.num_days_from_ce(),
108108
);
109-
Ok(ExprSimplifyResult::Simplified(Expr::Literal(
109+
Ok(ExprSimplifyResult::Simplified(Box::new(Expr::Literal(
110110
ScalarValue::Date32(days),
111-
)))
111+
))))
112112
}
113113

114114
fn documentation(&self) -> Option<&Documentation> {

datafusion/functions/src/datetime/current_time.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ impl ScalarUDFImpl for CurrentTimeFunc {
9494
) -> Result<ExprSimplifyResult> {
9595
let now_ts = info.execution_props().query_execution_start_time;
9696
let nano = now_ts.timestamp_nanos_opt().map(|ts| ts % 86400000000000);
97-
Ok(ExprSimplifyResult::Simplified(Expr::Literal(
97+
Ok(ExprSimplifyResult::Simplified(Box::new(Expr::Literal(
9898
ScalarValue::Time64Nanosecond(nano),
99-
)))
99+
))))
100100
}
101101

102102
fn documentation(&self) -> Option<&Documentation> {

0 commit comments

Comments
 (0)