Skip to content

Commit 35ee604

Browse files
committed
sum_ansi_mode_checks_fix_tests
1 parent c0715aa commit 35ee604

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

native/spark-expr/src/agg_funcs/sum_int.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ impl Accumulator for SumIntegerAccumulator {
138138
{
139139
for i in 0..int_array.len() {
140140
if !int_array.is_null(i) {
141-
let v = int_array.value(i).to_i64().ok_or_else(|| {
142-
DataFusionError::Internal("Failed to convert value to i64".to_string())
143-
})?;
141+
let v = int_array.value(i).to_i64().unwrap();
144142
match eval_mode {
145143
EvalMode::Legacy => {
146144
sum = v.add_wrapping(sum);
@@ -209,7 +207,10 @@ impl Accumulator for SumIntegerAccumulator {
209207
running_sum,
210208
)?,
211209
_ => {
212-
panic!("Unsupported data type {}", values.data_type())
210+
return Err(DataFusionError::Internal(format!(
211+
"unsupported data type: {:?}",
212+
values.data_type()
213+
)));
213214
}
214215
};
215216
self.sum = sum;
@@ -227,7 +228,7 @@ impl Accumulator for SumIntegerAccumulator {
227228
}
228229

229230
fn size(&self) -> usize {
230-
size_of_val(self)
231+
std::mem::size_of_val(self)
231232
}
232233

233234
fn state(&mut self) -> DFResult<Vec<ScalarValue>> {
@@ -314,6 +315,16 @@ impl SumIntGroupsAccumulator {
314315
has_all_nulls: Vec::new(),
315316
}
316317
}
318+
319+
fn resize_helper(&mut self, total_num_groups: usize) {
320+
if self.eval_mode == EvalMode::Try {
321+
self.sums.resize(total_num_groups, Some(0));
322+
self.has_all_nulls.resize(total_num_groups, true);
323+
} else {
324+
self.sums.resize(total_num_groups, None);
325+
self.has_all_nulls.resize(total_num_groups, false);
326+
}
327+
}
317328
}
318329

319330
impl GroupsAccumulator for SumIntGroupsAccumulator {
@@ -375,15 +386,9 @@ impl GroupsAccumulator for SumIntGroupsAccumulator {
375386
Ok(())
376387
}
377388

378-
assert!(opt_filter.is_none(), "opt_filter is not supported yet");
389+
debug_assert!(opt_filter.is_none(), "opt_filter is not supported yet");
379390
let values = &values[0];
380-
if self.eval_mode == EvalMode::Try {
381-
self.sums.resize(total_num_groups, Some(0));
382-
self.has_all_nulls.resize(total_num_groups, true);
383-
} else {
384-
self.sums.resize(total_num_groups, None);
385-
self.has_all_nulls.resize(total_num_groups, false);
386-
}
391+
self.resize_helper(total_num_groups);
387392

388393
match values.data_type() {
389394
DataType::Int64 => update_groups_sum_internal(
@@ -480,17 +485,11 @@ impl GroupsAccumulator for SumIntGroupsAccumulator {
480485
opt_filter: Option<&BooleanArray>,
481486
total_num_groups: usize,
482487
) -> DFResult<()> {
483-
assert!(opt_filter.is_none(), "opt_filter is not supported yet");
488+
debug_assert!(opt_filter.is_none(), "opt_filter is not supported yet");
484489

485490
let that_sums = values[0].as_primitive::<Int64Type>();
486491

487-
if self.eval_mode == EvalMode::Try {
488-
self.sums.resize(total_num_groups, Some(0));
489-
self.has_all_nulls.resize(total_num_groups, true);
490-
} else {
491-
self.sums.resize(total_num_groups, None);
492-
self.has_all_nulls.resize(total_num_groups, false);
493-
}
492+
self.resize_helper(total_num_groups);
494493

495494
let that_sums_is_all_nulls = if self.eval_mode == EvalMode::Try {
496495
Some(values[1].as_boolean())
@@ -569,6 +568,6 @@ impl GroupsAccumulator for SumIntGroupsAccumulator {
569568
}
570569

571570
fn size(&self) -> usize {
572-
size_of_val(self)
571+
std::mem::size_of_val(self)
573572
}
574573
}

spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import org.apache.comet.shims.CometExprShim
6262
*/
6363
object QueryPlanSerde extends Logging with CometExprShim {
6464

65-
val integerTypes = Seq(ByteType, ShortType, IntegerType, LongType)
65+
private val integerTypes = Seq(ByteType, ShortType, IntegerType, LongType)
6666

6767
/**
6868
* Mapping of Spark operator class to Comet operator handler.

0 commit comments

Comments
 (0)