feat: query engine impl on datafusion (#10)

* feat: query engine impl on datafusion

* feat: adds physical_optimizer, physical_planner and executor

* feat: impl adpaters between datafuion and greptime query engine core APIs.

* feat: impl PhysicalPlanAdapter and ExecutionPlanAdapter

* feat: rename table datafusion mod to adapter

* fix: clippy warning

* fix: conflicts with develop branch

* feat: add database mod

* fix: CR comment

* fix: by CR comments

* fix: conflicts with develop branch

* fix: by CR comments
This commit is contained in:
dennis zhuang
2022-04-26 15:17:32 +08:00
committed by GitHub
parent e334e55bf7
commit 3a2f794f6c
35 changed files with 2597 additions and 8 deletions

View File

@@ -0,0 +1,7 @@
[package]
name = "common-query"
version = "0.1.0"
edition = "2021"
[dependencies]
datafusion = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2", features = ["simd"]}

View File

@@ -0,0 +1 @@
pub mod logical_plan;

View File

@@ -0,0 +1,18 @@
use datafusion::logical_plan::Expr as DfExpr;
/// Central struct of query API.
/// Represent logical expressions such as `A + 1`, or `CAST(c1 AS int)`.
#[derive(Clone, PartialEq, Hash)]
pub struct Expr {
df_expr: DfExpr,
}
impl Expr {
pub fn new(df_expr: DfExpr) -> Self {
Self { df_expr }
}
pub fn df_expr(&self) -> &DfExpr {
&self.df_expr
}
}

View File

@@ -0,0 +1,3 @@
mod expr;
pub use self::expr::Expr;

View File

@@ -0,0 +1,16 @@
[package]
name = "common-recordbatch"
version = "0.1.0"
edition = "2021"
[dependencies.arrow]
package = "arrow2"
version="0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute"]
[dependencies]
datafusion = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2", features = ["simd"]}
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2"}
datatypes = {path ="../../datatypes" }
futures = "0.3"
snafu = "0.7.0"

View File

@@ -0,0 +1,10 @@
use arrow::error::ArrowError;
use snafu::Snafu;
#[derive(Debug, Snafu)]
#[snafu(visibility(pub))]
pub enum Error {
#[snafu(display("Arrow error: {}", source))]
Arrow { source: ArrowError },
}
pub type Result<T> = std::result::Result<T, Error>;

View File

@@ -0,0 +1,15 @@
pub mod error;
mod recordbatch;
use std::pin::Pin;
use datatypes::schema::SchemaRef;
use error::Result;
use futures::Stream;
pub use recordbatch::RecordBatch;
pub trait RecordBatchStream: Stream<Item = Result<RecordBatch>> {
fn schema(&self) -> SchemaRef;
}
pub type SendableRecordBatchStream = Pin<Box<dyn RecordBatchStream + Send>>;

View File

@@ -0,0 +1,10 @@
use std::sync::Arc;
use datafusion_common::record_batch::RecordBatch as DfRecordBatch;
use datatypes::schema::Schema;
#[derive(Clone, Debug)]
pub struct RecordBatch {
pub schema: Arc<Schema>,
pub df_recordbatch: DfRecordBatch,
}