-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] Enable pivot for swordfish (#3081)
Adds pivot as an intermediate operator. Unskips all the pivot tests. Co-authored-by: Colin Ho <[email protected]>
- Loading branch information
Showing
7 changed files
with
144 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use std::sync::Arc; | ||
|
||
use common_error::DaftResult; | ||
use daft_dsl::ExprRef; | ||
use tracing::instrument; | ||
|
||
use super::intermediate_op::{ | ||
IntermediateOperator, IntermediateOperatorResult, IntermediateOperatorState, | ||
}; | ||
use crate::pipeline::PipelineResultType; | ||
|
||
pub struct PivotOperator { | ||
group_by: Vec<ExprRef>, | ||
pivot_col: ExprRef, | ||
values_col: ExprRef, | ||
names: Vec<String>, | ||
} | ||
|
||
impl PivotOperator { | ||
pub fn new( | ||
group_by: Vec<ExprRef>, | ||
pivot_col: ExprRef, | ||
values_col: ExprRef, | ||
names: Vec<String>, | ||
) -> Self { | ||
Self { | ||
group_by, | ||
pivot_col, | ||
values_col, | ||
names, | ||
} | ||
} | ||
} | ||
|
||
impl IntermediateOperator for PivotOperator { | ||
#[instrument(skip_all, name = "PivotOperator::execute")] | ||
fn execute( | ||
&self, | ||
_idx: usize, | ||
input: &PipelineResultType, | ||
_state: Option<&mut Box<dyn IntermediateOperatorState>>, | ||
) -> DaftResult<IntermediateOperatorResult> { | ||
let out = input.as_data().pivot( | ||
&self.group_by, | ||
self.pivot_col.clone(), | ||
self.values_col.clone(), | ||
self.names.clone(), | ||
)?; | ||
Ok(IntermediateOperatorResult::NeedMoreInput(Some(Arc::new( | ||
out, | ||
)))) | ||
} | ||
|
||
fn name(&self) -> &'static str { | ||
"PivotOperator" | ||
} | ||
} |
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
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