mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-24 00:40:40 +00:00
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:
7
src/common/query/Cargo.toml
Normal file
7
src/common/query/Cargo.toml
Normal 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"]}
|
||||
1
src/common/query/src/lib.rs
Normal file
1
src/common/query/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod logical_plan;
|
||||
18
src/common/query/src/logical_plan/expr.rs
Normal file
18
src/common/query/src/logical_plan/expr.rs
Normal 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
|
||||
}
|
||||
}
|
||||
3
src/common/query/src/logical_plan/mod.rs
Normal file
3
src/common/query/src/logical_plan/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
mod expr;
|
||||
|
||||
pub use self::expr::Expr;
|
||||
16
src/common/recordbatch/Cargo.toml
Normal file
16
src/common/recordbatch/Cargo.toml
Normal 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"
|
||||
10
src/common/recordbatch/src/error.rs
Normal file
10
src/common/recordbatch/src/error.rs
Normal 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>;
|
||||
15
src/common/recordbatch/src/lib.rs
Normal file
15
src/common/recordbatch/src/lib.rs
Normal 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>>;
|
||||
10
src/common/recordbatch/src/recordbatch.rs
Normal file
10
src/common/recordbatch/src/recordbatch.rs
Normal 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,
|
||||
}
|
||||
Reference in New Issue
Block a user