Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: support system.parquet_files table #25002

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
be11052
chore: initial sync changes
hiltontj May 9, 2024
f637f8c
fix: correct field type for retention policies
hiltontj May 9, 2024
72d825d
fix: test in wal
hiltontj May 9, 2024
0fd3f31
refactor: use TokioDatafusionConfig for server setup
hiltontj May 10, 2024
985589e
feat: add SystemSchemaProvider to QueryExecutor
hiltontj May 10, 2024
c5b7fba
chore: clippy
hiltontj May 10, 2024
266cca1
feat: add the system.queries table
hiltontj May 10, 2024
5c1b2d4
fix: gRPC test broken after addition of system.queries table
hiltontj May 10, 2024
afdd5ba
Merge branch 'main' into hiltontj/system-tables
hiltontj May 13, 2024
df41e99
Merge branch 'hiltontj/system-tables' into hiltontj/system-queries-table
hiltontj May 13, 2024
fa63a8e
test: test system.queries table via gRPC
hiltontj May 13, 2024
e3aa631
refactor: clean up test for system queries table
hiltontj May 13, 2024
0b87130
refactor: naming on const in query executor
hiltontj May 13, 2024
8fc3537
refactor: expose system tables by default in edge/pro
hiltontj May 14, 2024
17d5bec
feat: support system.parquet_files table
hiltontj May 14, 2024
a990259
test: added test for system.parquet_files table
hiltontj May 15, 2024
f85fa78
test: add test for missing table_name to system.parquet_files queries
hiltontj May 15, 2024
8998e59
chore: switch to core rev instead of branch
hiltontj May 15, 2024
d101824
Merge branch 'main' into hiltontj/system-tables
hiltontj May 16, 2024
b9044cd
Merge branch 'hiltontj/system-tables' into hiltontj/system-queries-table
hiltontj May 16, 2024
f94c342
Merge branch 'hiltontj/system-queries-table' into hiltontj/system-tab…
hiltontj May 16, 2024
d2b1cd5
Merge branch 'hiltontj/system-tables-no-debug' into hiltontj/sys-tbl-…
hiltontj May 16, 2024
c4430cf
Merge branch 'hiltontj/system-tables' into hiltontj/system-queries-table
hiltontj May 16, 2024
788b73d
Merge branch 'hiltontj/system-queries-table' into hiltontj/system-tab…
hiltontj May 16, 2024
77965ec
Merge branch 'hiltontj/system-tables-no-debug' into hiltontj/sys-tbl-…
hiltontj May 16, 2024
9171bbf
Merge branch 'main' into hiltontj/sys-tbl-parquet-files
hiltontj May 17, 2024
File filter

Filter by extension

Filter by extension


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

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ sha2 = "0.10.8"
snap = "1.0.0"
sqlparser = "0.41.0"
sysinfo = "0.30.8"
test-log = { version = "0.2.16", features = ["trace"] }
thiserror = "1.0"
tokio = { version = "1.35", features = ["full"] }
tokio-util = "0.7.9"
Expand Down
12 changes: 12 additions & 0 deletions influxdb3/src/commands/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ pub struct Config {
action
)]
pub segment_duration: SegmentDuration,

// TODO - tune this default:
/// The size of the query log. Up to this many queries will remain in the log before
/// old queries are evicted to make room for new ones.
#[clap(
long = "query-log-size",
env = "INFLUXDB3_QUERY_LOG_SIZE",
default_value = "1000",
action
)]
pub query_log_size: usize,
}

/// If `p` does not exist, try to create it as a directory.
Expand Down Expand Up @@ -275,6 +286,7 @@ pub async fn command(config: Config) -> Result<()> {
Arc::clone(&metrics),
Arc::new(config.datafusion_config),
10,
config.query_log_size,
));

let builder = ServerBuilder::new(common_state)
Expand Down
22 changes: 12 additions & 10 deletions influxdb3/tests/server/flight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,18 @@ async fn flight() -> Result<(), influxdb3_client::Error> {

assert_batches_sorted_eq!(
[
"+--------------+--------------------+-------------+------------+",
"| catalog_name | db_schema_name | table_name | table_type |",
"+--------------+--------------------+-------------+------------+",
"| public | information_schema | columns | VIEW |",
"| public | information_schema | df_settings | VIEW |",
"| public | information_schema | schemata | VIEW |",
"| public | information_schema | tables | VIEW |",
"| public | information_schema | views | VIEW |",
"| public | iox | cpu | BASE TABLE |",
"+--------------+--------------------+-------------+------------+",
"+--------------+--------------------+---------------+------------+",
"| catalog_name | db_schema_name | table_name | table_type |",
"+--------------+--------------------+---------------+------------+",
"| public | information_schema | columns | VIEW |",
"| public | information_schema | df_settings | VIEW |",
"| public | information_schema | schemata | VIEW |",
"| public | information_schema | tables | VIEW |",
"| public | information_schema | views | VIEW |",
"| public | iox | cpu | BASE TABLE |",
"| public | system | parquet_files | BASE TABLE |",
"| public | system | queries | BASE TABLE |",
"+--------------+--------------------+---------------+------------+",
],
&batches
);
Expand Down
2 changes: 1 addition & 1 deletion influxdb3/tests/server/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod flight;
mod limits;
mod ping;
mod query;
mod system_tables;
mod write;

/// Configuration for a [`TestServer`]
Expand Down Expand Up @@ -122,7 +123,6 @@ impl TestServer {
.expect("connect to gRPC client");
let mut client = FlightSqlClient::new(channel);
client.add_header("database", database).unwrap();
client.add_header("iox-debug", "true").unwrap();
client
}

Expand Down
92 changes: 92 additions & 0 deletions influxdb3/tests/server/system_tables.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
use arrow_util::assert_batches_sorted_eq;
use influxdb3_client::Precision;

use crate::{collect_stream, TestServer};

#[tokio::test]
async fn queries_table() {
let server = TestServer::spawn().await;

server
.write_lp_to_db(
"foo",
"cpu,host=s1,region=us-east usage=0.9 1\n\
cpu,host=s1,region=us-east usage=0.89 2\n\
cpu,host=s1,region=us-east usage=0.85 3",
Precision::Nanosecond,
)
.await
.expect("write some lp");

let mut client = server.flight_sql_client("foo").await;

// Check queries table for completed queries, will be empty:
{
let response = client
.query("SELECT COUNT(*) FROM system.queries WHERE running = false")
.await
.unwrap();

let batches = collect_stream(response).await;
assert_batches_sorted_eq!(
[
"+----------+",
"| COUNT(*) |",
"+----------+",
"| 0 |",
"+----------+",
],
&batches
);
}

// Do some queries, to produce some query logs:
{
let queries = [
"SELECT * FROM cpu", // valid
"SELECT * FROM mem", // not valid table, will fail, and not be logged
"SELECT usage, time FROM cpu", // specific columns
];
for q in queries {
let response = client.query(q).await;
// collect the stream to make sure the query completes:
if let Ok(stream) = response {
let _batches = collect_stream(stream).await;
}
}
}

// Now check the log:
{
// A sub-set of columns is selected in this query, because the queries
// table contains may columns whose values change in susequent test runs
let response = client
.query(
"SELECT \
phase, \
query_type, \
query_text, \
success, \
running, \
cancelled \
FROM system.queries \
WHERE success = true",
)
.await
.unwrap();

let batches = collect_stream(response).await;
assert_batches_sorted_eq!(
[
"+---------+------------+--------------------------------------------------------------------------------+---------+---------+-----------+",
"| phase | query_type | query_text | success | running | cancelled |",
"+---------+------------+--------------------------------------------------------------------------------+---------+---------+-----------+",
"| success | flightsql | CommandStatementQuerySELECT * FROM cpu | true | false | false |",
"| success | flightsql | CommandStatementQuerySELECT COUNT(*) FROM system.queries WHERE running = false | true | false | false |",
"| success | flightsql | CommandStatementQuerySELECT usage, time FROM cpu | true | false | false |",
"+---------+------------+--------------------------------------------------------------------------------+---------+---------+-----------+",
],
&batches
);
}
}
2 changes: 2 additions & 0 deletions influxdb3_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ iox_http.workspace = true
iox_query.workspace = true
iox_query_params.workspace = true
iox_query_influxql.workspace = true
iox_system_tables.workspace = true
iox_time.workspace = true
metric.workspace = true
metric_exporters.workspace = true
Expand Down Expand Up @@ -70,6 +71,7 @@ parquet.workspace = true
parquet_file.workspace = true
test_helpers.workspace = true
test_helpers_end_to_end.workspace = true
test-log.workspace = true

# crates.io crates
http.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions influxdb3_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ mod tests {
Arc::clone(&metrics),
Arc::new(HashMap::new()),
10,
10,
));

let server = ServerBuilder::new(common_state)
Expand Down Expand Up @@ -449,6 +450,7 @@ mod tests {
Arc::clone(&metrics),
Arc::new(HashMap::new()),
10,
10,
);

let server = ServerBuilder::new(common_state)
Expand Down Expand Up @@ -655,6 +657,7 @@ mod tests {
Arc::clone(&metrics),
Arc::new(HashMap::new()),
10,
10,
);

let server = ServerBuilder::new(common_state)
Expand Down
Loading