Skip to content

Commit

Permalink
Remove
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Sep 15, 2023
1 parent e4b1285 commit 10f70f3
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions datafusion/physical-expr/src/aggregate/first_last.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ struct FirstValueAccumulator {
orderings: Vec<ScalarValue>,
// Stores the applicable ordering requirement.
ordering_req: LexOrdering,
// Whether merge_batch() is called before
is_merge_called: bool,
}

impl FirstValueAccumulator {
Expand All @@ -185,7 +183,6 @@ impl FirstValueAccumulator {
is_set: false,
orderings,
ordering_req,
is_merge_called: false,
})
}

Expand All @@ -201,9 +198,7 @@ impl Accumulator for FirstValueAccumulator {
fn state(&self) -> Result<Vec<ScalarValue>> {
let mut result = vec![self.first.clone()];
result.extend(self.orderings.iter().cloned());
if !self.is_merge_called {
result.push(ScalarValue::Boolean(Some(self.is_set)));
}
result.push(ScalarValue::Boolean(Some(self.is_set)));
Ok(result)
}

Expand All @@ -218,7 +213,6 @@ impl Accumulator for FirstValueAccumulator {
}

fn merge_batch(&mut self, states: &[ArrayRef]) -> Result<()> {
self.is_merge_called = true;
// FIRST_VALUE(first1, first2, first3, ...)
// last index contains is_set flag.
let is_set_idx = states.len() - 1;
Expand Down Expand Up @@ -394,8 +388,6 @@ struct LastValueAccumulator {
orderings: Vec<ScalarValue>,
// Stores the applicable ordering requirement.
ordering_req: LexOrdering,
// Whether merge_batch() is called before
is_merge_called: bool,
}

impl LastValueAccumulator {
Expand All @@ -414,7 +406,6 @@ impl LastValueAccumulator {
is_set: false,
orderings,
ordering_req,
is_merge_called: false,
})
}

Expand All @@ -430,9 +421,7 @@ impl Accumulator for LastValueAccumulator {
fn state(&self) -> Result<Vec<ScalarValue>> {
let mut result = vec![self.last.clone()];
result.extend(self.orderings.clone());
if !self.is_merge_called {
result.push(ScalarValue::Boolean(Some(self.is_set)));
}
result.push(ScalarValue::Boolean(Some(self.is_set)));
Ok(result)
}

Expand All @@ -446,7 +435,6 @@ impl Accumulator for LastValueAccumulator {
}

fn merge_batch(&mut self, states: &[ArrayRef]) -> Result<()> {
self.is_merge_called = true;
// LAST_VALUE(last1, last2, last3, ...)
// last index contains is_set flag.
let is_set_idx = states.len() - 1;
Expand Down

0 comments on commit 10f70f3

Please sign in to comment.