-
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 unpivot for swordfish (#3078)
Adds unpivot as an intermediate operator. Unskips all the unpivot tests --------- Co-authored-by: Colin Ho <[email protected]>
- Loading branch information
Showing
7 changed files
with
123 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ pub mod intermediate_op; | |
pub mod pivot; | ||
pub mod project; | ||
pub mod sample; | ||
pub mod unpivot; |
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 UnpivotOperator { | ||
ids: Vec<ExprRef>, | ||
values: Vec<ExprRef>, | ||
variable_name: String, | ||
value_name: String, | ||
} | ||
|
||
impl UnpivotOperator { | ||
pub fn new( | ||
ids: Vec<ExprRef>, | ||
values: Vec<ExprRef>, | ||
variable_name: String, | ||
value_name: String, | ||
) -> Self { | ||
Self { | ||
ids, | ||
values, | ||
variable_name, | ||
value_name, | ||
} | ||
} | ||
} | ||
|
||
impl IntermediateOperator for UnpivotOperator { | ||
#[instrument(skip_all, name = "UnpivotOperator::execute")] | ||
fn execute( | ||
&self, | ||
_idx: usize, | ||
input: &PipelineResultType, | ||
_state: Option<&mut Box<dyn IntermediateOperatorState>>, | ||
) -> DaftResult<IntermediateOperatorResult> { | ||
let out = input.as_data().unpivot( | ||
&self.ids, | ||
&self.values, | ||
&self.variable_name, | ||
&self.value_name, | ||
)?; | ||
Ok(IntermediateOperatorResult::NeedMoreInput(Some(Arc::new( | ||
out, | ||
)))) | ||
} | ||
|
||
fn name(&self) -> &'static str { | ||
"UnpivotOperator" | ||
} | ||
} |
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