diff --git a/Cargo.lock b/Cargo.lock index ab6d928b3f..b240fb3738 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -723,6 +723,28 @@ dependencies = [ "scanlex", ] +[[package]] +name = "chrono-tz" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa48fa079165080f11d7753fd0bc175b7d391f276b965fe4b55bfad67856e463" +dependencies = [ + "chrono", + "chrono-tz-build", + "phf", +] + +[[package]] +name = "chrono-tz-build" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9998fb9f7e9b2111641485bf8beb32f92945f97f92a3d061f744cfef335f751" +dependencies = [ + "parse-zoneinfo", + "phf", + "phf_codegen", +] + [[package]] name = "ciborium" version = "0.2.0" @@ -2331,6 +2353,8 @@ name = "influxdb_influxql_parser" version = "0.1.0" dependencies = [ "assert_matches", + "chrono", + "chrono-tz", "insta", "nom", "once_cell", @@ -3887,6 +3911,15 @@ dependencies = [ "workspace-hack", ] +[[package]] +name = "parse-zoneinfo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" +dependencies = [ + "regex", +] + [[package]] name = "paste" version = "1.0.11" @@ -3999,6 +4032,44 @@ dependencies = [ "indexmap", ] +[[package]] +name = "phf" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56ac890c5e3ca598bbdeaa99964edb5b0258a583a9eb6ef4e89fc85d9224770" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_shared" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.0.12" @@ -6529,10 +6600,12 @@ dependencies = [ "once_cell", "parking_lot 0.12.1", "parquet", + "phf_shared", "predicates", "prost 0.11.6", "prost-types 0.11.6", "rand", + "rand_core", "regex", "regex-automata", "regex-syntax", diff --git a/influxdb_influxql_parser/Cargo.toml b/influxdb_influxql_parser/Cargo.toml index c1a4505294..e155ef0eec 100644 --- a/influxdb_influxql_parser/Cargo.toml +++ b/influxdb_influxql_parser/Cargo.toml @@ -8,7 +8,9 @@ license.workspace = true [dependencies] # In alphabetical order nom = { version = "7", default-features = false, features = ["std"] } once_cell = "1" -workspace-hack = { path = "../workspace-hack"} +chrono = { version = "0.4", default-features = false } +chrono-tz = { version = "0.8" } +workspace-hack = { path = "../workspace-hack" } [dev-dependencies] # In alphabetical order test_helpers = { path = "../test_helpers" } diff --git a/influxdb_influxql_parser/src/select.rs b/influxdb_influxql_parser/src/select.rs index 13604cd0e2..a0f462e77e 100644 --- a/influxdb_influxql_parser/src/select.rs +++ b/influxdb_influxql_parser/src/select.rs @@ -13,13 +13,13 @@ use crate::expression::arithmetic::{ }; use crate::expression::conditional::is_valid_now_call; use crate::identifier::{identifier, Identifier}; -use crate::internal::{expect, verify, ParseResult}; +use crate::impl_tuple_clause; +use crate::internal::{expect, map_fail, verify, ParseResult}; use crate::keywords::keyword; use crate::literal::{duration, literal, number, unsigned_integer, Literal, Number}; use crate::parameter::parameter; use crate::select::MeasurementSelection::Subquery; use crate::string::{regex, single_quoted_string, Regex}; -use crate::{impl_tuple_clause, write_escaped}; use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::char; @@ -630,17 +630,15 @@ fn soffset_clause(i: &str) -> ParseResult<&str, SOffsetClause> { )(i) } -/// Represents the value of the time zone string of a `TZ` clause. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct TimeZoneClause(pub(crate) String); +/// Represents an IANA time zone parsed from the `TZ` clause. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct TimeZoneClause(pub(crate) chrono_tz::Tz); -impl_tuple_clause!(TimeZoneClause, String); +impl_tuple_clause!(TimeZoneClause, chrono_tz::Tz); impl Display for TimeZoneClause { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - f.write_str("TZ('")?; - write_escaped!(f, self.0, '\n' => "\\n", '\\' => "\\\\", '\'' => "\\'", '"' => "\\\""); - f.write_str("')") + write!(f, "TZ('{}')", self.0) } } @@ -649,6 +647,34 @@ impl Display for TimeZoneClause { /// ```text /// timezone_clause ::= "TZ" "(" single_quoted_string ")" /// ``` +/// +/// ## NOTE +/// +/// There are some differences with how the IANA timezone string +/// is parsed to a [chrono_tz::Tz] in Rust vs a [`time.Location`][location] via +/// Go's [`time.LoadLocation`][load_location] +/// function, which is used by the canonical Go InfluxQL parser. +/// +/// It isn't expected that these differences matter for parsing, however, +/// the notable differences are: +/// +/// * Specifying the location name `Local` returns `time.Local`, which represents +/// the system's local time zone. As a result, a user could specify a `TZ` clause +/// as `TZ('Local')` to use the local time zone of the server running InfluxDB. +/// +/// * on macOS, IANA name lookups are case-insensitive, whereas the Rust implementation +/// is case-sensitive. However, this is purely a result of the Go implementation, +/// which loads the zoneinfo files from the filesystem. macOS uses a case-insensitive +/// file system by default. When using a case-sensitive file system, name lookups are +/// also case-sensitive. +/// +/// * Go's implementation (by default) loads the timezone database from the local file system +/// vs Rust's implementation, where the database is statically compiled into the binary. Changes +/// to the IANA database on disk will allow an existing binary to load new timezones. +/// +/// [location]: https://github.com/influxdata/influxql/blob/7e7d61973256ffeef4b99edd0a89f18a9e52fa2d/parser.go#L2384 +/// [load_location]: https://pkg.go.dev/time#LoadLocation +/// fn timezone_clause(i: &str) -> ParseResult<&str, TimeZoneClause> { preceded( keyword("TZ"), @@ -656,7 +682,12 @@ fn timezone_clause(i: &str) -> ParseResult<&str, TimeZoneClause> { preceded(ws0, char('(')), expect( "invalid TZ clause, expected string", - preceded(ws0, map(single_quoted_string, TimeZoneClause)), + preceded( + ws0, + map_fail("unable to find timezone", single_quoted_string, |s| { + s.parse().map(TimeZoneClause) + }), + ), ), preceded(ws0, char(')')), ), @@ -1189,13 +1220,17 @@ mod test { #[test] fn test_timezone_clause() { let (_, got) = timezone_clause("TZ('Australia/Hobart')").unwrap(); - assert_eq!(*got, "Australia/Hobart"); + assert_eq!(*got, chrono_tz::Australia::Hobart); + + let (_, got) = timezone_clause("TZ('UTC')").unwrap(); + assert_eq!(*got, chrono_tz::UTC); // Fallible cases assert_expect_error!( timezone_clause("TZ(foo)"), "invalid TZ clause, expected string" ); + assert_expect_error!(timezone_clause("TZ('Foo')"), "unable to find timezone"); } #[test] diff --git a/influxdb_influxql_parser/src/snapshots/influxdb_influxql_parser__visit__test__select_statement-6.snap b/influxdb_influxql_parser/src/snapshots/influxdb_influxql_parser__visit__test__select_statement-6.snap index 715115ee4b..926231af6e 100644 --- a/influxdb_influxql_parser/src/snapshots/influxdb_influxql_parser__visit__test__select_statement-6.snap +++ b/influxdb_influxql_parser/src/snapshots/influxdb_influxql_parser__visit__test__select_statement-6.snap @@ -2,8 +2,8 @@ source: influxdb_influxql_parser/src/visit.rs expression: "visit_statement!(r#\"SELECT value FROM (SELECT usage FROM cpu WHERE host = \"node1\")\n WHERE region =~ /west/ AND value > 5\n GROUP BY TIME(5m), host\n FILL(previous)\n ORDER BY TIME DESC\n LIMIT 1 OFFSET 2\n SLIMIT 3 SOFFSET 4\n TZ('Australia/Hobart')\n \"#)" --- -- "pre_visit_statement: Select(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(\"Australia/Hobart\")) })" -- "pre_visit_select_statement: SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(\"Australia/Hobart\")) }" +- "pre_visit_statement: Select(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(Australia/Hobart)) })" +- "pre_visit_select_statement: SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(Australia/Hobart)) }" - "pre_visit_select_field_list: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }" - "pre_visit_select_field: Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }" - "pre_visit_expr: VarRef { name: Identifier(\"value\"), data_type: None }" @@ -86,8 +86,8 @@ expression: "visit_statement!(r#\"SELECT value FROM (SELECT usage FROM cpu WHERE - "post_visit_slimit_clause: SLimitClause(3)" - "pre_visit_soffset_clause: SOffsetClause(4)" - "post_visit_soffset_clause: SOffsetClause(4)" -- "pre_visit_timezone_clause: TimeZoneClause(\"Australia/Hobart\")" -- "post_visit_timezone_clause: TimeZoneClause(\"Australia/Hobart\")" -- "post_visit_select_statement: SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(\"Australia/Hobart\")) }" -- "post_visit_statement: Select(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(\"Australia/Hobart\")) })" +- "pre_visit_timezone_clause: TimeZoneClause(Australia/Hobart)" +- "post_visit_timezone_clause: TimeZoneClause(Australia/Hobart)" +- "post_visit_select_statement: SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(Australia/Hobart)) }" +- "post_visit_statement: Select(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(Australia/Hobart)) })" diff --git a/influxdb_influxql_parser/src/snapshots/influxdb_influxql_parser__visit_mut__test__select_statement-6.snap b/influxdb_influxql_parser/src/snapshots/influxdb_influxql_parser__visit_mut__test__select_statement-6.snap index 330e5dc006..d4975bfeb1 100644 --- a/influxdb_influxql_parser/src/snapshots/influxdb_influxql_parser__visit_mut__test__select_statement-6.snap +++ b/influxdb_influxql_parser/src/snapshots/influxdb_influxql_parser__visit_mut__test__select_statement-6.snap @@ -2,8 +2,8 @@ source: influxdb_influxql_parser/src/visit_mut.rs expression: "visit_statement!(r#\"SELECT value FROM (SELECT usage FROM cpu WHERE host = \"node1\")\n WHERE region =~ /west/ AND value > 5\n GROUP BY TIME(5m), host\n FILL(previous)\n ORDER BY TIME DESC\n LIMIT 1 OFFSET 2\n SLIMIT 3 SOFFSET 4\n TZ('Australia/Hobart')\n \"#)" --- -- "pre_visit_statement: Select(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(\"Australia/Hobart\")) })" -- "pre_visit_select_statement: SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(\"Australia/Hobart\")) }" +- "pre_visit_statement: Select(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(Australia/Hobart)) })" +- "pre_visit_select_statement: SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(Australia/Hobart)) }" - "pre_visit_select_field_list: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }" - "pre_visit_select_field: Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }" - "pre_visit_expr: VarRef { name: Identifier(\"value\"), data_type: None }" @@ -86,8 +86,8 @@ expression: "visit_statement!(r#\"SELECT value FROM (SELECT usage FROM cpu WHERE - "post_visit_slimit_clause: SLimitClause(3)" - "pre_visit_soffset_clause: SOffsetClause(4)" - "post_visit_soffset_clause: SOffsetClause(4)" -- "pre_visit_timezone_clause: TimeZoneClause(\"Australia/Hobart\")" -- "post_visit_timezone_clause: TimeZoneClause(\"Australia/Hobart\")" -- "post_visit_select_statement: SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(\"Australia/Hobart\")) }" -- "post_visit_statement: Select(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(\"Australia/Hobart\")) })" +- "pre_visit_timezone_clause: TimeZoneClause(Australia/Hobart)" +- "post_visit_timezone_clause: TimeZoneClause(Australia/Hobart)" +- "post_visit_select_statement: SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(Australia/Hobart)) }" +- "post_visit_statement: Select(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"value\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Subquery(SelectStatement { fields: ZeroOrMore { contents: [Field { expr: VarRef { name: Identifier(\"usage\"), data_type: None }, alias: None }] }, from: ZeroOrMore { contents: [Name(QualifiedMeasurementName { database: None, retention_policy: None, name: Name(Identifier(\"cpu\")) })] }, condition: Some(WhereClause(Binary { lhs: Expr(VarRef { name: Identifier(\"host\"), data_type: None }), op: Eq, rhs: Expr(VarRef { name: Identifier(\"node1\"), data_type: None }) })), group_by: None, fill: None, order_by: None, limit: None, offset: None, series_limit: None, series_offset: None, timezone: None })] }, condition: Some(WhereClause(Binary { lhs: Binary { lhs: Expr(VarRef { name: Identifier(\"region\"), data_type: None }), op: EqRegex, rhs: Expr(Literal(Regex(Regex(\"west\")))) }, op: And, rhs: Binary { lhs: Expr(VarRef { name: Identifier(\"value\"), data_type: None }), op: Gt, rhs: Expr(Literal(Unsigned(5))) } })), group_by: Some(ZeroOrMore { contents: [Time { interval: Literal(Duration(Duration(300000000000))), offset: None }, Tag(Identifier(\"host\"))] }), fill: Some(Previous), order_by: Some(Descending), limit: Some(LimitClause(1)), offset: Some(OffsetClause(2)), series_limit: Some(SLimitClause(3)), series_offset: Some(SOffsetClause(4)), timezone: Some(TimeZoneClause(Australia/Hobart)) })" diff --git a/influxdb_influxql_parser/src/visit.rs b/influxdb_influxql_parser/src/visit.rs index 2e44984bae..ee2ce8dca3 100644 --- a/influxdb_influxql_parser/src/visit.rs +++ b/influxdb_influxql_parser/src/visit.rs @@ -3,14 +3,16 @@ //! # Example //! //! ``` -//! use influxdb_influxql_parser::visit::{Visitable, Visitor, VisitorResult}; +//! use influxdb_influxql_parser::visit::{Visitable, Visitor}; //! use influxdb_influxql_parser::parse_statements; //! use influxdb_influxql_parser::common::WhereClause; //! //! struct MyVisitor; //! //! impl Visitor for MyVisitor { -//! fn post_visit_where_clause(self, n: &WhereClause) -> VisitorResult { +//! type Error = (); +//! +//! fn post_visit_where_clause(self, n: &WhereClause) -> Result { //! println!("{}", n); //! Ok(self) //! } @@ -47,9 +49,6 @@ use crate::show_tag_values::{ShowTagValuesStatement, WithKeyClause}; use crate::simple_from_clause::{DeleteFromClause, ShowFromClause}; use crate::statement::Statement; -/// The result type for a [`Visitor`]. -pub type VisitorResult = Result; - /// Controls how the visitor recursion should proceed. pub enum Recursion { /// Attempt to visit all the children, recursively, of this expression. @@ -63,13 +62,16 @@ pub enum Recursion { /// any [`Visitable::accept`], `pre_visit` functions are invoked repeatedly /// until a leaf node is reached or a `pre_visit` function returns [`Recursion::Stop`]. pub trait Visitor: Sized { + /// The type returned in the event of an error traversing the tree. + type Error; + /// Invoked before any children of the InfluxQL statement are visited. - fn pre_visit_statement(self, _n: &Statement) -> VisitorResult> { + fn pre_visit_statement(self, _n: &Statement) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the InfluxQL statement are visited. - fn post_visit_statement(self, _n: &Statement) -> VisitorResult { + fn post_visit_statement(self, _n: &Statement) -> Result { Ok(self) } @@ -77,7 +79,7 @@ pub trait Visitor: Sized { fn pre_visit_create_database_statement( self, _n: &CreateDatabaseStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } @@ -86,37 +88,46 @@ pub trait Visitor: Sized { fn post_visit_create_database_statement( self, _n: &CreateDatabaseStatement, - ) -> VisitorResult { + ) -> Result { Ok(self) } /// Invoked before any children of the `DELETE` statement are visited. - fn pre_visit_delete_statement(self, _n: &DeleteStatement) -> VisitorResult> { + fn pre_visit_delete_statement( + self, + _n: &DeleteStatement, + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `DELETE` statement are visited. - fn post_visit_delete_statement(self, _n: &DeleteStatement) -> VisitorResult { + fn post_visit_delete_statement(self, _n: &DeleteStatement) -> Result { Ok(self) } /// Invoked before any children of the `FROM` clause of a `DELETE` statement are visited. - fn pre_visit_delete_from_clause(self, _n: &DeleteFromClause) -> VisitorResult> { + fn pre_visit_delete_from_clause( + self, + _n: &DeleteFromClause, + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `FROM` clause of a `DELETE` statement are visited. - fn post_visit_delete_from_clause(self, _n: &DeleteFromClause) -> VisitorResult { + fn post_visit_delete_from_clause(self, _n: &DeleteFromClause) -> Result { Ok(self) } /// Invoked before any children of the measurement name are visited. - fn pre_visit_measurement_name(self, _n: &MeasurementName) -> VisitorResult> { + fn pre_visit_measurement_name( + self, + _n: &MeasurementName, + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the measurement name are visited. - fn post_visit_measurement_name(self, _n: &MeasurementName) -> VisitorResult { + fn post_visit_measurement_name(self, _n: &MeasurementName) -> Result { Ok(self) } @@ -124,7 +135,7 @@ pub trait Visitor: Sized { fn pre_visit_drop_measurement_statement( self, _n: &DropMeasurementStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } @@ -132,27 +143,33 @@ pub trait Visitor: Sized { fn post_visit_drop_measurement_statement( self, _n: &DropMeasurementStatement, - ) -> VisitorResult { + ) -> Result { Ok(self) } /// Invoked before any children of the `EXPLAIN` statement are visited. - fn pre_visit_explain_statement(self, _n: &ExplainStatement) -> VisitorResult> { + fn pre_visit_explain_statement( + self, + _n: &ExplainStatement, + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `EXPLAIN` statement are visited. - fn post_visit_explain_statement(self, _n: &ExplainStatement) -> VisitorResult { + fn post_visit_explain_statement(self, _n: &ExplainStatement) -> Result { Ok(self) } /// Invoked before any children of the `SELECT` statement are visited. - fn pre_visit_select_statement(self, _n: &SelectStatement) -> VisitorResult> { + fn pre_visit_select_statement( + self, + _n: &SelectStatement, + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `SELECT` statement are visited. - fn post_visit_select_statement(self, _n: &SelectStatement) -> VisitorResult { + fn post_visit_select_statement(self, _n: &SelectStatement) -> Result { Ok(self) } @@ -160,7 +177,7 @@ pub trait Visitor: Sized { fn pre_visit_show_databases_statement( self, _n: &ShowDatabasesStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } @@ -168,7 +185,7 @@ pub trait Visitor: Sized { fn post_visit_show_databases_statement( self, _n: &ShowDatabasesStatement, - ) -> VisitorResult { + ) -> Result { Ok(self) } @@ -176,7 +193,7 @@ pub trait Visitor: Sized { fn pre_visit_show_measurements_statement( self, _n: &ShowMeasurementsStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } @@ -184,7 +201,7 @@ pub trait Visitor: Sized { fn post_visit_show_measurements_statement( self, _n: &ShowMeasurementsStatement, - ) -> VisitorResult { + ) -> Result { Ok(self) } @@ -192,7 +209,7 @@ pub trait Visitor: Sized { fn pre_visit_show_retention_policies_statement( self, _n: &ShowRetentionPoliciesStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } @@ -200,7 +217,7 @@ pub trait Visitor: Sized { fn post_visit_show_retention_policies_statement( self, _n: &ShowRetentionPoliciesStatement, - ) -> VisitorResult { + ) -> Result { Ok(self) } @@ -208,12 +225,15 @@ pub trait Visitor: Sized { fn pre_visit_show_tag_keys_statement( self, _n: &ShowTagKeysStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `SHOW TAG KEYS` statement are visited. - fn post_visit_show_tag_keys_statement(self, _n: &ShowTagKeysStatement) -> VisitorResult { + fn post_visit_show_tag_keys_statement( + self, + _n: &ShowTagKeysStatement, + ) -> Result { Ok(self) } @@ -221,7 +241,7 @@ pub trait Visitor: Sized { fn pre_visit_show_tag_values_statement( self, _n: &ShowTagValuesStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } @@ -229,7 +249,7 @@ pub trait Visitor: Sized { fn post_visit_show_tag_values_statement( self, _n: &ShowTagValuesStatement, - ) -> VisitorResult { + ) -> Result { Ok(self) } @@ -237,7 +257,7 @@ pub trait Visitor: Sized { fn pre_visit_show_field_keys_statement( self, _n: &ShowFieldKeysStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } @@ -245,7 +265,7 @@ pub trait Visitor: Sized { fn post_visit_show_field_keys_statement( self, _n: &ShowFieldKeysStatement, - ) -> VisitorResult { + ) -> Result { Ok(self) } @@ -253,42 +273,45 @@ pub trait Visitor: Sized { fn pre_visit_conditional_expression( self, _n: &ConditionalExpression, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the conditional expression are visited. - fn post_visit_conditional_expression(self, _n: &ConditionalExpression) -> VisitorResult { + fn post_visit_conditional_expression( + self, + _n: &ConditionalExpression, + ) -> Result { Ok(self) } /// Invoked before any children of the arithmetic expression are visited. - fn pre_visit_expr(self, _n: &Expr) -> VisitorResult> { + fn pre_visit_expr(self, _n: &Expr) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the arithmetic expression are visited. - fn post_visit_expr(self, _n: &Expr) -> VisitorResult { + fn post_visit_expr(self, _n: &Expr) -> Result { Ok(self) } /// Invoked before any fields of the `SELECT` projection are visited. - fn pre_visit_select_field_list(self, _n: &FieldList) -> VisitorResult> { + fn pre_visit_select_field_list(self, _n: &FieldList) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all fields of the `SELECT` projection are visited. - fn post_visit_select_field_list(self, _n: &FieldList) -> VisitorResult { + fn post_visit_select_field_list(self, _n: &FieldList) -> Result { Ok(self) } /// Invoked before any children of the field of a `SELECT` statement are visited. - fn pre_visit_select_field(self, _n: &Field) -> VisitorResult> { + fn pre_visit_select_field(self, _n: &Field) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the field of a `SELECT` statement are visited. - fn post_visit_select_field(self, _n: &Field) -> VisitorResult { + fn post_visit_select_field(self, _n: &Field) -> Result { Ok(self) } @@ -296,12 +319,15 @@ pub trait Visitor: Sized { fn pre_visit_select_from_clause( self, _n: &FromMeasurementClause, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `FROM` clause of a `SELECT` statement are visited. - fn post_visit_select_from_clause(self, _n: &FromMeasurementClause) -> VisitorResult { + fn post_visit_select_from_clause( + self, + _n: &FromMeasurementClause, + ) -> Result { Ok(self) } @@ -309,7 +335,7 @@ pub trait Visitor: Sized { fn pre_visit_select_measurement_selection( self, _n: &MeasurementSelection, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } @@ -317,47 +343,50 @@ pub trait Visitor: Sized { fn post_visit_select_measurement_selection( self, _n: &MeasurementSelection, - ) -> VisitorResult { + ) -> Result { Ok(self) } /// Invoked before any children of the `GROUP BY` clause are visited. - fn pre_visit_group_by_clause(self, _n: &GroupByClause) -> VisitorResult> { + fn pre_visit_group_by_clause(self, _n: &GroupByClause) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `GROUP BY` clause are visited. - fn post_visit_group_by_clause(self, _n: &GroupByClause) -> VisitorResult { + fn post_visit_group_by_clause(self, _n: &GroupByClause) -> Result { Ok(self) } /// Invoked before any children of the `GROUP BY` dimension expression are visited. - fn pre_visit_select_dimension(self, _n: &Dimension) -> VisitorResult> { + fn pre_visit_select_dimension(self, _n: &Dimension) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `GROUP BY` dimension expression are visited. - fn post_visit_select_dimension(self, _n: &Dimension) -> VisitorResult { + fn post_visit_select_dimension(self, _n: &Dimension) -> Result { Ok(self) } /// Invoked before any children of the `WHERE` clause are visited. - fn pre_visit_where_clause(self, _n: &WhereClause) -> VisitorResult> { + fn pre_visit_where_clause(self, _n: &WhereClause) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `WHERE` clause are visited. - fn post_visit_where_clause(self, _n: &WhereClause) -> VisitorResult { + fn post_visit_where_clause(self, _n: &WhereClause) -> Result { Ok(self) } /// Invoked before any children of the `FROM` clause for any `SHOW` statement are visited. - fn pre_visit_show_from_clause(self, _n: &ShowFromClause) -> VisitorResult> { + fn pre_visit_show_from_clause( + self, + _n: &ShowFromClause, + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `FROM` clause for any `SHOW` statement are visited. - fn post_visit_show_from_clause(self, _n: &ShowFromClause) -> VisitorResult { + fn post_visit_show_from_clause(self, _n: &ShowFromClause) -> Result { Ok(self) } @@ -365,7 +394,7 @@ pub trait Visitor: Sized { fn pre_visit_qualified_measurement_name( self, _n: &QualifiedMeasurementName, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } @@ -373,97 +402,103 @@ pub trait Visitor: Sized { fn post_visit_qualified_measurement_name( self, _n: &QualifiedMeasurementName, - ) -> VisitorResult { + ) -> Result { Ok(self) } /// Invoked before any children of the `FILL` clause are visited. - fn pre_visit_fill_clause(self, _n: &FillClause) -> VisitorResult> { + fn pre_visit_fill_clause(self, _n: &FillClause) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `FILL` clause are visited. - fn post_visit_fill_clause(self, _n: &FillClause) -> VisitorResult { + fn post_visit_fill_clause(self, _n: &FillClause) -> Result { Ok(self) } /// Invoked before any children of the `ORDER BY` clause are visited. - fn pre_visit_order_by_clause(self, _n: &OrderByClause) -> VisitorResult> { + fn pre_visit_order_by_clause(self, _n: &OrderByClause) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `ORDER BY` clause are visited. - fn post_visit_order_by_clause(self, _n: &OrderByClause) -> VisitorResult { + fn post_visit_order_by_clause(self, _n: &OrderByClause) -> Result { Ok(self) } /// Invoked before any children of the `LIMIT` clause are visited. - fn pre_visit_limit_clause(self, _n: &LimitClause) -> VisitorResult> { + fn pre_visit_limit_clause(self, _n: &LimitClause) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `LIMIT` clause are visited. - fn post_visit_limit_clause(self, _n: &LimitClause) -> VisitorResult { + fn post_visit_limit_clause(self, _n: &LimitClause) -> Result { Ok(self) } /// Invoked before any children of the `OFFSET` clause are visited. - fn pre_visit_offset_clause(self, _n: &OffsetClause) -> VisitorResult> { + fn pre_visit_offset_clause(self, _n: &OffsetClause) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `OFFSET` clause are visited. - fn post_visit_offset_clause(self, _n: &OffsetClause) -> VisitorResult { + fn post_visit_offset_clause(self, _n: &OffsetClause) -> Result { Ok(self) } /// Invoked before any children of the `SLIMIT` clause are visited. - fn pre_visit_slimit_clause(self, _n: &SLimitClause) -> VisitorResult> { + fn pre_visit_slimit_clause(self, _n: &SLimitClause) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `SLIMIT` clause are visited. - fn post_visit_slimit_clause(self, _n: &SLimitClause) -> VisitorResult { + fn post_visit_slimit_clause(self, _n: &SLimitClause) -> Result { Ok(self) } /// Invoked before any children of the `SOFFSET` clause are visited. - fn pre_visit_soffset_clause(self, _n: &SOffsetClause) -> VisitorResult> { + fn pre_visit_soffset_clause(self, _n: &SOffsetClause) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of the `SOFFSET` clause are visited. - fn post_visit_soffset_clause(self, _n: &SOffsetClause) -> VisitorResult { + fn post_visit_soffset_clause(self, _n: &SOffsetClause) -> Result { Ok(self) } /// Invoked before any children of a `TZ` clause are visited. - fn pre_visit_timezone_clause(self, _n: &TimeZoneClause) -> VisitorResult> { + fn pre_visit_timezone_clause( + self, + _n: &TimeZoneClause, + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of a `TZ` clause are visited. - fn post_visit_timezone_clause(self, _n: &TimeZoneClause) -> VisitorResult { + fn post_visit_timezone_clause(self, _n: &TimeZoneClause) -> Result { Ok(self) } /// Invoked before any children of an extended `ON` clause are visited. - fn pre_visit_extended_on_clause(self, _n: &ExtendedOnClause) -> VisitorResult> { + fn pre_visit_extended_on_clause( + self, + _n: &ExtendedOnClause, + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of an extended `ON` clause are visited. - fn post_visit_extended_on_clause(self, _n: &ExtendedOnClause) -> VisitorResult { + fn post_visit_extended_on_clause(self, _n: &ExtendedOnClause) -> Result { Ok(self) } /// Invoked before any children of an `ON` clause are visited. - fn pre_visit_on_clause(self, _n: &OnClause) -> VisitorResult> { + fn pre_visit_on_clause(self, _n: &OnClause) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of an `ON` clause are visited. - fn post_visit_on_clause(self, _n: &OnClause) -> VisitorResult { + fn post_visit_on_clause(self, _n: &OnClause) -> Result { Ok(self) } @@ -471,22 +506,25 @@ pub trait Visitor: Sized { fn pre_visit_with_measurement_clause( self, _n: &WithMeasurementClause, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of a `WITH MEASUREMENT` clause are visited. - fn post_visit_with_measurement_clause(self, _n: &WithMeasurementClause) -> VisitorResult { + fn post_visit_with_measurement_clause( + self, + _n: &WithMeasurementClause, + ) -> Result { Ok(self) } /// Invoked before any children of a `WITH KEY` clause are visited. - fn pre_visit_with_key_clause(self, _n: &WithKeyClause) -> VisitorResult> { + fn pre_visit_with_key_clause(self, _n: &WithKeyClause) -> Result, Self::Error> { Ok(Continue(self)) } /// Invoked after all children of a `WITH KEY` clause are visited. - fn post_visit_with_key_clause(self, _n: &WithKeyClause) -> VisitorResult { + fn post_visit_with_key_clause(self, _n: &WithKeyClause) -> Result { Ok(self) } } @@ -494,11 +532,11 @@ pub trait Visitor: Sized { /// Trait for types that can be visited by [`Visitor`] pub trait Visitable: Sized { /// accept a visitor, calling `visit` on all children of this - fn accept(&self, visitor: V) -> VisitorResult; + fn accept(&self, visitor: V) -> Result; } impl Visitable for Statement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -523,7 +561,7 @@ impl Visitable for Statement { } impl Visitable for CreateDatabaseStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_create_database_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -534,7 +572,7 @@ impl Visitable for CreateDatabaseStatement { } impl Visitable for DeleteStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_delete_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -558,7 +596,7 @@ impl Visitable for DeleteStatement { } impl Visitable for WhereClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_where_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -571,7 +609,7 @@ impl Visitable for WhereClause { } impl Visitable for DeleteFromClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_delete_from_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -584,7 +622,7 @@ impl Visitable for DeleteFromClause { } impl Visitable for MeasurementName { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_measurement_name(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -595,7 +633,7 @@ impl Visitable for MeasurementName { } impl Visitable for DropMeasurementStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_drop_measurement_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -606,7 +644,7 @@ impl Visitable for DropMeasurementStatement { } impl Visitable for ExplainStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_explain_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -619,7 +657,7 @@ impl Visitable for ExplainStatement { } impl Visitable for SelectStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_select_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -688,7 +726,7 @@ impl Visitable for SelectStatement { } impl Visitable for TimeZoneClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_timezone_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -699,7 +737,7 @@ impl Visitable for TimeZoneClause { } impl Visitable for LimitClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_limit_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -710,7 +748,7 @@ impl Visitable for LimitClause { } impl Visitable for OffsetClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_offset_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -721,7 +759,7 @@ impl Visitable for OffsetClause { } impl Visitable for SLimitClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_slimit_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -732,7 +770,7 @@ impl Visitable for SLimitClause { } impl Visitable for SOffsetClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_soffset_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -743,7 +781,7 @@ impl Visitable for SOffsetClause { } impl Visitable for FillClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_fill_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -754,7 +792,7 @@ impl Visitable for FillClause { } impl Visitable for OrderByClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_order_by_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -765,7 +803,7 @@ impl Visitable for OrderByClause { } impl Visitable for GroupByClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_group_by_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -778,7 +816,7 @@ impl Visitable for GroupByClause { } impl Visitable for ShowMeasurementsStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_show_measurements_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -819,7 +857,7 @@ impl Visitable for ShowMeasurementsStatement { } impl Visitable for ExtendedOnClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_extended_on_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -830,7 +868,7 @@ impl Visitable for ExtendedOnClause { } impl Visitable for WithMeasurementClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_with_measurement_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -846,7 +884,7 @@ impl Visitable for WithMeasurementClause { } impl Visitable for ShowRetentionPoliciesStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_show_retention_policies_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -863,7 +901,7 @@ impl Visitable for ShowRetentionPoliciesStatement { } impl Visitable for ShowFromClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_show_from_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -876,7 +914,7 @@ impl Visitable for ShowFromClause { } impl Visitable for QualifiedMeasurementName { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_qualified_measurement_name(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -889,7 +927,7 @@ impl Visitable for QualifiedMeasurementName { } impl Visitable for ShowTagKeysStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_show_tag_keys_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -930,7 +968,7 @@ impl Visitable for ShowTagKeysStatement { } impl Visitable for ShowTagValuesStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_show_tag_values_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -973,7 +1011,7 @@ impl Visitable for ShowTagValuesStatement { } impl Visitable for ShowFieldKeysStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_show_field_keys_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1008,7 +1046,7 @@ impl Visitable for ShowFieldKeysStatement { } impl Visitable for FieldList { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_select_field_list(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1021,7 +1059,7 @@ impl Visitable for FieldList { } impl Visitable for Field { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_select_field(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1034,7 +1072,7 @@ impl Visitable for Field { } impl Visitable for FromMeasurementClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_select_from_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1047,7 +1085,7 @@ impl Visitable for FromMeasurementClause { } impl Visitable for MeasurementSelection { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_select_measurement_selection(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1063,7 +1101,7 @@ impl Visitable for MeasurementSelection { } impl Visitable for Dimension { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_select_dimension(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1086,7 +1124,7 @@ impl Visitable for Dimension { } impl Visitable for WithKeyClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_with_key_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1097,7 +1135,7 @@ impl Visitable for WithKeyClause { } impl Visitable for ShowDatabasesStatement { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_show_databases_statement(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1107,7 +1145,7 @@ impl Visitable for ShowDatabasesStatement { } impl Visitable for ConditionalExpression { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_conditional_expression(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1127,7 +1165,7 @@ impl Visitable for ConditionalExpression { } impl Visitable for Expr { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_expr(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1156,7 +1194,7 @@ impl Visitable for Expr { } impl Visitable for OnClause { - fn accept(&self, visitor: V) -> VisitorResult { + fn accept(&self, visitor: V) -> Result { let visitor = match visitor.pre_visit_on_clause(self)? { Continue(visitor) => visitor, Stop(visitor) => return Ok(visitor), @@ -1169,7 +1207,7 @@ impl Visitable for OnClause { #[cfg(test)] mod test { use super::Recursion::Continue; - use super::{Recursion, Visitable, Visitor, VisitorResult}; + use super::{Recursion, Visitable, Visitor}; use crate::common::{ LimitClause, MeasurementName, OffsetClause, OrderByClause, QualifiedMeasurementName, WhereClause, @@ -1216,106 +1254,117 @@ mod test { } impl Visitor for TestVisitor { - fn pre_visit_statement(self, n: &Statement) -> VisitorResult> { + type Error = (); + + fn pre_visit_statement(self, n: &Statement) -> Result, Self::Error> { Ok(Continue(self.push_pre("statement", n))) } - fn post_visit_statement(self, n: &Statement) -> VisitorResult { + fn post_visit_statement(self, n: &Statement) -> Result { Ok(self.push_post("statement", n)) } - fn pre_visit_delete_statement(self, n: &DeleteStatement) -> VisitorResult> { + fn pre_visit_delete_statement( + self, + n: &DeleteStatement, + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("delete_statement", n))) } - fn post_visit_delete_statement(self, n: &DeleteStatement) -> VisitorResult { + fn post_visit_delete_statement(self, n: &DeleteStatement) -> Result { Ok(self.push_post("delete_statement", n)) } fn pre_visit_delete_from_clause( self, n: &DeleteFromClause, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("delete_from", n))) } - fn post_visit_delete_from_clause(self, n: &DeleteFromClause) -> VisitorResult { + fn post_visit_delete_from_clause(self, n: &DeleteFromClause) -> Result { Ok(self.push_post("delete_from", n)) } - fn pre_visit_measurement_name(self, n: &MeasurementName) -> VisitorResult> { + fn pre_visit_measurement_name( + self, + n: &MeasurementName, + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("measurement_name", n))) } - fn post_visit_measurement_name(self, n: &MeasurementName) -> VisitorResult { + fn post_visit_measurement_name(self, n: &MeasurementName) -> Result { Ok(self.push_post("measurement_name", n)) } fn pre_visit_drop_measurement_statement( self, n: &DropMeasurementStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("drop_measurement_statement", n))) } fn post_visit_drop_measurement_statement( self, n: &DropMeasurementStatement, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("drop_measurement_statement", n)) } fn pre_visit_explain_statement( self, n: &ExplainStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("explain_statement", n))) } - fn post_visit_explain_statement(self, n: &ExplainStatement) -> VisitorResult { + fn post_visit_explain_statement(self, n: &ExplainStatement) -> Result { Ok(self.push_post("explain_statement", n)) } - fn pre_visit_select_statement(self, n: &SelectStatement) -> VisitorResult> { + fn pre_visit_select_statement( + self, + n: &SelectStatement, + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("select_statement", n))) } - fn post_visit_select_statement(self, n: &SelectStatement) -> VisitorResult { + fn post_visit_select_statement(self, n: &SelectStatement) -> Result { Ok(self.push_post("select_statement", n)) } fn pre_visit_show_databases_statement( self, n: &ShowDatabasesStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("show_databases_statement", n))) } fn post_visit_show_databases_statement( self, n: &ShowDatabasesStatement, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("show_databases_statement", n)) } fn pre_visit_show_measurements_statement( self, n: &ShowMeasurementsStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("show_measurements_statement", n))) } fn post_visit_show_measurements_statement( self, n: &ShowMeasurementsStatement, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("show_measurements_statement", n)) } fn pre_visit_show_retention_policies_statement( self, n: &ShowRetentionPoliciesStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue( self.push_pre("show_retention_policies_statement", n), )) @@ -1324,255 +1373,279 @@ mod test { fn post_visit_show_retention_policies_statement( self, n: &ShowRetentionPoliciesStatement, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("show_retention_policies_statement", n)) } fn pre_visit_show_tag_keys_statement( self, n: &ShowTagKeysStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("show_tag_keys_statement", n))) } fn post_visit_show_tag_keys_statement( self, n: &ShowTagKeysStatement, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("show_tag_keys_statement", n)) } fn pre_visit_show_tag_values_statement( self, n: &ShowTagValuesStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("show_tag_values_statement", n))) } fn post_visit_show_tag_values_statement( self, n: &ShowTagValuesStatement, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("show_tag_values_statement", n)) } fn pre_visit_show_field_keys_statement( self, n: &ShowFieldKeysStatement, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("show_field_keys_statement", n))) } fn post_visit_show_field_keys_statement( self, n: &ShowFieldKeysStatement, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("show_field_keys_statement", n)) } fn pre_visit_conditional_expression( self, n: &ConditionalExpression, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("conditional_expression", n))) } fn post_visit_conditional_expression( self, n: &ConditionalExpression, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("conditional_expression", n)) } - fn pre_visit_expr(self, n: &Expr) -> VisitorResult> { + fn pre_visit_expr(self, n: &Expr) -> Result, Self::Error> { Ok(Continue(self.push_pre("expr", n))) } - fn post_visit_expr(self, n: &Expr) -> VisitorResult { + fn post_visit_expr(self, n: &Expr) -> Result { Ok(self.push_post("expr", n)) } - fn pre_visit_select_field_list(self, n: &FieldList) -> VisitorResult> { + fn pre_visit_select_field_list( + self, + n: &FieldList, + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("select_field_list", n))) } - fn post_visit_select_field_list(self, n: &FieldList) -> VisitorResult { + fn post_visit_select_field_list(self, n: &FieldList) -> Result { Ok(self.push_post("select_field_list", n)) } - fn pre_visit_select_field(self, n: &Field) -> VisitorResult> { + fn pre_visit_select_field(self, n: &Field) -> Result, Self::Error> { Ok(Continue(self.push_pre("select_field", n))) } - fn post_visit_select_field(self, n: &Field) -> VisitorResult { + fn post_visit_select_field(self, n: &Field) -> Result { Ok(self.push_post("select_field", n)) } fn pre_visit_select_from_clause( self, n: &FromMeasurementClause, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("select_from_clause", n))) } - fn post_visit_select_from_clause(self, n: &FromMeasurementClause) -> VisitorResult { + fn post_visit_select_from_clause( + self, + n: &FromMeasurementClause, + ) -> Result { Ok(self.push_post("select_from_clause", n)) } fn pre_visit_select_measurement_selection( self, n: &MeasurementSelection, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("select_measurement_selection", n))) } fn post_visit_select_measurement_selection( self, n: &MeasurementSelection, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("select_measurement_selection", n)) } - fn pre_visit_group_by_clause(self, n: &GroupByClause) -> VisitorResult> { + fn pre_visit_group_by_clause( + self, + n: &GroupByClause, + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("group_by_clause", n))) } - fn post_visit_group_by_clause(self, n: &GroupByClause) -> VisitorResult { + fn post_visit_group_by_clause(self, n: &GroupByClause) -> Result { Ok(self.push_post("group_by_clause", n)) } - fn pre_visit_select_dimension(self, n: &Dimension) -> VisitorResult> { + fn pre_visit_select_dimension(self, n: &Dimension) -> Result, Self::Error> { Ok(Continue(self.push_pre("select_dimension", n))) } - fn post_visit_select_dimension(self, n: &Dimension) -> VisitorResult { + fn post_visit_select_dimension(self, n: &Dimension) -> Result { Ok(self.push_post("select_dimension", n)) } - fn pre_visit_where_clause(self, n: &WhereClause) -> VisitorResult> { + fn pre_visit_where_clause(self, n: &WhereClause) -> Result, Self::Error> { Ok(Continue(self.push_pre("where_clause", n))) } - fn post_visit_where_clause(self, n: &WhereClause) -> VisitorResult { + fn post_visit_where_clause(self, n: &WhereClause) -> Result { Ok(self.push_post("where_clause", n)) } - fn pre_visit_show_from_clause(self, n: &ShowFromClause) -> VisitorResult> { + fn pre_visit_show_from_clause( + self, + n: &ShowFromClause, + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("show_from_clause", n))) } - fn post_visit_show_from_clause(self, n: &ShowFromClause) -> VisitorResult { + fn post_visit_show_from_clause(self, n: &ShowFromClause) -> Result { Ok(self.push_post("show_from_clause", n)) } fn pre_visit_qualified_measurement_name( self, n: &QualifiedMeasurementName, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("qualified_measurement_name", n))) } fn post_visit_qualified_measurement_name( self, n: &QualifiedMeasurementName, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("qualified_measurement_name", n)) } - fn pre_visit_fill_clause(self, n: &FillClause) -> VisitorResult> { + fn pre_visit_fill_clause(self, n: &FillClause) -> Result, Self::Error> { Ok(Continue(self.push_pre("fill_clause", n))) } - fn post_visit_fill_clause(self, n: &FillClause) -> VisitorResult { + fn post_visit_fill_clause(self, n: &FillClause) -> Result { Ok(self.push_post("fill_clause", n)) } - fn pre_visit_order_by_clause(self, n: &OrderByClause) -> VisitorResult> { + fn pre_visit_order_by_clause( + self, + n: &OrderByClause, + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("order_by_clause", n))) } - fn post_visit_order_by_clause(self, n: &OrderByClause) -> VisitorResult { + fn post_visit_order_by_clause(self, n: &OrderByClause) -> Result { Ok(self.push_post("order_by_clause", n)) } - fn pre_visit_limit_clause(self, n: &LimitClause) -> VisitorResult> { + fn pre_visit_limit_clause(self, n: &LimitClause) -> Result, Self::Error> { Ok(Continue(self.push_pre("limit_clause", n))) } - fn post_visit_limit_clause(self, n: &LimitClause) -> VisitorResult { + fn post_visit_limit_clause(self, n: &LimitClause) -> Result { Ok(self.push_post("limit_clause", n)) } - fn pre_visit_offset_clause(self, n: &OffsetClause) -> VisitorResult> { + fn pre_visit_offset_clause(self, n: &OffsetClause) -> Result, Self::Error> { Ok(Continue(self.push_pre("offset_clause", n))) } - fn post_visit_offset_clause(self, n: &OffsetClause) -> VisitorResult { + fn post_visit_offset_clause(self, n: &OffsetClause) -> Result { Ok(self.push_post("offset_clause", n)) } - fn pre_visit_slimit_clause(self, n: &SLimitClause) -> VisitorResult> { + fn pre_visit_slimit_clause(self, n: &SLimitClause) -> Result, Self::Error> { Ok(Continue(self.push_pre("slimit_clause", n))) } - fn post_visit_slimit_clause(self, n: &SLimitClause) -> VisitorResult { + fn post_visit_slimit_clause(self, n: &SLimitClause) -> Result { Ok(self.push_post("slimit_clause", n)) } - fn pre_visit_soffset_clause(self, n: &SOffsetClause) -> VisitorResult> { + fn pre_visit_soffset_clause( + self, + n: &SOffsetClause, + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("soffset_clause", n))) } - fn post_visit_soffset_clause(self, n: &SOffsetClause) -> VisitorResult { + fn post_visit_soffset_clause(self, n: &SOffsetClause) -> Result { Ok(self.push_post("soffset_clause", n)) } - fn pre_visit_timezone_clause(self, n: &TimeZoneClause) -> VisitorResult> { + fn pre_visit_timezone_clause( + self, + n: &TimeZoneClause, + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("timezone_clause", n))) } - fn post_visit_timezone_clause(self, n: &TimeZoneClause) -> VisitorResult { + fn post_visit_timezone_clause(self, n: &TimeZoneClause) -> Result { Ok(self.push_post("timezone_clause", n)) } fn pre_visit_extended_on_clause( self, n: &ExtendedOnClause, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("extended_on_clause", n))) } - fn post_visit_extended_on_clause(self, n: &ExtendedOnClause) -> VisitorResult { + fn post_visit_extended_on_clause(self, n: &ExtendedOnClause) -> Result { Ok(self.push_post("extended_on_clause", n)) } - fn pre_visit_on_clause(self, n: &OnClause) -> VisitorResult> { + fn pre_visit_on_clause(self, n: &OnClause) -> Result, Self::Error> { Ok(Continue(self.push_pre("on_clause", n))) } - fn post_visit_on_clause(self, n: &OnClause) -> VisitorResult { + fn post_visit_on_clause(self, n: &OnClause) -> Result { Ok(self.push_pre("on_clause", n)) } fn pre_visit_with_measurement_clause( self, n: &WithMeasurementClause, - ) -> VisitorResult> { + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("with_measurement_clause", n))) } fn post_visit_with_measurement_clause( self, n: &WithMeasurementClause, - ) -> VisitorResult { + ) -> Result { Ok(self.push_post("with_measurement_clause", n)) } - fn pre_visit_with_key_clause(self, n: &WithKeyClause) -> VisitorResult> { + fn pre_visit_with_key_clause( + self, + n: &WithKeyClause, + ) -> Result, Self::Error> { Ok(Continue(self.push_pre("with_key_clause", n))) } - fn post_visit_with_key_clause(self, n: &WithKeyClause) -> VisitorResult { + fn post_visit_with_key_clause(self, n: &WithKeyClause) -> Result { Ok(self.push_post("with_key_clause", n)) } } diff --git a/influxdb_influxql_parser/src/visit_mut.rs b/influxdb_influxql_parser/src/visit_mut.rs index 728a182c25..eeaa6fe8d5 100644 --- a/influxdb_influxql_parser/src/visit_mut.rs +++ b/influxdb_influxql_parser/src/visit_mut.rs @@ -3,14 +3,16 @@ //! # Example //! //! ``` -//! use influxdb_influxql_parser::visit_mut::{VisitableMut, VisitorMut, VisitorResult}; +//! use influxdb_influxql_parser::visit_mut::{VisitableMut, VisitorMut}; //! use influxdb_influxql_parser::parse_statements; //! use influxdb_influxql_parser::common::WhereClause; //! //! struct MyVisitor; //! //! impl VisitorMut for MyVisitor { -//! fn post_visit_where_clause(&mut self, n: &mut WhereClause) -> VisitorResult<()> { +//! type Error = (); +//! +//! fn post_visit_where_clause(&mut self, n: &mut WhereClause) -> Result<(), Self::Error> { //! println!("{}", n); //! Ok(()) //! } @@ -47,9 +49,6 @@ use crate::show_tag_values::{ShowTagValuesStatement, WithKeyClause}; use crate::simple_from_clause::{DeleteFromClause, ShowFromClause}; use crate::statement::Statement; -/// The result type for a [`VisitorMut`]. -pub type VisitorResult = Result; - /// Controls how the visitor recursion should proceed. #[derive(Clone, Copy)] pub enum Recursion { @@ -64,13 +63,16 @@ pub enum Recursion { /// any [`VisitableMut::accept`], `pre_visit` functions are invoked repeatedly /// until a leaf node is reached or a `pre_visit` function returns [`Recursion::Stop`]. pub trait VisitorMut: Sized { + /// The type returned in the event of an error traversing the tree. + type Error; + /// Invoked before any children of the InfluxQL statement are visited. - fn pre_visit_statement(&mut self, _n: &mut Statement) -> VisitorResult { + fn pre_visit_statement(&mut self, _n: &mut Statement) -> Result { Ok(Continue) } /// Invoked after all children of the InfluxQL statement are visited. - fn post_visit_statement(&mut self, _n: &mut Statement) -> VisitorResult<()> { + fn post_visit_statement(&mut self, _n: &mut Statement) -> Result<(), Self::Error> { Ok(()) } @@ -78,7 +80,7 @@ pub trait VisitorMut: Sized { fn pre_visit_create_database_statement( &mut self, _n: &mut CreateDatabaseStatement, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -87,17 +89,20 @@ pub trait VisitorMut: Sized { fn post_visit_create_database_statement( &mut self, _n: &mut CreateDatabaseStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `DELETE` statement are visited. - fn pre_visit_delete_statement(&mut self, _n: &mut DeleteStatement) -> VisitorResult { + fn pre_visit_delete_statement( + &mut self, + _n: &mut DeleteStatement, + ) -> Result { Ok(Continue) } /// Invoked after all children of the `DELETE` statement are visited. - fn post_visit_delete_statement(&mut self, _n: &mut DeleteStatement) -> VisitorResult<()> { + fn post_visit_delete_statement(&mut self, _n: &mut DeleteStatement) -> Result<(), Self::Error> { Ok(()) } @@ -105,22 +110,28 @@ pub trait VisitorMut: Sized { fn pre_visit_delete_from_clause( &mut self, _n: &mut DeleteFromClause, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } /// Invoked after all children of the `FROM` clause of a `DELETE` statement are visited. - fn post_visit_delete_from_clause(&mut self, _n: &mut DeleteFromClause) -> VisitorResult<()> { + fn post_visit_delete_from_clause( + &mut self, + _n: &mut DeleteFromClause, + ) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the measurement name are visited. - fn pre_visit_measurement_name(&mut self, _n: &mut MeasurementName) -> VisitorResult { + fn pre_visit_measurement_name( + &mut self, + _n: &mut MeasurementName, + ) -> Result { Ok(Continue) } /// Invoked after all children of the measurement name are visited. - fn post_visit_measurement_name(&mut self, _n: &mut MeasurementName) -> VisitorResult<()> { + fn post_visit_measurement_name(&mut self, _n: &mut MeasurementName) -> Result<(), Self::Error> { Ok(()) } @@ -128,7 +139,7 @@ pub trait VisitorMut: Sized { fn pre_visit_drop_measurement_statement( &mut self, _n: &mut DropMeasurementStatement, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -136,7 +147,7 @@ pub trait VisitorMut: Sized { fn post_visit_drop_measurement_statement( &mut self, _n: &mut DropMeasurementStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } @@ -144,22 +155,28 @@ pub trait VisitorMut: Sized { fn pre_visit_explain_statement( &mut self, _n: &mut ExplainStatement, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } /// Invoked after all children of the `EXPLAIN` statement are visited. - fn post_visit_explain_statement(&mut self, _n: &mut ExplainStatement) -> VisitorResult<()> { + fn post_visit_explain_statement( + &mut self, + _n: &mut ExplainStatement, + ) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `SELECT` statement are visited. - fn pre_visit_select_statement(&mut self, _n: &mut SelectStatement) -> VisitorResult { + fn pre_visit_select_statement( + &mut self, + _n: &mut SelectStatement, + ) -> Result { Ok(Continue) } /// Invoked after all children of the `SELECT` statement are visited. - fn post_visit_select_statement(&mut self, _n: &mut SelectStatement) -> VisitorResult<()> { + fn post_visit_select_statement(&mut self, _n: &mut SelectStatement) -> Result<(), Self::Error> { Ok(()) } @@ -167,7 +184,7 @@ pub trait VisitorMut: Sized { fn pre_visit_show_databases_statement( &mut self, _n: &mut ShowDatabasesStatement, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -175,7 +192,7 @@ pub trait VisitorMut: Sized { fn post_visit_show_databases_statement( &mut self, _n: &mut ShowDatabasesStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } @@ -183,7 +200,7 @@ pub trait VisitorMut: Sized { fn pre_visit_show_measurements_statement( &mut self, _n: &mut ShowMeasurementsStatement, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -191,7 +208,7 @@ pub trait VisitorMut: Sized { fn post_visit_show_measurements_statement( &mut self, _n: &mut ShowMeasurementsStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } @@ -199,7 +216,7 @@ pub trait VisitorMut: Sized { fn pre_visit_show_retention_policies_statement( &mut self, _n: &mut ShowRetentionPoliciesStatement, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -207,7 +224,7 @@ pub trait VisitorMut: Sized { fn post_visit_show_retention_policies_statement( &mut self, _n: &mut ShowRetentionPoliciesStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } @@ -215,7 +232,7 @@ pub trait VisitorMut: Sized { fn pre_visit_show_tag_keys_statement( &mut self, _n: &mut ShowTagKeysStatement, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -223,7 +240,7 @@ pub trait VisitorMut: Sized { fn post_visit_show_tag_keys_statement( &mut self, _n: &mut ShowTagKeysStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } @@ -231,7 +248,7 @@ pub trait VisitorMut: Sized { fn pre_visit_show_tag_values_statement( &mut self, _n: &mut ShowTagValuesStatement, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -239,7 +256,7 @@ pub trait VisitorMut: Sized { fn post_visit_show_tag_values_statement( &mut self, _n: &mut ShowTagValuesStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } @@ -247,7 +264,7 @@ pub trait VisitorMut: Sized { fn pre_visit_show_field_keys_statement( &mut self, _n: &mut ShowFieldKeysStatement, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -255,7 +272,7 @@ pub trait VisitorMut: Sized { fn post_visit_show_field_keys_statement( &mut self, _n: &mut ShowFieldKeysStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } @@ -263,7 +280,7 @@ pub trait VisitorMut: Sized { fn pre_visit_conditional_expression( &mut self, _n: &mut ConditionalExpression, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -271,37 +288,40 @@ pub trait VisitorMut: Sized { fn post_visit_conditional_expression( &mut self, _n: &mut ConditionalExpression, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the arithmetic expression are visited. - fn pre_visit_expr(&mut self, _n: &mut Expr) -> VisitorResult { + fn pre_visit_expr(&mut self, _n: &mut Expr) -> Result { Ok(Continue) } /// Invoked after all children of the arithmetic expression are visited. - fn post_visit_expr(&mut self, _n: &mut Expr) -> VisitorResult<()> { + fn post_visit_expr(&mut self, _n: &mut Expr) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any fields of the `SELECT` projection are visited. - fn pre_visit_select_field_list(&mut self, _n: &mut FieldList) -> VisitorResult { + fn pre_visit_select_field_list( + &mut self, + _n: &mut FieldList, + ) -> Result { Ok(Continue) } /// Invoked after all fields of the `SELECT` projection are visited. - fn post_visit_select_field_list(&mut self, _n: &mut FieldList) -> VisitorResult<()> { + fn post_visit_select_field_list(&mut self, _n: &mut FieldList) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the field of a `SELECT` statement are visited. - fn pre_visit_select_field(&mut self, _n: &mut Field) -> VisitorResult { + fn pre_visit_select_field(&mut self, _n: &mut Field) -> Result { Ok(Continue) } /// Invoked after all children of the field of a `SELECT` statement are visited. - fn post_visit_select_field(&mut self, _n: &mut Field) -> VisitorResult<()> { + fn post_visit_select_field(&mut self, _n: &mut Field) -> Result<(), Self::Error> { Ok(()) } @@ -309,7 +329,7 @@ pub trait VisitorMut: Sized { fn pre_visit_select_from_clause( &mut self, _n: &mut FromMeasurementClause, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -317,7 +337,7 @@ pub trait VisitorMut: Sized { fn post_visit_select_from_clause( &mut self, _n: &mut FromMeasurementClause, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } @@ -325,7 +345,7 @@ pub trait VisitorMut: Sized { fn pre_visit_select_measurement_selection( &mut self, _n: &mut MeasurementSelection, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -333,47 +353,53 @@ pub trait VisitorMut: Sized { fn post_visit_select_measurement_selection( &mut self, _n: &mut MeasurementSelection, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `GROUP BY` clause are visited. - fn pre_visit_group_by_clause(&mut self, _n: &mut GroupByClause) -> VisitorResult { + fn pre_visit_group_by_clause( + &mut self, + _n: &mut GroupByClause, + ) -> Result { Ok(Continue) } /// Invoked after all children of the `GROUP BY` clause are visited. - fn post_visit_group_by_clause(&mut self, _n: &mut GroupByClause) -> VisitorResult<()> { + fn post_visit_group_by_clause(&mut self, _n: &mut GroupByClause) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `GROUP BY` dimension expression are visited. - fn pre_visit_select_dimension(&mut self, _n: &mut Dimension) -> VisitorResult { + fn pre_visit_select_dimension(&mut self, _n: &mut Dimension) -> Result { Ok(Continue) } /// Invoked after all children of the `GROUP BY` dimension expression are visited. - fn post_visit_select_dimension(&mut self, _n: &mut Dimension) -> VisitorResult<()> { + fn post_visit_select_dimension(&mut self, _n: &mut Dimension) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `WHERE` clause are visited. - fn pre_visit_where_clause(&mut self, _n: &mut WhereClause) -> VisitorResult { + fn pre_visit_where_clause(&mut self, _n: &mut WhereClause) -> Result { Ok(Continue) } /// Invoked after all children of the `WHERE` clause are visited. - fn post_visit_where_clause(&mut self, _n: &mut WhereClause) -> VisitorResult<()> { + fn post_visit_where_clause(&mut self, _n: &mut WhereClause) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `FROM` clause for any `SHOW` statement are visited. - fn pre_visit_show_from_clause(&mut self, _n: &mut ShowFromClause) -> VisitorResult { + fn pre_visit_show_from_clause( + &mut self, + _n: &mut ShowFromClause, + ) -> Result { Ok(Continue) } /// Invoked after all children of the `FROM` clause for any `SHOW` statement are visited. - fn post_visit_show_from_clause(&mut self, _n: &mut ShowFromClause) -> VisitorResult<()> { + fn post_visit_show_from_clause(&mut self, _n: &mut ShowFromClause) -> Result<(), Self::Error> { Ok(()) } @@ -381,7 +407,7 @@ pub trait VisitorMut: Sized { fn pre_visit_qualified_measurement_name( &mut self, _n: &mut QualifiedMeasurementName, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -389,77 +415,86 @@ pub trait VisitorMut: Sized { fn post_visit_qualified_measurement_name( &mut self, _n: &mut QualifiedMeasurementName, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `FILL` clause are visited. - fn pre_visit_fill_clause(&mut self, _n: &mut FillClause) -> VisitorResult { + fn pre_visit_fill_clause(&mut self, _n: &mut FillClause) -> Result { Ok(Continue) } /// Invoked after all children of the `FILL` clause are visited. - fn post_visit_fill_clause(&mut self, _n: &mut FillClause) -> VisitorResult<()> { + fn post_visit_fill_clause(&mut self, _n: &mut FillClause) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `ORDER BY` clause are visited. - fn pre_visit_order_by_clause(&mut self, _n: &mut OrderByClause) -> VisitorResult { + fn pre_visit_order_by_clause( + &mut self, + _n: &mut OrderByClause, + ) -> Result { Ok(Continue) } /// Invoked after all children of the `ORDER BY` clause are visited. - fn post_visit_order_by_clause(&mut self, _n: &mut OrderByClause) -> VisitorResult<()> { + fn post_visit_order_by_clause(&mut self, _n: &mut OrderByClause) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `LIMIT` clause are visited. - fn pre_visit_limit_clause(&mut self, _n: &mut LimitClause) -> VisitorResult { + fn pre_visit_limit_clause(&mut self, _n: &mut LimitClause) -> Result { Ok(Continue) } /// Invoked after all children of the `LIMIT` clause are visited. - fn post_visit_limit_clause(&mut self, _n: &mut LimitClause) -> VisitorResult<()> { + fn post_visit_limit_clause(&mut self, _n: &mut LimitClause) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `OFFSET` clause are visited. - fn pre_visit_offset_clause(&mut self, _n: &mut OffsetClause) -> VisitorResult { + fn pre_visit_offset_clause(&mut self, _n: &mut OffsetClause) -> Result { Ok(Continue) } /// Invoked after all children of the `OFFSET` clause are visited. - fn post_visit_offset_clause(&mut self, _n: &mut OffsetClause) -> VisitorResult<()> { + fn post_visit_offset_clause(&mut self, _n: &mut OffsetClause) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `SLIMIT` clause are visited. - fn pre_visit_slimit_clause(&mut self, _n: &mut SLimitClause) -> VisitorResult { + fn pre_visit_slimit_clause(&mut self, _n: &mut SLimitClause) -> Result { Ok(Continue) } /// Invoked after all children of the `SLIMIT` clause are visited. - fn post_visit_slimit_clause(&mut self, _n: &mut SLimitClause) -> VisitorResult<()> { + fn post_visit_slimit_clause(&mut self, _n: &mut SLimitClause) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of the `SOFFSET` clause are visited. - fn pre_visit_soffset_clause(&mut self, _n: &mut SOffsetClause) -> VisitorResult { + fn pre_visit_soffset_clause( + &mut self, + _n: &mut SOffsetClause, + ) -> Result { Ok(Continue) } /// Invoked after all children of the `SOFFSET` clause are visited. - fn post_visit_soffset_clause(&mut self, _n: &mut SOffsetClause) -> VisitorResult<()> { + fn post_visit_soffset_clause(&mut self, _n: &mut SOffsetClause) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of a `TZ` clause are visited. - fn pre_visit_timezone_clause(&mut self, _n: &mut TimeZoneClause) -> VisitorResult { + fn pre_visit_timezone_clause( + &mut self, + _n: &mut TimeZoneClause, + ) -> Result { Ok(Continue) } /// Invoked after all children of a `TZ` clause are visited. - fn post_visit_timezone_clause(&mut self, _n: &mut TimeZoneClause) -> VisitorResult<()> { + fn post_visit_timezone_clause(&mut self, _n: &mut TimeZoneClause) -> Result<(), Self::Error> { Ok(()) } @@ -467,22 +502,25 @@ pub trait VisitorMut: Sized { fn pre_visit_extended_on_clause( &mut self, _n: &mut ExtendedOnClause, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } /// Invoked after all children of an extended `ON` clause are visited. - fn post_visit_extended_on_clause(&mut self, _n: &mut ExtendedOnClause) -> VisitorResult<()> { + fn post_visit_extended_on_clause( + &mut self, + _n: &mut ExtendedOnClause, + ) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of an `ON` clause are visited. - fn pre_visit_on_clause(&mut self, _n: &mut OnClause) -> VisitorResult { + fn pre_visit_on_clause(&mut self, _n: &mut OnClause) -> Result { Ok(Continue) } /// Invoked after all children of an `ON` clause are visited. - fn post_visit_on_clause(&mut self, _n: &mut OnClause) -> VisitorResult<()> { + fn post_visit_on_clause(&mut self, _n: &mut OnClause) -> Result<(), Self::Error> { Ok(()) } @@ -490,7 +528,7 @@ pub trait VisitorMut: Sized { fn pre_visit_with_measurement_clause( &mut self, _n: &mut WithMeasurementClause, - ) -> VisitorResult { + ) -> Result { Ok(Continue) } @@ -498,17 +536,20 @@ pub trait VisitorMut: Sized { fn post_visit_with_measurement_clause( &mut self, _n: &mut WithMeasurementClause, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { Ok(()) } /// Invoked before any children of a `WITH KEY` clause are visited. - fn pre_visit_with_key_clause(&mut self, _n: &mut WithKeyClause) -> VisitorResult { + fn pre_visit_with_key_clause( + &mut self, + _n: &mut WithKeyClause, + ) -> Result { Ok(Continue) } /// Invoked after all children of a `WITH KEY` clause are visited. - fn post_visit_with_key_clause(&mut self, _n: &mut WithKeyClause) -> VisitorResult<()> { + fn post_visit_with_key_clause(&mut self, _n: &mut WithKeyClause) -> Result<(), Self::Error> { Ok(()) } } @@ -516,11 +557,11 @@ pub trait VisitorMut: Sized { /// Trait for types that can be visited by [`VisitorMut`] pub trait VisitableMut: Sized { /// accept a visitor, calling `visit` on all children of this - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()>; + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error>; } impl VisitableMut for Statement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_statement(self)? { return Ok(()); }; @@ -544,7 +585,7 @@ impl VisitableMut for Statement { } impl VisitableMut for CreateDatabaseStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_create_database_statement(self)? { return Ok(()); }; @@ -554,7 +595,7 @@ impl VisitableMut for CreateDatabaseStatement { } impl VisitableMut for DeleteStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_delete_statement(self)? { return Ok(()); }; @@ -575,7 +616,7 @@ impl VisitableMut for DeleteStatement { } impl VisitableMut for WhereClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_where_clause(self)? { return Ok(()); }; @@ -587,7 +628,7 @@ impl VisitableMut for WhereClause { } impl VisitableMut for DeleteFromClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_delete_from_clause(self)? { return Ok(()); }; @@ -601,7 +642,7 @@ impl VisitableMut for DeleteFromClause { } impl VisitableMut for MeasurementName { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_measurement_name(self)? { return Ok(()); }; @@ -611,7 +652,7 @@ impl VisitableMut for MeasurementName { } impl VisitableMut for DropMeasurementStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_drop_measurement_statement(self)? { return Ok(()); }; @@ -621,7 +662,7 @@ impl VisitableMut for DropMeasurementStatement { } impl VisitableMut for ExplainStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_explain_statement(self)? { return Ok(()); }; @@ -633,7 +674,7 @@ impl VisitableMut for ExplainStatement { } impl VisitableMut for SelectStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_select_statement(self)? { return Ok(()); }; @@ -683,7 +724,7 @@ impl VisitableMut for SelectStatement { } impl VisitableMut for TimeZoneClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_timezone_clause(self)? { return Ok(()); }; @@ -693,7 +734,7 @@ impl VisitableMut for TimeZoneClause { } impl VisitableMut for LimitClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_limit_clause(self)? { return Ok(()); }; @@ -703,7 +744,7 @@ impl VisitableMut for LimitClause { } impl VisitableMut for OffsetClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_offset_clause(self)? { return Ok(()); }; @@ -713,7 +754,7 @@ impl VisitableMut for OffsetClause { } impl VisitableMut for SLimitClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_slimit_clause(self)? { return Ok(()); }; @@ -723,7 +764,7 @@ impl VisitableMut for SLimitClause { } impl VisitableMut for SOffsetClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_soffset_clause(self)? { return Ok(()); }; @@ -733,7 +774,7 @@ impl VisitableMut for SOffsetClause { } impl VisitableMut for FillClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_fill_clause(self)? { return Ok(()); }; @@ -743,7 +784,7 @@ impl VisitableMut for FillClause { } impl VisitableMut for OrderByClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_order_by_clause(self)? { return Ok(()); }; @@ -753,7 +794,7 @@ impl VisitableMut for OrderByClause { } impl VisitableMut for GroupByClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_group_by_clause(self)? { return Ok(()); }; @@ -767,7 +808,7 @@ impl VisitableMut for GroupByClause { } impl VisitableMut for ShowMeasurementsStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_show_measurements_statement(self)? { return Ok(()); }; @@ -797,7 +838,7 @@ impl VisitableMut for ShowMeasurementsStatement { } impl VisitableMut for ExtendedOnClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_extended_on_clause(self)? { return Ok(()); }; @@ -807,7 +848,7 @@ impl VisitableMut for ExtendedOnClause { } impl VisitableMut for WithMeasurementClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_with_measurement_clause(self)? { return Ok(()); }; @@ -822,7 +863,7 @@ impl VisitableMut for WithMeasurementClause { } impl VisitableMut for ShowRetentionPoliciesStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_show_retention_policies_statement(self)? { return Ok(()); }; @@ -836,7 +877,7 @@ impl VisitableMut for ShowRetentionPoliciesStatement { } impl VisitableMut for ShowFromClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_show_from_clause(self)? { return Ok(()); }; @@ -850,7 +891,7 @@ impl VisitableMut for ShowFromClause { } impl VisitableMut for QualifiedMeasurementName { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_qualified_measurement_name(self)? { return Ok(()); }; @@ -862,7 +903,7 @@ impl VisitableMut for QualifiedMeasurementName { } impl VisitableMut for ShowTagKeysStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_show_tag_keys_statement(self)? { return Ok(()); }; @@ -892,7 +933,7 @@ impl VisitableMut for ShowTagKeysStatement { } impl VisitableMut for ShowTagValuesStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_show_tag_values_statement(self)? { return Ok(()); }; @@ -924,7 +965,7 @@ impl VisitableMut for ShowTagValuesStatement { } impl VisitableMut for ShowFieldKeysStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_show_field_keys_statement(self)? { return Ok(()); }; @@ -950,7 +991,7 @@ impl VisitableMut for ShowFieldKeysStatement { } impl VisitableMut for FieldList { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_select_field_list(self)? { return Ok(()); }; @@ -964,7 +1005,7 @@ impl VisitableMut for FieldList { } impl VisitableMut for Field { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_select_field(self)? { return Ok(()); }; @@ -976,7 +1017,7 @@ impl VisitableMut for Field { } impl VisitableMut for FromMeasurementClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_select_from_clause(self)? { return Ok(()); }; @@ -990,7 +1031,7 @@ impl VisitableMut for FromMeasurementClause { } impl VisitableMut for MeasurementSelection { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_select_measurement_selection(self)? { return Ok(()); }; @@ -1005,7 +1046,7 @@ impl VisitableMut for MeasurementSelection { } impl VisitableMut for Dimension { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_select_dimension(self)? { return Ok(()); }; @@ -1025,7 +1066,7 @@ impl VisitableMut for Dimension { } impl VisitableMut for WithKeyClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_with_key_clause(self)? { return Ok(()); }; @@ -1035,7 +1076,7 @@ impl VisitableMut for WithKeyClause { } impl VisitableMut for ShowDatabasesStatement { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_show_databases_statement(self)? { return Ok(()); }; @@ -1044,7 +1085,7 @@ impl VisitableMut for ShowDatabasesStatement { } impl VisitableMut for ConditionalExpression { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_conditional_expression(self)? { return Ok(()); }; @@ -1063,7 +1104,7 @@ impl VisitableMut for ConditionalExpression { } impl VisitableMut for Expr { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_expr(self)? { return Ok(()); }; @@ -1091,7 +1132,7 @@ impl VisitableMut for Expr { } impl VisitableMut for OnClause { - fn accept(&mut self, visitor: &mut V) -> VisitorResult<()> { + fn accept(&mut self, visitor: &mut V) -> Result<(), V::Error> { if let Stop = visitor.pre_visit_on_clause(self)? { return Ok(()); }; @@ -1103,7 +1144,7 @@ impl VisitableMut for OnClause { #[cfg(test)] mod test { use super::Recursion::Continue; - use super::{Recursion, VisitableMut, VisitorMut, VisitorResult}; + use super::{Recursion, VisitableMut, VisitorMut}; use crate::common::{ LimitClause, MeasurementName, OffsetClause, OrderByClause, QualifiedMeasurementName, WhereClause, @@ -1147,12 +1188,14 @@ mod test { } impl VisitorMut for TestVisitor { - fn pre_visit_statement(&mut self, n: &mut Statement) -> VisitorResult { + type Error = (); + + fn pre_visit_statement(&mut self, n: &mut Statement) -> Result { self.push_pre("statement", n); Ok(Continue) } - fn post_visit_statement(&mut self, n: &mut Statement) -> VisitorResult<()> { + fn post_visit_statement(&mut self, n: &mut Statement) -> Result<(), Self::Error> { self.push_post("statement", n); Ok(()) } @@ -1160,12 +1203,15 @@ mod test { fn pre_visit_delete_statement( &mut self, n: &mut DeleteStatement, - ) -> VisitorResult { + ) -> Result { self.push_pre("delete_statement", n); Ok(Continue) } - fn post_visit_delete_statement(&mut self, n: &mut DeleteStatement) -> VisitorResult<()> { + fn post_visit_delete_statement( + &mut self, + n: &mut DeleteStatement, + ) -> Result<(), Self::Error> { self.push_post("delete_statement", n); Ok(()) } @@ -1173,12 +1219,15 @@ mod test { fn pre_visit_delete_from_clause( &mut self, n: &mut DeleteFromClause, - ) -> VisitorResult { + ) -> Result { self.push_pre("delete_from", n); Ok(Continue) } - fn post_visit_delete_from_clause(&mut self, n: &mut DeleteFromClause) -> VisitorResult<()> { + fn post_visit_delete_from_clause( + &mut self, + n: &mut DeleteFromClause, + ) -> Result<(), Self::Error> { self.push_post("delete_from", n); Ok(()) } @@ -1186,12 +1235,15 @@ mod test { fn pre_visit_measurement_name( &mut self, n: &mut MeasurementName, - ) -> VisitorResult { + ) -> Result { self.push_pre("measurement_name", n); Ok(Continue) } - fn post_visit_measurement_name(&mut self, n: &mut MeasurementName) -> VisitorResult<()> { + fn post_visit_measurement_name( + &mut self, + n: &mut MeasurementName, + ) -> Result<(), Self::Error> { self.push_post("measurement_name", n); Ok(()) } @@ -1199,7 +1251,7 @@ mod test { fn pre_visit_drop_measurement_statement( &mut self, n: &mut DropMeasurementStatement, - ) -> VisitorResult { + ) -> Result { self.push_pre("drop_measurement_statement", n); Ok(Continue) } @@ -1207,7 +1259,7 @@ mod test { fn post_visit_drop_measurement_statement( &mut self, n: &mut DropMeasurementStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("drop_measurement_statement", n); Ok(()) } @@ -1215,12 +1267,15 @@ mod test { fn pre_visit_explain_statement( &mut self, n: &mut ExplainStatement, - ) -> VisitorResult { + ) -> Result { self.push_pre("explain_statement", n); Ok(Continue) } - fn post_visit_explain_statement(&mut self, n: &mut ExplainStatement) -> VisitorResult<()> { + fn post_visit_explain_statement( + &mut self, + n: &mut ExplainStatement, + ) -> Result<(), Self::Error> { self.push_post("explain_statement", n); Ok(()) } @@ -1228,12 +1283,15 @@ mod test { fn pre_visit_select_statement( &mut self, n: &mut SelectStatement, - ) -> VisitorResult { + ) -> Result { self.push_pre("select_statement", n); Ok(Continue) } - fn post_visit_select_statement(&mut self, n: &mut SelectStatement) -> VisitorResult<()> { + fn post_visit_select_statement( + &mut self, + n: &mut SelectStatement, + ) -> Result<(), Self::Error> { self.push_post("select_statement", n); Ok(()) } @@ -1241,7 +1299,7 @@ mod test { fn pre_visit_show_databases_statement( &mut self, n: &mut ShowDatabasesStatement, - ) -> VisitorResult { + ) -> Result { self.push_pre("show_databases_statement", n); Ok(Continue) } @@ -1249,7 +1307,7 @@ mod test { fn post_visit_show_databases_statement( &mut self, n: &mut ShowDatabasesStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("show_databases_statement", n); Ok(()) } @@ -1257,7 +1315,7 @@ mod test { fn pre_visit_show_measurements_statement( &mut self, n: &mut ShowMeasurementsStatement, - ) -> VisitorResult { + ) -> Result { self.push_pre("show_measurements_statement", n); Ok(Continue) } @@ -1265,7 +1323,7 @@ mod test { fn post_visit_show_measurements_statement( &mut self, n: &mut ShowMeasurementsStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("show_measurements_statement", n); Ok(()) } @@ -1273,7 +1331,7 @@ mod test { fn pre_visit_show_retention_policies_statement( &mut self, n: &mut ShowRetentionPoliciesStatement, - ) -> VisitorResult { + ) -> Result { self.push_pre("show_retention_policies_statement", n); Ok(Continue) } @@ -1281,7 +1339,7 @@ mod test { fn post_visit_show_retention_policies_statement( &mut self, n: &mut ShowRetentionPoliciesStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("show_retention_policies_statement", n); Ok(()) } @@ -1289,7 +1347,7 @@ mod test { fn pre_visit_show_tag_keys_statement( &mut self, n: &mut ShowTagKeysStatement, - ) -> VisitorResult { + ) -> Result { self.push_pre("show_tag_keys_statement", n); Ok(Continue) } @@ -1297,7 +1355,7 @@ mod test { fn post_visit_show_tag_keys_statement( &mut self, n: &mut ShowTagKeysStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("show_tag_keys_statement", n); Ok(()) } @@ -1305,7 +1363,7 @@ mod test { fn pre_visit_show_tag_values_statement( &mut self, n: &mut ShowTagValuesStatement, - ) -> VisitorResult { + ) -> Result { self.push_pre("show_tag_values_statement", n); Ok(Continue) } @@ -1313,7 +1371,7 @@ mod test { fn post_visit_show_tag_values_statement( &mut self, n: &mut ShowTagValuesStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("show_tag_values_statement", n); Ok(()) } @@ -1321,7 +1379,7 @@ mod test { fn pre_visit_show_field_keys_statement( &mut self, n: &mut ShowFieldKeysStatement, - ) -> VisitorResult { + ) -> Result { self.push_pre("show_field_keys_statement", n); Ok(Continue) } @@ -1329,7 +1387,7 @@ mod test { fn post_visit_show_field_keys_statement( &mut self, n: &mut ShowFieldKeysStatement, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("show_field_keys_statement", n); Ok(()) } @@ -1337,7 +1395,7 @@ mod test { fn pre_visit_conditional_expression( &mut self, n: &mut ConditionalExpression, - ) -> VisitorResult { + ) -> Result { self.push_pre("conditional_expression", n); Ok(Continue) } @@ -1345,37 +1403,40 @@ mod test { fn post_visit_conditional_expression( &mut self, n: &mut ConditionalExpression, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("conditional_expression", n); Ok(()) } - fn pre_visit_expr(&mut self, n: &mut Expr) -> VisitorResult { + fn pre_visit_expr(&mut self, n: &mut Expr) -> Result { self.push_pre("expr", n); Ok(Continue) } - fn post_visit_expr(&mut self, n: &mut Expr) -> VisitorResult<()> { + fn post_visit_expr(&mut self, n: &mut Expr) -> Result<(), Self::Error> { self.push_post("expr", n); Ok(()) } - fn pre_visit_select_field_list(&mut self, n: &mut FieldList) -> VisitorResult { + fn pre_visit_select_field_list( + &mut self, + n: &mut FieldList, + ) -> Result { self.push_pre("select_field_list", n); Ok(Continue) } - fn post_visit_select_field_list(&mut self, n: &mut FieldList) -> VisitorResult<()> { + fn post_visit_select_field_list(&mut self, n: &mut FieldList) -> Result<(), Self::Error> { self.push_post("select_field_list", n); Ok(()) } - fn pre_visit_select_field(&mut self, n: &mut Field) -> VisitorResult { + fn pre_visit_select_field(&mut self, n: &mut Field) -> Result { self.push_pre("select_field", n); Ok(Continue) } - fn post_visit_select_field(&mut self, n: &mut Field) -> VisitorResult<()> { + fn post_visit_select_field(&mut self, n: &mut Field) -> Result<(), Self::Error> { self.push_post("select_field", n); Ok(()) } @@ -1383,7 +1444,7 @@ mod test { fn pre_visit_select_from_clause( &mut self, n: &mut FromMeasurementClause, - ) -> VisitorResult { + ) -> Result { self.push_pre("select_from_clause", n); Ok(Continue) } @@ -1391,7 +1452,7 @@ mod test { fn post_visit_select_from_clause( &mut self, n: &mut FromMeasurementClause, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("select_from_clause", n); Ok(()) } @@ -1399,7 +1460,7 @@ mod test { fn pre_visit_select_measurement_selection( &mut self, n: &mut MeasurementSelection, - ) -> VisitorResult { + ) -> Result { self.push_pre("select_measurement_selection", n); Ok(Continue) } @@ -1407,37 +1468,46 @@ mod test { fn post_visit_select_measurement_selection( &mut self, n: &mut MeasurementSelection, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("select_measurement_selection", n); Ok(()) } - fn pre_visit_group_by_clause(&mut self, n: &mut GroupByClause) -> VisitorResult { + fn pre_visit_group_by_clause( + &mut self, + n: &mut GroupByClause, + ) -> Result { self.push_pre("group_by_clause", n); Ok(Continue) } - fn post_visit_group_by_clause(&mut self, n: &mut GroupByClause) -> VisitorResult<()> { + fn post_visit_group_by_clause(&mut self, n: &mut GroupByClause) -> Result<(), Self::Error> { self.push_post("group_by_clause", n); Ok(()) } - fn pre_visit_select_dimension(&mut self, n: &mut Dimension) -> VisitorResult { + fn pre_visit_select_dimension( + &mut self, + n: &mut Dimension, + ) -> Result { self.push_pre("select_dimension", n); Ok(Continue) } - fn post_visit_select_dimension(&mut self, n: &mut Dimension) -> VisitorResult<()> { + fn post_visit_select_dimension(&mut self, n: &mut Dimension) -> Result<(), Self::Error> { self.push_post("select_dimension", n); Ok(()) } - fn pre_visit_where_clause(&mut self, n: &mut WhereClause) -> VisitorResult { + fn pre_visit_where_clause( + &mut self, + n: &mut WhereClause, + ) -> Result { self.push_pre("where_clause", n); Ok(Continue) } - fn post_visit_where_clause(&mut self, n: &mut WhereClause) -> VisitorResult<()> { + fn post_visit_where_clause(&mut self, n: &mut WhereClause) -> Result<(), Self::Error> { self.push_post("where_clause", n); Ok(()) } @@ -1445,12 +1515,15 @@ mod test { fn pre_visit_show_from_clause( &mut self, n: &mut ShowFromClause, - ) -> VisitorResult { + ) -> Result { self.push_pre("show_from_clause", n); Ok(Continue) } - fn post_visit_show_from_clause(&mut self, n: &mut ShowFromClause) -> VisitorResult<()> { + fn post_visit_show_from_clause( + &mut self, + n: &mut ShowFromClause, + ) -> Result<(), Self::Error> { self.push_post("show_from_clause", n); Ok(()) } @@ -1458,7 +1531,7 @@ mod test { fn pre_visit_qualified_measurement_name( &mut self, n: &mut QualifiedMeasurementName, - ) -> VisitorResult { + ) -> Result { self.push_pre("qualified_measurement_name", n); Ok(Continue) } @@ -1466,67 +1539,82 @@ mod test { fn post_visit_qualified_measurement_name( &mut self, n: &mut QualifiedMeasurementName, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("qualified_measurement_name", n); Ok(()) } - fn pre_visit_fill_clause(&mut self, n: &mut FillClause) -> VisitorResult { + fn pre_visit_fill_clause(&mut self, n: &mut FillClause) -> Result { self.push_pre("fill_clause", n); Ok(Continue) } - fn post_visit_fill_clause(&mut self, n: &mut FillClause) -> VisitorResult<()> { + fn post_visit_fill_clause(&mut self, n: &mut FillClause) -> Result<(), Self::Error> { self.push_post("fill_clause", n); Ok(()) } - fn pre_visit_order_by_clause(&mut self, n: &mut OrderByClause) -> VisitorResult { + fn pre_visit_order_by_clause( + &mut self, + n: &mut OrderByClause, + ) -> Result { self.push_pre("order_by_clause", n); Ok(Continue) } - fn post_visit_order_by_clause(&mut self, n: &mut OrderByClause) -> VisitorResult<()> { + fn post_visit_order_by_clause(&mut self, n: &mut OrderByClause) -> Result<(), Self::Error> { self.push_post("order_by_clause", n); Ok(()) } - fn pre_visit_limit_clause(&mut self, n: &mut LimitClause) -> VisitorResult { + fn pre_visit_limit_clause( + &mut self, + n: &mut LimitClause, + ) -> Result { self.push_pre("limit_clause", n); Ok(Continue) } - fn post_visit_limit_clause(&mut self, n: &mut LimitClause) -> VisitorResult<()> { + fn post_visit_limit_clause(&mut self, n: &mut LimitClause) -> Result<(), Self::Error> { self.push_post("limit_clause", n); Ok(()) } - fn pre_visit_offset_clause(&mut self, n: &mut OffsetClause) -> VisitorResult { + fn pre_visit_offset_clause( + &mut self, + n: &mut OffsetClause, + ) -> Result { self.push_pre("offset_clause", n); Ok(Continue) } - fn post_visit_offset_clause(&mut self, n: &mut OffsetClause) -> VisitorResult<()> { + fn post_visit_offset_clause(&mut self, n: &mut OffsetClause) -> Result<(), Self::Error> { self.push_post("offset_clause", n); Ok(()) } - fn pre_visit_slimit_clause(&mut self, n: &mut SLimitClause) -> VisitorResult { + fn pre_visit_slimit_clause( + &mut self, + n: &mut SLimitClause, + ) -> Result { self.push_pre("slimit_clause", n); Ok(Continue) } - fn post_visit_slimit_clause(&mut self, n: &mut SLimitClause) -> VisitorResult<()> { + fn post_visit_slimit_clause(&mut self, n: &mut SLimitClause) -> Result<(), Self::Error> { self.push_post("slimit_clause", n); Ok(()) } - fn pre_visit_soffset_clause(&mut self, n: &mut SOffsetClause) -> VisitorResult { + fn pre_visit_soffset_clause( + &mut self, + n: &mut SOffsetClause, + ) -> Result { self.push_pre("soffset_clause", n); Ok(Continue) } - fn post_visit_soffset_clause(&mut self, n: &mut SOffsetClause) -> VisitorResult<()> { + fn post_visit_soffset_clause(&mut self, n: &mut SOffsetClause) -> Result<(), Self::Error> { self.push_post("soffset_clause", n); Ok(()) } @@ -1534,12 +1622,15 @@ mod test { fn pre_visit_timezone_clause( &mut self, n: &mut TimeZoneClause, - ) -> VisitorResult { + ) -> Result { self.push_pre("timezone_clause", n); Ok(Continue) } - fn post_visit_timezone_clause(&mut self, n: &mut TimeZoneClause) -> VisitorResult<()> { + fn post_visit_timezone_clause( + &mut self, + n: &mut TimeZoneClause, + ) -> Result<(), Self::Error> { self.push_post("timezone_clause", n); Ok(()) } @@ -1547,22 +1638,25 @@ mod test { fn pre_visit_extended_on_clause( &mut self, n: &mut ExtendedOnClause, - ) -> VisitorResult { + ) -> Result { self.push_pre("extended_on_clause", n); Ok(Continue) } - fn post_visit_extended_on_clause(&mut self, n: &mut ExtendedOnClause) -> VisitorResult<()> { + fn post_visit_extended_on_clause( + &mut self, + n: &mut ExtendedOnClause, + ) -> Result<(), Self::Error> { self.push_post("extended_on_clause", n); Ok(()) } - fn pre_visit_on_clause(&mut self, n: &mut OnClause) -> VisitorResult { + fn pre_visit_on_clause(&mut self, n: &mut OnClause) -> Result { self.push_pre("on_clause", n); Ok(Continue) } - fn post_visit_on_clause(&mut self, n: &mut OnClause) -> VisitorResult<()> { + fn post_visit_on_clause(&mut self, n: &mut OnClause) -> Result<(), Self::Error> { self.push_pre("on_clause", n); Ok(()) } @@ -1570,7 +1664,7 @@ mod test { fn pre_visit_with_measurement_clause( &mut self, n: &mut WithMeasurementClause, - ) -> VisitorResult { + ) -> Result { self.push_pre("with_measurement_clause", n); Ok(Continue) } @@ -1578,17 +1672,20 @@ mod test { fn post_visit_with_measurement_clause( &mut self, n: &mut WithMeasurementClause, - ) -> VisitorResult<()> { + ) -> Result<(), Self::Error> { self.push_post("with_measurement_clause", n); Ok(()) } - fn pre_visit_with_key_clause(&mut self, n: &mut WithKeyClause) -> VisitorResult { + fn pre_visit_with_key_clause( + &mut self, + n: &mut WithKeyClause, + ) -> Result { self.push_pre("with_key_clause", n); Ok(Continue) } - fn post_visit_with_key_clause(&mut self, n: &mut WithKeyClause) -> VisitorResult<()> { + fn post_visit_with_key_clause(&mut self, n: &mut WithKeyClause) -> Result<(), Self::Error> { self.push_post("with_key_clause", n); Ok(()) } @@ -1703,10 +1800,12 @@ mod test { struct AddLimit; impl VisitorMut for AddLimit { + type Error = (); + fn pre_visit_select_statement( &mut self, n: &mut SelectStatement, - ) -> VisitorResult { + ) -> Result { n.limit = Some(LimitClause(10)); Ok(Continue) } diff --git a/iox_query/src/plan/influxql/field.rs b/iox_query/src/plan/influxql/field.rs index d579cda212..bed619559d 100644 --- a/iox_query/src/plan/influxql/field.rs +++ b/iox_query/src/plan/influxql/field.rs @@ -1,6 +1,6 @@ use influxdb_influxql_parser::expression::Expr; use influxdb_influxql_parser::select::{Field, SelectStatement}; -use influxdb_influxql_parser::visit::{Recursion, Visitable, Visitor, VisitorResult}; +use influxdb_influxql_parser::visit::{Recursion, Visitable, Visitor}; use std::ops::Deref; /// Returns the name of the field. @@ -59,7 +59,9 @@ pub(crate) fn field_by_name(select: &SelectStatement, name: &str) -> Option(&'a mut Vec); impl<'a> Visitor for BinaryExprNameVisitor<'a> { - fn pre_visit_expr(self, n: &Expr) -> VisitorResult> { + type Error = (); + + fn pre_visit_expr(self, n: &Expr) -> Result, Self::Error> { match n { Expr::Call { name, .. } => self.0.push(name.clone()), Expr::VarRef { name, .. } => self.0.push(name.to_string()), diff --git a/iox_query/src/plan/influxql/rewriter.rs b/iox_query/src/plan/influxql/rewriter.rs index 8b344b9af5..0665e1ed89 100644 --- a/iox_query/src/plan/influxql/rewriter.rs +++ b/iox_query/src/plan/influxql/rewriter.rs @@ -14,7 +14,6 @@ use influxdb_influxql_parser::select::{ SelectStatement, }; use influxdb_influxql_parser::string::Regex; -use influxdb_influxql_parser::visit::{Recursion, Visitable, Visitor, VisitorResult}; use itertools::Itertools; use predicate::rpc_predicate::QueryNamespaceMeta; use query_functions::clean_non_meta_escapes; @@ -151,10 +150,14 @@ fn from_field_and_dimensions( /// has any wildcards or regular expressions in the projection list /// and `GROUP BY` clause respectively. fn has_wildcards(stmt: &SelectStatement) -> (bool, bool) { + use influxdb_influxql_parser::visit::{Recursion, Visitable, Visitor}; + struct HasWildcardsVisitor(bool, bool); impl Visitor for HasWildcardsVisitor { - fn pre_visit_expr(self, n: &Expr) -> VisitorResult> { + type Error = DataFusionError; + + fn pre_visit_expr(self, n: &Expr) -> Result> { Ok( if matches!(n, Expr::Wildcard(_) | Expr::Literal(Literal::Regex(_))) { Recursion::Stop(Self(true, self.1)) @@ -167,12 +170,12 @@ fn has_wildcards(stmt: &SelectStatement) -> (bool, bool) { fn pre_visit_select_from_clause( self, _n: &FromMeasurementClause, - ) -> VisitorResult> { + ) -> Result> { // Don't traverse FROM and potential subqueries Ok(Recursion::Stop(self)) } - fn pre_visit_select_dimension(self, n: &Dimension) -> VisitorResult> { + fn pre_visit_select_dimension(self, n: &Dimension) -> Result> { Ok(if matches!(n, Dimension::Wildcard | Dimension::Regex(_)) { Recursion::Stop(Self(self.0, true)) } else { diff --git a/workspace-hack/Cargo.toml b/workspace-hack/Cargo.toml index 9c98801415..e62683edfe 100644 --- a/workspace-hack/Cargo.toml +++ b/workspace-hack/Cargo.toml @@ -57,10 +57,12 @@ object_store = { git = "https://github.com/apache/arrow-rs.git", rev = "f5c165ac once_cell = { version = "1", features = ["alloc", "parking_lot", "parking_lot_core", "race", "std"] } parking_lot = { version = "0.12", features = ["arc_lock"] } parquet = { version = "29", features = ["arrow", "arrow-array", "arrow-buffer", "arrow-cast", "arrow-data", "arrow-ipc", "arrow-schema", "arrow-select", "async", "base64", "brotli", "experimental", "flate2", "futures", "lz4", "snap", "tokio", "zstd"] } +phf_shared = { version = "0.11", features = ["std"] } predicates = { version = "2", features = ["diff", "difflib", "float-cmp", "normalize-line-endings", "regex"] } prost = { version = "0.11", features = ["prost-derive", "std"] } prost-types = { version = "0.11", features = ["std"] } rand = { version = "0.8", features = ["alloc", "getrandom", "libc", "rand_chacha", "small_rng", "std", "std_rng"] } +rand_core = { version = "0.6", default-features = false, features = ["alloc", "getrandom", "std"] } regex = { version = "1", features = ["aho-corasick", "memchr", "perf", "perf-cache", "perf-dfa", "perf-inline", "perf-literal", "std", "unicode", "unicode-age", "unicode-bool", "unicode-case", "unicode-gencat", "unicode-perl", "unicode-script", "unicode-segment"] } regex-automata = { version = "0.1", features = ["regex-syntax", "std"] } regex-syntax = { version = "0.6", features = ["unicode", "unicode-age", "unicode-bool", "unicode-case", "unicode-gencat", "unicode-perl", "unicode-script", "unicode-segment"] } @@ -121,9 +123,11 @@ nom = { version = "7", features = ["alloc", "std"] } num-traits = { version = "0.2", features = ["i128", "libm", "std"] } once_cell = { version = "1", features = ["alloc", "parking_lot", "parking_lot_core", "race", "std"] } parking_lot = { version = "0.12", features = ["arc_lock"] } +phf_shared = { version = "0.11", features = ["std"] } prost = { version = "0.11", features = ["prost-derive", "std"] } prost-types = { version = "0.11", features = ["std"] } rand = { version = "0.8", features = ["alloc", "getrandom", "libc", "rand_chacha", "small_rng", "std", "std_rng"] } +rand_core = { version = "0.6", default-features = false, features = ["alloc", "getrandom", "std"] } regex = { version = "1", features = ["aho-corasick", "memchr", "perf", "perf-cache", "perf-dfa", "perf-inline", "perf-literal", "std", "unicode", "unicode-age", "unicode-bool", "unicode-case", "unicode-gencat", "unicode-perl", "unicode-script", "unicode-segment"] } regex-syntax = { version = "0.6", features = ["unicode", "unicode-age", "unicode-bool", "unicode-case", "unicode-gencat", "unicode-perl", "unicode-script", "unicode-segment"] } ring = { version = "0.16", features = ["alloc", "dev_urandom_fallback", "once_cell", "std"] }