Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: SELECT with aggragate preserves select_list order
- Loading branch information
Showing
13 changed files
with
602 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
.../autonomous_executor/task/pump_task/pump_subtask/query_subtask/aggr_projection_subtask.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ngine/autonomous_executor/task/pump_task/pump_subtask/query_subtask/projection_subtask.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// This file is part of https://github.com/SpringQL/SpringQL which is licensed under MIT OR Apache-2.0. See file LICENSE-MIT or LICENSE-APACHE for full license details. | ||
|
||
use crate::error::Result; | ||
use crate::expr_resolver::expr_label::ExprLabel; | ||
use crate::expr_resolver::ExprResolver; | ||
use crate::stream_engine::autonomous_executor::task::tuple::Tuple; | ||
use crate::stream_engine::autonomous_executor::task::window::aggregate::AggregatedAndGroupingValues; | ||
|
||
use super::SqlValues; | ||
|
||
#[derive(Debug, new)] | ||
pub(in crate::stream_engine::autonomous_executor) struct ProjectionSubtask { | ||
exprs: Vec<ExprLabel>, | ||
} | ||
|
||
impl ProjectionSubtask { | ||
/// Projection for SELECT without aggregate. | ||
pub(in crate::stream_engine::autonomous_executor) fn run_without_aggr( | ||
&self, | ||
expr_resolver: &ExprResolver, | ||
tuple: &Tuple, | ||
) -> Result<SqlValues> { | ||
let values = self | ||
.exprs | ||
.iter() | ||
.map(|label| match label { | ||
ExprLabel::Value(group_by_value_label) => { | ||
expr_resolver.eval_value_expr(*group_by_value_label, tuple) | ||
} | ||
ExprLabel::Aggr(_) => unreachable!("aggregate must not be in select_list"), | ||
}) | ||
.collect::<Result<Vec<_>>>()?; | ||
|
||
Ok(SqlValues::new(values)) | ||
} | ||
|
||
/// Projection for SELECT with aggregate. | ||
/// select_list must only have GROUP BY elements or aggregate expressions. | ||
/// (Column reference without aggregate is not allowed.) | ||
pub(in crate::stream_engine::autonomous_executor) fn run_with_aggr( | ||
&self, | ||
aggregated_and_grouping_values: AggregatedAndGroupingValues, | ||
) -> Result<SqlValues> { | ||
let values = self | ||
.exprs | ||
.iter() | ||
.map(|label| { | ||
match label { | ||
ExprLabel::Value(group_by_value_label) => { | ||
aggregated_and_grouping_values.get_group_by_value(group_by_value_label) | ||
} | ||
ExprLabel::Aggr(aggr_label) => { | ||
aggregated_and_grouping_values.get_aggregated_value(aggr_label) | ||
} | ||
} | ||
.cloned() | ||
}) | ||
.collect::<Result<Vec<_>>>()?; | ||
|
||
Ok(SqlValues::new(values)) | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
...autonomous_executor/task/pump_task/pump_subtask/query_subtask/value_projection_subtask.rs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.