This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9658bb
commit 8fc8185
Showing
10 changed files
with
333 additions
and
61 deletions.
There are no files selected for viewing
Submodule arrow-datafusion
updated
5 files
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,109 @@ | ||
use datafusion::physical_plan::ExecutionPlan; | ||
use std::pin::Pin; | ||
use std::sync::Arc; | ||
use std::task::{Context, Poll}; | ||
use std::{any::Any, vec}; | ||
|
||
use arrow::array::{ArrayRef, UInt64Builder}; | ||
use arrow::datatypes::Schema; | ||
use arrow::datatypes::SchemaRef; | ||
use arrow::record_batch::RecordBatch; | ||
use datafusion::common::{arrow_datafusion_err, not_impl_err, DataFusionError, Result}; | ||
use datafusion::execution::TaskContext; | ||
use datafusion::physical_plan::metrics::MetricsSet; | ||
use datafusion::physical_plan::DisplayAs; | ||
use datafusion::physical_plan::DisplayFormatType; | ||
use datafusion::physical_plan::PlanProperties; | ||
use datafusion::physical_plan::RecordBatchStream; | ||
use datafusion::physical_plan::SendableRecordBatchStream; | ||
use datafusion::physical_plan::Statistics; | ||
use futures::stream::Stream; | ||
|
||
use futures::{FutureExt, StreamExt}; | ||
#[derive(Debug)] | ||
pub struct DummyExec { | ||
cache: PlanProperties, | ||
statistics: Statistics, | ||
schema: Arc<Schema>, | ||
} | ||
|
||
impl DummyExec { | ||
pub fn new(cache: PlanProperties, statistics: Statistics, schema: Arc<Schema>) -> Self { | ||
DummyExec { | ||
cache, | ||
statistics, | ||
schema, | ||
} | ||
} | ||
} | ||
impl ExecutionPlan for DummyExec { | ||
/// Return a reference to Any that can be used for downcasting | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
|
||
fn properties(&self) -> &PlanProperties { | ||
&self.cache | ||
} | ||
|
||
fn children(&self) -> Vec<Arc<dyn ExecutionPlan>> { | ||
vec![] | ||
} | ||
|
||
fn with_new_children( | ||
self: Arc<Self>, | ||
mut children: Vec<Arc<dyn ExecutionPlan>>, | ||
) -> Result<Arc<dyn ExecutionPlan>> { | ||
Ok(self) | ||
} | ||
|
||
fn benefits_from_input_partitioning(&self) -> Vec<bool> { | ||
vec![] | ||
} | ||
|
||
fn maintains_input_order(&self) -> Vec<bool> { | ||
vec![] | ||
} | ||
|
||
fn execute( | ||
&self, | ||
partition: usize, | ||
context: Arc<TaskContext>, | ||
) -> Result<SendableRecordBatchStream> { | ||
let stream = DummyStream { | ||
schema: self.schema.clone(), | ||
}; | ||
Ok(Box::pin(stream)) | ||
} | ||
|
||
fn metrics(&self) -> Option<MetricsSet> { | ||
None | ||
} | ||
|
||
fn statistics(&self) -> Result<Statistics> { | ||
Ok(self.statistics.clone()) | ||
} | ||
} | ||
|
||
impl DisplayAs for DummyExec { | ||
fn fmt_as(&self, t: DisplayFormatType, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
write!(f, "dummmyyy")?; | ||
Ok(()) | ||
} | ||
} | ||
struct DummyStream { | ||
schema: Arc<Schema>, | ||
} | ||
impl Stream for DummyStream { | ||
type Item = Result<RecordBatch>; | ||
|
||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { | ||
return Poll::Pending; | ||
} | ||
} | ||
|
||
impl RecordBatchStream for DummyStream { | ||
fn schema(&self) -> SchemaRef { | ||
self.schema.clone() | ||
} | ||
} |
Oops, something went wrong.