Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tql): add initial support for start,stop,step as sql functions #3507

Merged
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2cd9e39
feat(tql): add initial support for start,stop,step as sql functions
etolbakov Mar 13, 2024
bc1a549
fix(tql): remove unwraps, adjust fmt
etolbakov Mar 14, 2024
cd8b958
fix(tql): address taplo issue
etolbakov Mar 14, 2024
77cfa94
feat(tql): update parse_tql_query logic
etolbakov Mar 14, 2024
4d8711e
fix(tql): change query parsing logic to use parser instead of delimiter
etolbakov Mar 15, 2024
b665614
fix(tql): add timestamp function support, add sqlness tests
etolbakov Mar 17, 2024
26a4ab2
fix(tql): add lookback optional param for tql eval
etolbakov Mar 18, 2024
4bff8a5
fix(tql): adjust tests for now() function
etolbakov Mar 20, 2024
edafbe3
Merge branch 'main' into tql-start-stop-step-sql-functions-support
etolbakov Mar 20, 2024
d91c4e9
fix(tql): introduce the tqlerror to differentiate failures on parsing…
etolbakov Mar 21, 2024
b648e92
fix(tql): add tests for explain/analyze
etolbakov Mar 21, 2024
21f40ae
feat(tql): add lookback support for explain/analyze, update tests
etolbakov Mar 21, 2024
7d1d45b
Merge branch 'main' into tql-start-stop-step-sql-functions-support
etolbakov Mar 21, 2024
47a36de
feat(tql): add more sqlness tests
etolbakov Mar 22, 2024
bbac2f4
chore(tql): extract common logic for eval, analyze and explain into a…
etolbakov Mar 24, 2024
96fc4b9
feat(tql): address CR points
etolbakov Mar 26, 2024
fbdb7d0
Merge branch 'main' into tql-start-stop-step-sql-functions-support
etolbakov Mar 26, 2024
1281597
feat(tql): use snafu for tql errors, add more docs
etolbakov Mar 27, 2024
b59ffba
Merge branch 'main' into tql-start-stop-step-sql-functions-support
etolbakov Mar 27, 2024
368276b
feat(tql): address CR points
etolbakov Mar 27, 2024
1a611d8
Merge branch 'main' into tql-start-stop-step-sql-functions-support
etolbakov Mar 27, 2024
1abf153
Merge branch 'main' into tql-start-stop-step-sql-functions-support
etolbakov Mar 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions src/sql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ workspace = true

[dependencies]
api.workspace = true
chrono.workspace = true
common-base.workspace = true
common-catalog.workspace = true
common-decimal.workspace = true
common-error.workspace = true
common-macro.workspace = true
common-query.workspace = true
common-time.workspace = true
datafusion.workspace = true
datafusion-common.workspace = true
datafusion-expr.workspace = true
datafusion-physical-expr.workspace = true
datafusion-sql.workspace = true
datatypes.workspace = true
hex = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion src/sql/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::ast::{Expr, Value as SqlValue};
pub type Result<T> = std::result::Result<T, Error>;

/// SQL parser errors.
// Now the error in parser does not contains backtrace to avoid generating backtrace
// Now the error in parser does not contain backtrace to avoid generating backtrace
// every time the parser parses an invalid SQL.
#[derive(Snafu)]
#[snafu(visibility(pub))]
Expand Down
1 change: 1 addition & 0 deletions src/sql/src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub(crate) mod create_parser;
pub(crate) mod delete_parser;
pub(crate) mod describe_parser;
pub(crate) mod drop_parser;
mod error;
pub(crate) mod explain_parser;
pub(crate) mod insert_parser;
pub(crate) mod query_parser;
Expand Down
56 changes: 56 additions & 0 deletions src/sql/src/parsers/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2023 Greptime Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use datafusion_common::DataFusionError;
use sqlparser::parser::ParserError;

pub enum TQLError {
etolbakov marked this conversation as resolved.
Show resolved Hide resolved
Parser(String),
Simplification(String),
Evaluation(String),
}

impl From<ParserError> for TQLError {
fn from(err: ParserError) -> Self {
TQLError::Parser(err.to_string())
}
}

impl From<DataFusionError> for TQLError {
fn from(err: DataFusionError) -> Self {
match err {
DataFusionError::SQL(parser_err) => TQLError::Parser(parser_err.to_string()),
DataFusionError::Plan(plan_err) => TQLError::Evaluation(plan_err),
unspecified => {
TQLError::Evaluation(format!("Failed to evaluate due to: {unspecified:?}"))
}
}
}
}

impl From<TQLError> for ParserError {
fn from(tql_err: TQLError) -> Self {
match tql_err {
TQLError::Parser(s) => {
ParserError::ParserError(format!("Failed to parse the query: {s}"))
}
TQLError::Simplification(s) => {
ParserError::ParserError(format!("Failed to simplify the query: {s}"))
}
TQLError::Evaluation(s) => {
ParserError::ParserError(format!("Failed to evaluate the query: {s}"))
}
}
}
}
Loading