Skip to content

Commit

Permalink
implement influxql stmt rewriter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Mar 7, 2023
1 parent 31573e3 commit 273fd88
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 337 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ tokio = { version = "1.25", features = ["full"] }
wal = { path = "wal" }
message_queue = { path = "components/message_queue" }
zstd = { version = "0.12", default-features = false }
itertools = "0.10.5"

[dependencies]
analytic_engine = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions sql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ sqlparser = { workspace = true }
table_engine = { workspace = true }
influxdb_influxql_parser = {git = "https://github.com/Rachelint/influxdb_iox.git", branch = "influxql-parser"}
regex-syntax = "0.6.28"
itertools = { workspace = true }

[dev-dependencies]
common_types = { workspace = true, features = ["test"] }
Expand Down
17 changes: 15 additions & 2 deletions sql/src/influxql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@ pub mod error {
#[snafu(display("Unimplemented influxql statement, msg: {}", msg))]
Unimplemented { msg: String },

#[snafu(display("Unimplemented influxql statement, source: {}", source))]
RewriteStmtWithCause { source: GenericError },
#[snafu(display(
"Rewrite influxql from clause with cause, msg:{}, source:{}",
msg,
source
))]
RewriteFromWithCause { msg: String, source: GenericError },

#[snafu(display("Rewrite influxql from clause no cause, msg:{}", msg))]
RewriteFromNoCause { msg: String },

#[snafu(display("Unimplemented influxql select fields with cause, source: {}", source))]
RewriteFieldsWithCause { msg: String, source: GenericError },

#[snafu(display("Unimplemented influxql select fields no cause, msg: {}", msg))]
RewriteFieldsNoCause { msg: String },
}

define_result!(Error);
Expand Down
4 changes: 4 additions & 0 deletions sql/src/influxql/planner.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use influxdb_influxql_parser::statement::Statement as InfluxqlStatement;

use super::stmt_rewriter::StmtRewriter;
use crate::{influxql::error::*, plan::Plan, provider::MetaProvider};

pub(crate) struct Planner<'a, P: MetaProvider> {
Expand Down Expand Up @@ -28,6 +29,9 @@ impl<'a, P: MetaProvider> Planner<'a, P> {
}

fn rewrite_stmt(&self, stmt: InfluxqlStatement) -> Result<InfluxqlStatement> {
let mut stmt = stmt;
let stmt_rewriter = StmtRewriter::new(&self.sql_planner);
// stmt_rewriter.rewrite_from(&mut stmt)?;
todo!()
}
}
Loading

0 comments on commit 273fd88

Please sign in to comment.