Skip to content

Commit

Permalink
Add subsort to testdata
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanrfrazier committed Jul 18, 2023
1 parent cc7156f commit b217537
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions crates/sparrow-main/tests/e2e/collection_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ use crate::{fixture::DataFixture, QueryFixture};
/// Create a simple table with a collection type (map).
///
/// ```json
/// {"time": "1996-12-19T16:39:57Z", "key": 1, "e0": {"f1": 0, "f2": 22}, "e1": 1, "e2": 2.7, "e3": "f1" }
/// {"time": "1996-12-19T16:40:57Z", "key": 1, "e0": {"f1": 1, "f2": 10}, "e1": 2, "e2": 3.8, "e3": "f2" }
/// {"time": "1996-12-19T16:40:59Z", "key": 1, "e0": {"f1": 5, "f2": 3}, "e1": 42, "e2": 4.0, "e3": "f3" }
/// {"time": "1996-12-19T16:41:57Z", "key": 1, "e0": {"f2": 13}, "e1": 42, "e2": null, "e3": "f2" }
/// {"time": "1996-12-19T16:42:57Z", "key": 1, "e0": {"f1": 15, "f3": 11}, "e1": 3, "e2": 7, "e3": "f3" }
/// {"time": "1996-12-19T16:39:57Z", "subsort": 0, "key": 1, "e0": {"f1": 0, "f2": 22}, "e1": 1, "e2": 2.7, "e3": "f1" }
/// {"time": "1996-12-19T16:40:57Z", "subsort": 0, "key": 1, "e0": {"f1": 1, "f2": 10}, "e1": 2, "e2": 3.8, "e3": "f2" }
/// {"time": "1996-12-19T16:40:59Z", "subsort": 0, "key": 1, "e0": {"f1": 5, "f2": 3}, "e1": 42, "e2": 4.0, "e3": "f3" }
/// {"time": "1996-12-19T16:41:57Z", "subsort": 0, "key": 1, "e0": {"f2": 13}, "e1": 42, "e2": null, "e3": "f2" }
/// {"time": "1996-12-19T16:42:57Z", "subsort": 0, "key": 1, "e0": {"f1": 15, "f3": 11}, "e1": 3, "e2": 7, "e3": "f3" }
/// ```
pub(crate) async fn collection_data_fixture() -> DataFixture {
DataFixture::new()
.with_table_from_files(
TableConfig::new_with_table_source("Input", &Uuid::new_v4(), "time", None, "key", ""),
TableConfig::new_with_table_source(
"Input",
&Uuid::new_v4(),
"time",
Some("subsort"),
"key",
"",
),
&[&"parquet/data_with_map.parquet"],
)
.await
Expand All @@ -28,35 +35,35 @@ pub(crate) async fn collection_data_fixture() -> DataFixture {
async fn test_get_static_key() {
insta::assert_snapshot!(QueryFixture::new("{ f1: get(\"f1\", Input.e0) }").run_to_csv(&collection_data_fixture().await).await.unwrap(), @r###"
_time,_subsort,_key_hash,_key,f1
1996-12-19T16:39:57.000000000,4964349264041216751,2359047937476779835,1,0
1996-12-19T16:40:57.000000000,4964349264041216752,2359047937476779835,1,1
1996-12-19T16:40:59.000000000,4964349264041216753,2359047937476779835,1,5
1996-12-19T16:41:57.000000000,4964349264041216754,2359047937476779835,1,
1996-12-19T16:42:57.000000000,4964349264041216755,2359047937476779835,1,15
1996-12-19T16:39:57.000000000,0,2359047937476779835,1,0
1996-12-19T16:40:57.000000000,0,2359047937476779835,1,1
1996-12-19T16:40:59.000000000,0,2359047937476779835,1,5
1996-12-19T16:41:57.000000000,0,2359047937476779835,1,
1996-12-19T16:42:57.000000000,0,2359047937476779835,1,15
"###);
}

#[tokio::test]
async fn test_get_static_key_second_field() {
insta::assert_snapshot!(QueryFixture::new("{ f2: Input.e0 | get(\"f2\") }").run_to_csv(&collection_data_fixture().await).await.unwrap(), @r###"
_time,_subsort,_key_hash,_key,f2
1996-12-19T16:39:57.000000000,4964349264041216751,2359047937476779835,1,22
1996-12-19T16:40:57.000000000,4964349264041216752,2359047937476779835,1,10
1996-12-19T16:40:59.000000000,4964349264041216753,2359047937476779835,1,3
1996-12-19T16:41:57.000000000,4964349264041216754,2359047937476779835,1,13
1996-12-19T16:42:57.000000000,4964349264041216755,2359047937476779835,1,
1996-12-19T16:39:57.000000000,0,2359047937476779835,1,22
1996-12-19T16:40:57.000000000,0,2359047937476779835,1,10
1996-12-19T16:40:59.000000000,0,2359047937476779835,1,3
1996-12-19T16:41:57.000000000,0,2359047937476779835,1,13
1996-12-19T16:42:57.000000000,0,2359047937476779835,1,
"###);
}

#[tokio::test]
async fn test_get_dynamic_key() {
insta::assert_snapshot!(QueryFixture::new("{ value: Input.e0 | get(Input.e3) }").run_to_csv(&collection_data_fixture().await).await.unwrap(), @r###"
_time,_subsort,_key_hash,_key,value
1996-12-19T16:39:57.000000000,4964349264041216751,2359047937476779835,1,0
1996-12-19T16:40:57.000000000,4964349264041216752,2359047937476779835,1,10
1996-12-19T16:40:59.000000000,4964349264041216753,2359047937476779835,1,
1996-12-19T16:41:57.000000000,4964349264041216754,2359047937476779835,1,13
1996-12-19T16:42:57.000000000,4964349264041216755,2359047937476779835,1,11
1996-12-19T16:39:57.000000000,0,2359047937476779835,1,0
1996-12-19T16:40:57.000000000,0,2359047937476779835,1,10
1996-12-19T16:40:59.000000000,0,2359047937476779835,1,
1996-12-19T16:41:57.000000000,0,2359047937476779835,1,13
1996-12-19T16:42:57.000000000,0,2359047937476779835,1,11
"###);
}

Expand Down
Binary file modified testdata/parquet/data_with_map.parquet
Binary file not shown.

0 comments on commit b217537

Please sign in to comment.