test: Add / update query tests

pull/24376/head
Andrew Lamb 2021-04-01 16:13:19 -04:00 committed by kodiakhq[bot]
parent d0e901f503
commit e52c6a8292
2 changed files with 95 additions and 15 deletions

View File

@ -168,6 +168,29 @@ impl DBSetup for TwoMeasurementsManyFields {
}
}
pub struct TwoMeasurementsManyFieldsOneChunk {}
#[async_trait]
impl DBSetup for TwoMeasurementsManyFieldsOneChunk {
async fn make(&self) -> Vec<DBScenario> {
let db = make_db();
let mut writer = TestLPWriter::default();
let lp_lines = vec![
"h2o,state=MA,city=Boston temp=70.4 50",
"h2o,state=MA,city=Boston other_temp=70.4 250",
"h2o,state=CA,city=Boston other_temp=72.4 350",
"o2,state=MA,city=Boston temp=53.4,reading=51 50",
"o2,state=CA temp=79.0 300",
];
writer.write_lp_string(&db, &lp_lines.join("\n")).unwrap();
vec![DBScenario {
scenario_name: "Data in open chunk of mutable buffer".into(),
db,
}]
}
}
pub struct OneMeasurementManyFields {}
#[async_trait]
impl DBSetup for OneMeasurementManyFields {

View File

@ -190,6 +190,8 @@ async fn sql_select_from_information_schema_tables() {
"+---------------+--------------------+------------+------------+",
"| public | iox | h2o | BASE TABLE |",
"| public | iox | o2 | BASE TABLE |",
"| public | system | chunks | BASE TABLE |",
"| public | system | columns | BASE TABLE |",
"| public | information_schema | tables | VIEW |",
"| public | information_schema | columns | VIEW |",
"+---------------+--------------------+------------+------------+",
@ -207,21 +209,32 @@ async fn sql_select_from_information_schema_columns() {
// validate we have access to information schema for listing columns
// names
let expected = vec![
"+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+-------------------------+---------------+--------------------+---------------+",
"| table_catalog | table_schema | table_name | column_name | ordinal_position | column_default | is_nullable | data_type | character_maximum_length | character_octet_length | numeric_precision | numeric_precision_radix | numeric_scale | datetime_precision | interval_type |",
"+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+-------------------------+---------------+--------------------+---------------+",
"| public | iox | h2o | city | 0 | | YES | Utf8 | | 2147483647 | | | | | |",
"| public | iox | h2o | moisture | 1 | | YES | Float64 | | | 24 | 2 | | | |",
"| public | iox | h2o | other_temp | 2 | | YES | Float64 | | | 24 | 2 | | | |",
"| public | iox | h2o | state | 3 | | YES | Utf8 | | 2147483647 | | | | | |",
"| public | iox | h2o | temp | 4 | | YES | Float64 | | | 24 | 2 | | | |",
"| public | iox | h2o | time | 5 | | NO | Int64 | | | | | | | |",
"| public | iox | o2 | city | 0 | | YES | Utf8 | | 2147483647 | | | | | |",
"| public | iox | o2 | reading | 1 | | YES | Float64 | | | 24 | 2 | | | |",
"| public | iox | o2 | state | 2 | | YES | Utf8 | | 2147483647 | | | | | |",
"| public | iox | o2 | temp | 3 | | YES | Float64 | | | 24 | 2 | | | |",
"| public | iox | o2 | time | 4 | | NO | Int64 | | | | | | | |",
"+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+-------------------------+---------------+--------------------+---------------+",
"+---------------+--------------+------------+---------------------+------------------+----------------+-------------+-----------------------------+--------------------------+------------------------+-------------------+-------------------------+---------------+--------------------+---------------+",
"| table_catalog | table_schema | table_name | column_name | ordinal_position | column_default | is_nullable | data_type | character_maximum_length | character_octet_length | numeric_precision | numeric_precision_radix | numeric_scale | datetime_precision | interval_type |",
"+---------------+--------------+------------+---------------------+------------------+----------------+-------------+-----------------------------+--------------------------+------------------------+-------------------+-------------------------+---------------+--------------------+---------------+",
"| public | iox | h2o | city | 0 | | YES | Utf8 | | 2147483647 | | | | | |",
"| public | iox | h2o | moisture | 1 | | YES | Float64 | | | 24 | 2 | | | |",
"| public | iox | h2o | other_temp | 2 | | YES | Float64 | | | 24 | 2 | | | |",
"| public | iox | h2o | state | 3 | | YES | Utf8 | | 2147483647 | | | | | |",
"| public | iox | h2o | temp | 4 | | YES | Float64 | | | 24 | 2 | | | |",
"| public | iox | h2o | time | 5 | | NO | Int64 | | | | | | | |",
"| public | iox | o2 | city | 0 | | YES | Utf8 | | 2147483647 | | | | | |",
"| public | iox | o2 | reading | 1 | | YES | Float64 | | | 24 | 2 | | | |",
"| public | iox | o2 | state | 2 | | YES | Utf8 | | 2147483647 | | | | | |",
"| public | iox | o2 | temp | 3 | | YES | Float64 | | | 24 | 2 | | | |",
"| public | iox | o2 | time | 4 | | NO | Int64 | | | | | | | |",
"| public | system | chunks | id | 0 | | NO | UInt32 | | | 32 | 2 | | | |",
"| public | system | chunks | partition_key | 1 | | NO | Utf8 | | 2147483647 | | | | | |",
"| public | system | chunks | storage | 2 | | NO | Utf8 | | 2147483647 | | | | | |",
"| public | system | chunks | estimated_bytes | 3 | | YES | UInt64 | | | | | | | |",
"| public | system | chunks | time_of_first_write | 4 | | YES | Timestamp(Nanosecond, None) | | | | | | | |",
"| public | system | chunks | time_of_last_write | 5 | | YES | Timestamp(Nanosecond, None) | | | | | | | |",
"| public | system | chunks | time_closing | 6 | | YES | Timestamp(Nanosecond, None) | | | | | | | |",
"| public | system | columns | partition_key | 0 | | NO | Utf8 | | 2147483647 | | | | | |",
"| public | system | columns | table_name | 1 | | YES | Utf8 | | 2147483647 | | | | | |",
"| public | system | columns | column_name | 2 | | YES | Utf8 | | 2147483647 | | | | | |",
"| public | system | columns | count | 3 | | YES | UInt64 | | | | | | | |",
"+---------------+--------------+------------+---------------------+------------------+----------------+-------------+-----------------------------+--------------------------+------------------------+-------------------+-------------------------+---------------+--------------------+---------------+",
];
run_sql_test_case!(
TwoMeasurementsManyFields {},
@ -230,6 +243,50 @@ async fn sql_select_from_information_schema_columns() {
);
}
#[tokio::test]
async fn sql_select_from_system_tables() {
// system tables reflect the state of chunks, so don't run them
// with different chunk configurations.
// ensures the tables / plumbing are hooked up (so no need to
// test timestamps, etc)
let expected = vec![
"+----+---------------+-------------------+-----------------+",
"| id | partition_key | storage | estimated_bytes |",
"+----+---------------+-------------------+-----------------+",
"| 0 | 1970-01-01T00 | OpenMutableBuffer | 493 |",
"+----+---------------+-------------------+-----------------+",
];
run_sql_test_case!(
TwoMeasurementsManyFieldsOneChunk {},
"SELECT id, partition_key, storage, estimated_bytes from system.chunks",
&expected
);
let expected = vec![
"+---------------+------------+-------------+-------+",
"| partition_key | table_name | column_name | count |",
"+---------------+------------+-------------+-------+",
"| 1970-01-01T00 | h2o | state | 3 |",
"| 1970-01-01T00 | h2o | city | 3 |",
"| 1970-01-01T00 | h2o | temp | 1 |",
"| 1970-01-01T00 | h2o | time | 3 |",
"| 1970-01-01T00 | h2o | other_temp | 2 |",
"| 1970-01-01T00 | o2 | state | 2 |",
"| 1970-01-01T00 | o2 | city | 1 |",
"| 1970-01-01T00 | o2 | temp | 2 |",
"| 1970-01-01T00 | o2 | time | 2 |",
"| 1970-01-01T00 | o2 | reading | 1 |",
"+---------------+------------+-------------+-------+",
];
run_sql_test_case!(
TwoMeasurementsManyFieldsOneChunk {},
"SELECT * from system.columns",
&expected
);
}
#[tokio::test]
async fn sql_union_all() {
// validate name resolution works for UNION ALL queries