mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-19 22:40:40 +00:00
chore: upgrade promql-parser version (#1484)
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -6230,9 +6230,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "promql-parser"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24766dbb98852e704a98fc2c003d2b3ffa48317ab09b4ae184925f0e60385764"
|
||||
checksum = "b86b6a58ddafa87824aecefd60ab8bf33638f4dc687c560a3c06a31122948274"
|
||||
dependencies = [
|
||||
"cfgrammar",
|
||||
"lazy_static",
|
||||
|
||||
@@ -15,7 +15,7 @@ common-function-macro = { path = "../common/function-macro" }
|
||||
datafusion.workspace = true
|
||||
datatypes = { path = "../datatypes" }
|
||||
futures = "0.3"
|
||||
promql-parser = "0.1.0"
|
||||
promql-parser = "0.1.1"
|
||||
session = { path = "../session" }
|
||||
snafu = { version = "0.7", features = ["backtraces"] }
|
||||
table = { path = "../table" }
|
||||
|
||||
@@ -34,9 +34,9 @@ use datafusion::sql::TableReference;
|
||||
use datatypes::arrow::datatypes::DataType as ArrowDataType;
|
||||
use promql_parser::label::{MatchOp, Matcher, Matchers, METRIC_NAME};
|
||||
use promql_parser::parser::{
|
||||
token, AggModifier, AggregateExpr, BinaryExpr as PromBinaryExpr, Call, EvalStmt,
|
||||
Expr as PromExpr, Function, MatrixSelector, NumberLiteral, Offset, ParenExpr, StringLiteral,
|
||||
SubqueryExpr, TokenType, UnaryExpr, VectorSelector,
|
||||
token, AggregateExpr, BinaryExpr as PromBinaryExpr, Call, EvalStmt, Expr as PromExpr, Function,
|
||||
LabelModifier, MatrixSelector, NumberLiteral, Offset, ParenExpr, StringLiteral, SubqueryExpr,
|
||||
TokenType, UnaryExpr, VectorSelector,
|
||||
};
|
||||
use snafu::{ensure, OptionExt, ResultExt};
|
||||
use table::table::adapter::DfTableProviderAdapter;
|
||||
@@ -393,6 +393,10 @@ impl PromPlanner {
|
||||
.build()
|
||||
.context(DataFusionPlanningSnafu)?
|
||||
}
|
||||
PromExpr::Extension(_) => UnsupportedExprSnafu {
|
||||
name: "Prom Extension",
|
||||
}
|
||||
.fail()?,
|
||||
};
|
||||
Ok(res)
|
||||
}
|
||||
@@ -564,10 +568,10 @@ impl PromPlanner {
|
||||
fn agg_modifier_to_col(
|
||||
&mut self,
|
||||
input_schema: &DFSchemaRef,
|
||||
modifier: &AggModifier,
|
||||
modifier: &LabelModifier,
|
||||
) -> Result<Vec<DfExpr>> {
|
||||
match modifier {
|
||||
AggModifier::By(labels) => {
|
||||
LabelModifier::Include(labels) => {
|
||||
let mut exprs = Vec::with_capacity(labels.len());
|
||||
for label in labels {
|
||||
// nonexistence label will be ignored
|
||||
@@ -584,7 +588,7 @@ impl PromPlanner {
|
||||
|
||||
Ok(exprs)
|
||||
}
|
||||
AggModifier::Without(labels) => {
|
||||
LabelModifier::Exclude(labels) => {
|
||||
let mut all_fields = input_schema
|
||||
.fields()
|
||||
.iter()
|
||||
@@ -730,6 +734,7 @@ impl PromPlanner {
|
||||
| PromExpr::Subquery(_)
|
||||
| PromExpr::VectorSelector(_)
|
||||
| PromExpr::MatrixSelector(_)
|
||||
| PromExpr::Extension(_)
|
||||
| PromExpr::Call(_) => {
|
||||
if result.input.replace(*arg.clone()).is_some() {
|
||||
MultipleVectorSnafu { expr: *arg.clone() }.fail()?;
|
||||
@@ -1018,6 +1023,7 @@ impl PromPlanner {
|
||||
PromExpr::VectorSelector(_)
|
||||
| PromExpr::MatrixSelector(_)
|
||||
| PromExpr::Call(_)
|
||||
| PromExpr::Extension(_)
|
||||
| PromExpr::Aggregate(_)
|
||||
| PromExpr::Subquery(_) => None,
|
||||
PromExpr::Paren(ParenExpr { expr }) => Self::try_build_literal_expr(expr),
|
||||
@@ -1530,7 +1536,7 @@ mod test {
|
||||
|
||||
// test group without
|
||||
if let PromExpr::Aggregate(AggregateExpr { modifier, .. }) = &mut eval_stmt.expr {
|
||||
*modifier = Some(AggModifier::Without(
|
||||
*modifier = Some(LabelModifier::Exclude(
|
||||
vec![String::from("tag_1")].into_iter().collect(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ metrics.workspace = true
|
||||
object-store = { path = "../object-store" }
|
||||
once_cell = "1.10"
|
||||
promql = { path = "../promql" }
|
||||
promql-parser = "0.1.0"
|
||||
promql-parser = "0.1.1"
|
||||
regex = "1.6"
|
||||
serde.workspace = true
|
||||
serde_json = "1.0"
|
||||
|
||||
@@ -49,7 +49,7 @@ parking_lot = "0.12"
|
||||
pgwire = "0.13"
|
||||
pin-project = "1.0"
|
||||
postgres-types = { version = "0.2", features = ["with-chrono-0_4"] }
|
||||
promql-parser = "0.1.0"
|
||||
promql-parser = "0.1.1"
|
||||
prost.workspace = true
|
||||
query = { path = "../query" }
|
||||
rand.workspace = true
|
||||
|
||||
@@ -444,6 +444,7 @@ fn promql_expr_to_metric_name(expr: &PromqlExpr) -> Option<String> {
|
||||
PromqlExpr::Subquery(SubqueryExpr { expr, .. }) => promql_expr_to_metric_name(expr),
|
||||
PromqlExpr::NumberLiteral(_) => None,
|
||||
PromqlExpr::StringLiteral(_) => None,
|
||||
PromqlExpr::Extension(_) => None,
|
||||
PromqlExpr::VectorSelector(VectorSelector { matchers, .. }) => {
|
||||
matchers.find_matchers(METRIC_NAME).pop().cloned()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user