feat: expose null_counts in system.chunk_columns (#2105)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>pull/24376/head
parent
201aead49d
commit
3ea84c6be4
|
@ -366,24 +366,24 @@ async fn sql_select_from_system_chunk_columns() {
|
||||||
// with different chunk configurations.
|
// with different chunk configurations.
|
||||||
|
|
||||||
let expected = vec![
|
let expected = vec![
|
||||||
"+---------------+----------+------------+-------------+-------------------+-----------+-----------+-----------+--------------+",
|
"+---------------+----------+------------+-------------+-------------------+-----------+------------+-----------+-----------+--------------+",
|
||||||
"| partition_key | chunk_id | table_name | column_name | storage | row_count | min_value | max_value | memory_bytes |",
|
"| partition_key | chunk_id | table_name | column_name | storage | row_count | null_count | min_value | max_value | memory_bytes |",
|
||||||
"+---------------+----------+------------+-------------+-------------------+-----------+-----------+-----------+--------------+",
|
"+---------------+----------+------------+-------------+-------------------+-----------+------------+-----------+-----------+--------------+",
|
||||||
"| 1970-01-01T00 | 0 | h2o | city | ReadBuffer | 2 | Boston | Boston | 252 |",
|
"| 1970-01-01T00 | 0 | h2o | city | ReadBuffer | 2 | 0 | Boston | Boston | 252 |",
|
||||||
"| 1970-01-01T00 | 0 | h2o | other_temp | ReadBuffer | 2 | 70.4 | 70.4 | 425 |",
|
"| 1970-01-01T00 | 0 | h2o | other_temp | ReadBuffer | 2 | 1 | 70.4 | 70.4 | 425 |",
|
||||||
"| 1970-01-01T00 | 0 | h2o | state | ReadBuffer | 2 | MA | MA | 240 |",
|
"| 1970-01-01T00 | 0 | h2o | state | ReadBuffer | 2 | 0 | MA | MA | 240 |",
|
||||||
"| 1970-01-01T00 | 0 | h2o | temp | ReadBuffer | 2 | 70.4 | 70.4 | 425 |",
|
"| 1970-01-01T00 | 0 | h2o | temp | ReadBuffer | 2 | 1 | 70.4 | 70.4 | 425 |",
|
||||||
"| 1970-01-01T00 | 0 | h2o | time | ReadBuffer | 2 | 50 | 250 | 51 |",
|
"| 1970-01-01T00 | 0 | h2o | time | ReadBuffer | 2 | 0 | 50 | 250 | 51 |",
|
||||||
"| 1970-01-01T00 | 0 | o2 | city | OpenMutableBuffer | 2 | Boston | Boston | 35 |",
|
"| 1970-01-01T00 | 0 | o2 | city | OpenMutableBuffer | 2 | 1 | Boston | Boston | 35 |",
|
||||||
"| 1970-01-01T00 | 0 | o2 | reading | OpenMutableBuffer | 2 | 51 | 51 | 25 |",
|
"| 1970-01-01T00 | 0 | o2 | reading | OpenMutableBuffer | 2 | 1 | 51 | 51 | 25 |",
|
||||||
"| 1970-01-01T00 | 0 | o2 | state | OpenMutableBuffer | 2 | CA | MA | 41 |",
|
"| 1970-01-01T00 | 0 | o2 | state | OpenMutableBuffer | 2 | 0 | CA | MA | 41 |",
|
||||||
"| 1970-01-01T00 | 0 | o2 | temp | OpenMutableBuffer | 2 | 53.4 | 79 | 25 |",
|
"| 1970-01-01T00 | 0 | o2 | temp | OpenMutableBuffer | 2 | 0 | 53.4 | 79 | 25 |",
|
||||||
"| 1970-01-01T00 | 0 | o2 | time | OpenMutableBuffer | 2 | 50 | 300 | 25 |",
|
"| 1970-01-01T00 | 0 | o2 | time | OpenMutableBuffer | 2 | 0 | 50 | 300 | 25 |",
|
||||||
"| 1970-01-01T00 | 1 | h2o | city | OpenMutableBuffer | 1 | Boston | Boston | 31 |",
|
"| 1970-01-01T00 | 1 | h2o | city | OpenMutableBuffer | 1 | 0 | Boston | Boston | 31 |",
|
||||||
"| 1970-01-01T00 | 1 | h2o | other_temp | OpenMutableBuffer | 1 | 72.4 | 72.4 | 17 |",
|
"| 1970-01-01T00 | 1 | h2o | other_temp | OpenMutableBuffer | 1 | 0 | 72.4 | 72.4 | 17 |",
|
||||||
"| 1970-01-01T00 | 1 | h2o | state | OpenMutableBuffer | 1 | CA | CA | 27 |",
|
"| 1970-01-01T00 | 1 | h2o | state | OpenMutableBuffer | 1 | 0 | CA | CA | 27 |",
|
||||||
"| 1970-01-01T00 | 1 | h2o | time | OpenMutableBuffer | 1 | 350 | 350 | 17 |",
|
"| 1970-01-01T00 | 1 | h2o | time | OpenMutableBuffer | 1 | 0 | 350 | 350 | 17 |",
|
||||||
"+---------------+----------+------------+-------------+-------------------+-----------+-----------+-----------+--------------+",
|
"+---------------+----------+------------+-------------+-------------------+-----------+------------+-----------+-----------+--------------+",
|
||||||
];
|
];
|
||||||
run_sql_test_case!(
|
run_sql_test_case!(
|
||||||
TwoMeasurementsManyFieldsTwoChunks {},
|
TwoMeasurementsManyFieldsTwoChunks {},
|
||||||
|
|
|
@ -127,6 +127,7 @@ fn chunk_columns_schema() -> SchemaRef {
|
||||||
Field::new("column_name", DataType::Utf8, false),
|
Field::new("column_name", DataType::Utf8, false),
|
||||||
Field::new("storage", DataType::Utf8, false),
|
Field::new("storage", DataType::Utf8, false),
|
||||||
Field::new("row_count", DataType::UInt64, true),
|
Field::new("row_count", DataType::UInt64, true),
|
||||||
|
Field::new("null_count", DataType::UInt64, true),
|
||||||
Field::new("min_value", DataType::Utf8, true),
|
Field::new("min_value", DataType::Utf8, true),
|
||||||
Field::new("max_value", DataType::Utf8, true),
|
Field::new("max_value", DataType::Utf8, true),
|
||||||
Field::new("memory_bytes", DataType::UInt64, true),
|
Field::new("memory_bytes", DataType::UInt64, true),
|
||||||
|
@ -160,6 +161,7 @@ fn assemble_chunk_columns(
|
||||||
let mut column_name = StringBuilder::new(row_estimate);
|
let mut column_name = StringBuilder::new(row_estimate);
|
||||||
let mut storage = StringBuilder::new(row_estimate);
|
let mut storage = StringBuilder::new(row_estimate);
|
||||||
let mut row_count = UInt64Builder::new(row_estimate);
|
let mut row_count = UInt64Builder::new(row_estimate);
|
||||||
|
let mut null_count = UInt64Builder::new(row_estimate);
|
||||||
let mut min_values = StringBuilder::new(row_estimate);
|
let mut min_values = StringBuilder::new(row_estimate);
|
||||||
let mut max_values = StringBuilder::new(row_estimate);
|
let mut max_values = StringBuilder::new(row_estimate);
|
||||||
let mut memory_bytes = UInt64Builder::new(row_estimate);
|
let mut memory_bytes = UInt64Builder::new(row_estimate);
|
||||||
|
@ -178,6 +180,7 @@ fn assemble_chunk_columns(
|
||||||
column_name.append_value(&column.name)?;
|
column_name.append_value(&column.name)?;
|
||||||
storage.append_value(storage_value)?;
|
storage.append_value(storage_value)?;
|
||||||
row_count.append_value(column.total_count())?;
|
row_count.append_value(column.total_count())?;
|
||||||
|
null_count.append_value(column.null_count())?;
|
||||||
if let Some(v) = column.stats.min_as_str() {
|
if let Some(v) = column.stats.min_as_str() {
|
||||||
min_values.append_value(v)?;
|
min_values.append_value(v)?;
|
||||||
} else {
|
} else {
|
||||||
|
@ -204,6 +207,7 @@ fn assemble_chunk_columns(
|
||||||
Arc::new(column_name.finish()),
|
Arc::new(column_name.finish()),
|
||||||
Arc::new(storage.finish()),
|
Arc::new(storage.finish()),
|
||||||
Arc::new(row_count.finish()),
|
Arc::new(row_count.finish()),
|
||||||
|
Arc::new(null_count.finish()),
|
||||||
Arc::new(min_values.finish()),
|
Arc::new(min_values.finish()),
|
||||||
Arc::new(max_values.finish()),
|
Arc::new(max_values.finish()),
|
||||||
Arc::new(memory_bytes.finish()),
|
Arc::new(memory_bytes.finish()),
|
||||||
|
@ -335,7 +339,7 @@ mod tests {
|
||||||
columns: vec![ColumnSummary {
|
columns: vec![ColumnSummary {
|
||||||
name: "c1".to_string(),
|
name: "c1".to_string(),
|
||||||
influxdb_type: Some(InfluxDbType::Field),
|
influxdb_type: Some(InfluxDbType::Field),
|
||||||
stats: Statistics::F64(StatValues::new(Some(110.0), Some(430.0), 667, 0)),
|
stats: Statistics::F64(StatValues::new(Some(110.0), Some(430.0), 667, 99)),
|
||||||
}],
|
}],
|
||||||
}),
|
}),
|
||||||
DetailedChunkSummary {
|
DetailedChunkSummary {
|
||||||
|
@ -392,14 +396,14 @@ mod tests {
|
||||||
];
|
];
|
||||||
|
|
||||||
let expected = vec![
|
let expected = vec![
|
||||||
"+---------------+----------+------------+-------------+-------------------+-----------+-----------+-----------+--------------+",
|
"+---------------+----------+------------+-------------+-------------------+-----------+------------+-----------+-----------+--------------+",
|
||||||
"| partition_key | chunk_id | table_name | column_name | storage | row_count | min_value | max_value | memory_bytes |",
|
"| partition_key | chunk_id | table_name | column_name | storage | row_count | null_count | min_value | max_value | memory_bytes |",
|
||||||
"+---------------+----------+------------+-------------+-------------------+-----------+-----------+-----------+--------------+",
|
"+---------------+----------+------------+-------------+-------------------+-----------+------------+-----------+-----------+--------------+",
|
||||||
"| p1 | 42 | t1 | c1 | ReadBuffer | 55 | bar | foo | 11 |",
|
"| p1 | 42 | t1 | c1 | ReadBuffer | 55 | 0 | bar | foo | 11 |",
|
||||||
"| p1 | 42 | t1 | c2 | ReadBuffer | 66 | 11 | 43 | 12 |",
|
"| p1 | 42 | t1 | c2 | ReadBuffer | 66 | 0 | 11 | 43 | 12 |",
|
||||||
"| p2 | 43 | t1 | c1 | OpenMutableBuffer | 667 | 110 | 430 | 100 |",
|
"| p2 | 43 | t1 | c1 | OpenMutableBuffer | 667 | 99 | 110 | 430 | 100 |",
|
||||||
"| p2 | 44 | t2 | c3 | OpenMutableBuffer | 4 | -1 | 2 | 200 |",
|
"| p2 | 44 | t2 | c3 | OpenMutableBuffer | 4 | 0 | -1 | 2 | 200 |",
|
||||||
"+---------------+----------+------------+-------------+-------------------+-----------+-----------+-----------+--------------+",
|
"+---------------+----------+------------+-------------+-------------------+-----------+------------+-----------+-----------+--------------+",
|
||||||
];
|
];
|
||||||
|
|
||||||
let batch = assemble_chunk_columns(chunk_columns_schema(), summaries).unwrap();
|
let batch = assemble_chunk_columns(chunk_columns_schema(), summaries).unwrap();
|
||||||
|
|
Loading…
Reference in New Issue