Skip to content

Commit

Permalink
Support a restricted SQL subset for querying timeseries
Browse files Browse the repository at this point in the history
- Add methods for querying oximeter timeseries using a limited subset of
  SQL. The raw string is heavily validated, and only simple SELECT
  queries are currently supported, with a limited subset of ClickHouse
  functions. Still, this allows running many different kinds of queries,
  including aggregations, window functions, and joins.
- Adds a few types for reading out tabular data from the query result,
  and parsing basic metadata for understanding resource usage of the
  queries.
- Add a barebones SQL shell for running oximeter SQL queries, using the
  new `Client::query` method.
- Include a bunch of tests for the restricted SQL subset as well as
  correctness of the actual returned queries against the DB.
  • Loading branch information
bnaecker committed Nov 9, 2023
1 parent 026b8e6 commit 03b8b97
Show file tree
Hide file tree
Showing 23 changed files with 2,280 additions and 275 deletions.
145 changes: 132 additions & 13 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ rand = "0.8.5"
ratatui = "0.23.0"
rayon = "1.8"
rcgen = "0.11.3"
reedline = "0.22.0"
ref-cast = "1.0"
regex = "1.10.2"
regress = "0.7.1"
Expand All @@ -307,6 +308,7 @@ rpassword = "7.2.0"
rstest = "0.18.2"
rustfmt-wrapper = "0.2"
rustls = "0.21.8"
rustyline = "12.0.0"
samael = { git = "https://github.com/njaremko/samael", features = ["xmlsec"], branch = "master" }
schemars = "0.8.12"
secrecy = "0.8.0"
Expand Down Expand Up @@ -340,6 +342,7 @@ sp-sim = { path = "sp-sim" }
sprockets-common = { git = "http://github.com/oxidecomputer/sprockets", rev = "77df31efa5619d0767ffc837ef7468101608aee9" }
sprockets-host = { git = "http://github.com/oxidecomputer/sprockets", rev = "77df31efa5619d0767ffc837ef7468101608aee9" }
sprockets-rot = { git = "http://github.com/oxidecomputer/sprockets", rev = "77df31efa5619d0767ffc837ef7468101608aee9" }
sqlparser = { version = "0.36.1", features = [ "visitor" ] }
static_assertions = "1.1.0"
# Please do not change the Steno version to a Git dependency. It makes it
# harder than expected to make breaking changes (even if you specify a specific
Expand Down
29 changes: 24 additions & 5 deletions oximeter/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,44 @@ license = "MPL-2.0"
anyhow.workspace = true
async-trait.workspace = true
bcs.workspace = true
bytes = { workspace = true, features = [ "serde" ] }
chrono.workspace = true
clap.workspace = true
dropshot.workspace = true
futures.workspace = true
highway.workspace = true
indexmap.workspace = true
omicron-workspace-hack.workspace = true
oximeter.workspace = true
reedline.workspace = true
regex.workspace = true
reqwest = { workspace = true, features = [ "json" ] }
schemars = { workspace = true, features = [ "uuid1", "bytes", "chrono" ] }
rustyline.workspace = true
serde.workspace = true
serde_json.workspace = true
slog.workspace = true
slog-async.workspace = true
slog-term.workspace = true
sqlparser.workspace = true
sqlformat = "0.2.2"
tabled.workspace = true
thiserror.workspace = true
tokio = { workspace = true, features = [ "rt-multi-thread", "macros" ] }
usdt.workspace = true
uuid.workspace = true
omicron-workspace-hack.workspace = true

[dependencies.bytes]
workspace = true
features = [ "serde" ]

[dependencies.reqwest]
workspace = true
features = [ "json" ]

[dependencies.schemars]
workspace = true
features = [ "uuid1", "bytes", "chrono" ]

[dependencies.tokio]
workspace = true
features = [ "rt-multi-thread", "macros" ]

[dev-dependencies]
expectorate.workspace = true
Expand Down
Loading

0 comments on commit 03b8b97

Please sign in to comment.