-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] [New Query Planner] Add support for Sort, Repartition, and Dis…
…tinct in new query planner. (#1248) This PR adds support for `df.sort()`, `df.repartition()`, and `df.distinct()` in the new query planner.
- Loading branch information
1 parent
03380a4
commit 074e37c
Showing
21 changed files
with
577 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::LogicalPlan; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Distinct { | ||
// Upstream node. | ||
pub input: Arc<LogicalPlan>, | ||
} | ||
|
||
impl Distinct { | ||
pub(crate) fn new(input: Arc<LogicalPlan>) -> Self { | ||
Self { input } | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
mod agg; | ||
mod distinct; | ||
mod filter; | ||
mod limit; | ||
mod repartition; | ||
mod sort; | ||
mod source; | ||
|
||
pub use agg::Aggregate; | ||
pub use distinct::Distinct; | ||
pub use filter::Filter; | ||
pub use limit::Limit; | ||
pub use repartition::Repartition; | ||
pub use sort::Sort; | ||
pub use source::Source; |
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,42 @@ | ||
use std::sync::Arc; | ||
|
||
use daft_dsl::Expr; | ||
|
||
use crate::{LogicalPlan, PartitionScheme}; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Repartition { | ||
pub num_partitions: usize, | ||
pub partition_by: Vec<Expr>, | ||
pub scheme: PartitionScheme, | ||
// Upstream node. | ||
pub input: Arc<LogicalPlan>, | ||
} | ||
|
||
impl Repartition { | ||
pub(crate) fn new( | ||
num_partitions: usize, | ||
partition_by: Vec<Expr>, | ||
scheme: PartitionScheme, | ||
input: Arc<LogicalPlan>, | ||
) -> Self { | ||
Self { | ||
num_partitions, | ||
partition_by, | ||
scheme, | ||
input, | ||
} | ||
} | ||
|
||
pub fn multiline_display(&self) -> Vec<String> { | ||
let mut res = vec![]; | ||
res.push(format!( | ||
"Repartition ({:?}): n={}", | ||
self.scheme, self.num_partitions | ||
)); | ||
if !self.partition_by.is_empty() { | ||
res.push(format!(" Partition by: {:?}", self.partition_by)); | ||
} | ||
res | ||
} | ||
} |
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,44 @@ | ||
use std::sync::Arc; | ||
|
||
use daft_dsl::Expr; | ||
|
||
use crate::LogicalPlan; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Sort { | ||
pub sort_by: Vec<Expr>, | ||
pub descending: Vec<bool>, | ||
// Upstream node. | ||
pub input: Arc<LogicalPlan>, | ||
} | ||
|
||
impl Sort { | ||
pub(crate) fn new(sort_by: Vec<Expr>, descending: Vec<bool>, input: Arc<LogicalPlan>) -> Self { | ||
Self { | ||
sort_by, | ||
descending, | ||
input, | ||
} | ||
} | ||
|
||
pub fn multiline_display(&self) -> Vec<String> { | ||
let mut res = vec![]; | ||
res.push("Sort:".to_string()); | ||
if !self.sort_by.is_empty() { | ||
let pairs: Vec<String> = self | ||
.sort_by | ||
.iter() | ||
.zip(self.descending.iter()) | ||
.map(|(sb, d)| { | ||
format!( | ||
"({:?}, {})", | ||
sb, | ||
if *d { "descending" } else { "ascending" }, | ||
) | ||
}) | ||
.collect(); | ||
res.push(format!(" Sort by: {:?}", pairs)); | ||
} | ||
res | ||
} | ||
} |
Oops, something went wrong.