-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] Refactors and agg improvements for new local execution model (#…
…2497) Makes source trait async Connect to new local physical plan Add incremental aggregations --------- Co-authored-by: Colin Ho <colinho@Colins-MBP.localdomain>
- Loading branch information
Showing
25 changed files
with
358 additions
and
189 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,34 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Iterator | ||
|
||
from daft.daft import ( | ||
NativeExecutor as _NativeExecutor, | ||
) | ||
from daft.logical.builder import LogicalPlanBuilder | ||
from daft.runners.partitioning import ( | ||
MaterializedResult, | ||
PartitionT, | ||
) | ||
from daft.table import MicroPartition | ||
|
||
if TYPE_CHECKING: | ||
from daft.runners.pyrunner import PyMaterializedResult | ||
|
||
|
||
class NativeExecutor: | ||
def __init__(self, executor: _NativeExecutor): | ||
self._executor = executor | ||
|
||
@classmethod | ||
def from_logical_plan_builder(cls, builder: LogicalPlanBuilder) -> NativeExecutor: | ||
executor = _NativeExecutor.from_logical_plan_builder(builder._builder) | ||
return cls(executor) | ||
|
||
def run(self, psets: dict[str, list[MaterializedResult[PartitionT]]]) -> Iterator[PyMaterializedResult]: | ||
from daft.runners.pyrunner import PyMaterializedResult | ||
|
||
psets_mp = {part_id: [part.vpartition()._micropartition for part in parts] for part_id, parts in psets.items()} | ||
return ( | ||
PyMaterializedResult(MicroPartition._from_pymicropartition(part)) for part in self._executor.run(psets_mp) | ||
) |
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
34 changes: 34 additions & 0 deletions
34
src/daft-local-execution/src/intermediate_ops/aggregate.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,34 @@ | ||
use std::sync::Arc; | ||
|
||
use common_error::DaftResult; | ||
use daft_dsl::ExprRef; | ||
use daft_micropartition::MicroPartition; | ||
|
||
use super::intermediate_op::IntermediateOperator; | ||
|
||
#[derive(Clone)] | ||
pub struct AggregateOperator { | ||
agg_exprs: Vec<ExprRef>, | ||
group_by: Vec<ExprRef>, | ||
} | ||
|
||
impl AggregateOperator { | ||
pub fn new(agg_exprs: Vec<ExprRef>, group_by: Vec<ExprRef>) -> Self { | ||
Self { | ||
agg_exprs, | ||
group_by, | ||
} | ||
} | ||
} | ||
|
||
impl IntermediateOperator for AggregateOperator { | ||
fn execute(&self, input: &Arc<MicroPartition>) -> DaftResult<Arc<MicroPartition>> { | ||
log::debug!("AggregateOperator::execute"); | ||
let out = input.agg(&self.agg_exprs, &self.group_by)?; | ||
Ok(Arc::new(out)) | ||
} | ||
|
||
fn name(&self) -> &'static str { | ||
"AggregateOperator" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod aggregate; | ||
pub mod filter; | ||
pub mod intermediate_op; | ||
pub mod project; |
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
Oops, something went wrong.