diff --git a/datafusion-cli/src/print_format.rs b/datafusion-cli/src/print_format.rs index 56bdb15a315d9..cfb8a32ffcfeb 100644 --- a/datafusion-cli/src/print_format.rs +++ b/datafusion-cli/src/print_format.rs @@ -247,12 +247,12 @@ mod tests { .with_schema(three_column_schema()) .with_batches(vec![]) .run(); - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" +---+---+---+ | a | b | c | +---+---+---+ +---+---+---+ - "#); + "); } #[test] @@ -262,11 +262,11 @@ mod tests { .with_batches(split_batch(three_column_batch())) .with_header(WithHeader::No) .run(); - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" 1,4,7 2,5,8 3,6,9 - "#); + "); } #[test] @@ -276,12 +276,12 @@ mod tests { .with_batches(split_batch(three_column_batch())) .with_header(WithHeader::Yes) .run(); - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" a,b,c 1,4,7 2,5,8 3,6,9 - "#); + "); } #[test] @@ -291,10 +291,10 @@ mod tests { .with_batches(split_batch(three_column_batch())) .with_header(WithHeader::No) .run(); - assert_snapshot!(output, @" - 1\t4\t7 - 2\t5\t8 - 3\t6\t9 + assert_snapshot!(output, @r" + 1 4 7 + 2 5 8 + 3 6 9 ") } @@ -305,11 +305,11 @@ mod tests { .with_batches(split_batch(three_column_batch())) .with_header(WithHeader::Yes) .run(); - assert_snapshot!(output, @" - a\tb\tc - 1\t4\t7 - 2\t5\t8 - 3\t6\t9 + assert_snapshot!(output, @r" + a b c + 1 4 7 + 2 5 8 + 3 6 9 "); } @@ -320,7 +320,7 @@ mod tests { .with_batches(split_batch(three_column_batch())) .with_header(WithHeader::Ignored) .run(); - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" +---+---+---+ | a | b | c | +---+---+---+ @@ -328,7 +328,7 @@ mod tests { | 2 | 5 | 8 | | 3 | 6 | 9 | +---+---+---+ - "#); + "); } #[test] fn print_json() { @@ -337,9 +337,7 @@ mod tests { .with_batches(split_batch(three_column_batch())) .with_header(WithHeader::Ignored) .run(); - assert_snapshot!(output, @r#" - [{"a":1,"b":4,"c":7},{"a":2,"b":5,"c":8},{"a":3,"b":6,"c":9}] - "#); + assert_snapshot!(output, @r#"[{"a":1,"b":4,"c":7},{"a":2,"b":5,"c":8},{"a":3,"b":6,"c":9}]"#); } #[test] @@ -363,11 +361,11 @@ mod tests { .with_batches(split_batch(three_column_batch())) .with_header(WithHeader::No) .run(); - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" 1,4,7 2,5,8 3,6,9 - "#); + "); } #[test] fn print_automatic_with_header() { @@ -376,12 +374,12 @@ mod tests { .with_batches(split_batch(three_column_batch())) .with_header(WithHeader::Yes) .run(); - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" a,b,c 1,4,7 2,5,8 3,6,9 - "#); + "); } #[test] @@ -396,7 +394,7 @@ mod tests { .with_maxrows(max_rows) .run(); allow_duplicates! { - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" +---+ | a | +---+ @@ -404,7 +402,7 @@ mod tests { | 2 | | 3 | +---+ - "#); + "); } } } @@ -416,7 +414,7 @@ mod tests { .with_batches(vec![one_column_batch()]) .with_maxrows(MaxRows::Limited(1)) .run(); - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" +---+ | a | +---+ @@ -425,7 +423,7 @@ mod tests { | . | | . | +---+ - "#); + "); } #[test] @@ -439,7 +437,7 @@ mod tests { ]) .with_maxrows(MaxRows::Limited(5)) .run(); - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" +---+ | a | +---+ @@ -452,7 +450,7 @@ mod tests { | . | | . | +---+ - "#); + "); } #[test] @@ -464,7 +462,7 @@ mod tests { .with_format(PrintFormat::Table) .with_batches(vec![empty_batch.clone(), batch, empty_batch]) .run(); - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" +---+ | a | +---+ @@ -472,7 +470,7 @@ mod tests { | 2 | | 3 | +---+ - "#); + "); } #[test] @@ -486,12 +484,12 @@ mod tests { .with_batches(vec![empty_batch]) .with_header(WithHeader::Yes) .run(); - assert_snapshot!(output, @r#" + assert_snapshot!(output, @r" +---+ | a | +---+ +---+ - "#); + "); // No output for empty batch when schema contains no columns let empty_batch = RecordBatch::new_empty(Arc::new(Schema::empty())); diff --git a/datafusion-cli/tests/snapshots/cli_explain_environment_overrides@explain_plan_environment_overrides.snap b/datafusion-cli/tests/snapshots/cli_explain_environment_overrides@explain_plan_environment_overrides.snap index 6b3a247dd7b82..1359cefbe71c7 100644 --- a/datafusion-cli/tests/snapshots/cli_explain_environment_overrides@explain_plan_environment_overrides.snap +++ b/datafusion-cli/tests/snapshots/cli_explain_environment_overrides@explain_plan_environment_overrides.snap @@ -7,7 +7,6 @@ info: - EXPLAIN SELECT 123 env: DATAFUSION_EXPLAIN_FORMAT: pgjson -snapshot_kind: text --- success: true exit_code: 0 diff --git a/datafusion-cli/tests/snapshots/cli_format@automatic.snap b/datafusion-cli/tests/snapshots/cli_format@automatic.snap index 2591f493e90a8..76b14d9a3a924 100644 --- a/datafusion-cli/tests/snapshots/cli_format@automatic.snap +++ b/datafusion-cli/tests/snapshots/cli_format@automatic.snap @@ -1,5 +1,5 @@ --- -source: tests/cli_integration.rs +source: datafusion-cli/tests/cli_integration.rs info: program: datafusion-cli args: diff --git a/datafusion-cli/tests/snapshots/cli_format@csv.snap b/datafusion-cli/tests/snapshots/cli_format@csv.snap index c41b042298eb0..2c969bd91d121 100644 --- a/datafusion-cli/tests/snapshots/cli_format@csv.snap +++ b/datafusion-cli/tests/snapshots/cli_format@csv.snap @@ -1,5 +1,5 @@ --- -source: tests/cli_integration.rs +source: datafusion-cli/tests/cli_integration.rs info: program: datafusion-cli args: diff --git a/datafusion-cli/tests/snapshots/cli_format@json.snap b/datafusion-cli/tests/snapshots/cli_format@json.snap index 8f804a337cce5..22a9cc4657a91 100644 --- a/datafusion-cli/tests/snapshots/cli_format@json.snap +++ b/datafusion-cli/tests/snapshots/cli_format@json.snap @@ -1,5 +1,5 @@ --- -source: tests/cli_integration.rs +source: datafusion-cli/tests/cli_integration.rs info: program: datafusion-cli args: diff --git a/datafusion-cli/tests/snapshots/cli_format@nd-json.snap b/datafusion-cli/tests/snapshots/cli_format@nd-json.snap index 7b4ce1e2530cf..513bcb7372ca6 100644 --- a/datafusion-cli/tests/snapshots/cli_format@nd-json.snap +++ b/datafusion-cli/tests/snapshots/cli_format@nd-json.snap @@ -1,5 +1,5 @@ --- -source: tests/cli_integration.rs +source: datafusion-cli/tests/cli_integration.rs info: program: datafusion-cli args: diff --git a/datafusion-cli/tests/snapshots/cli_format@table.snap b/datafusion-cli/tests/snapshots/cli_format@table.snap index 99914182462aa..8677847588385 100644 --- a/datafusion-cli/tests/snapshots/cli_format@table.snap +++ b/datafusion-cli/tests/snapshots/cli_format@table.snap @@ -1,5 +1,5 @@ --- -source: tests/cli_integration.rs +source: datafusion-cli/tests/cli_integration.rs info: program: datafusion-cli args: diff --git a/datafusion-cli/tests/snapshots/cli_format@tsv.snap b/datafusion-cli/tests/snapshots/cli_format@tsv.snap index 968268c31dd55..c56e60fcab155 100644 --- a/datafusion-cli/tests/snapshots/cli_format@tsv.snap +++ b/datafusion-cli/tests/snapshots/cli_format@tsv.snap @@ -1,5 +1,5 @@ --- -source: tests/cli_integration.rs +source: datafusion-cli/tests/cli_integration.rs info: program: datafusion-cli args: diff --git a/datafusion-cli/tests/snapshots/cli_quick_test@batch_size.snap b/datafusion-cli/tests/snapshots/cli_quick_test@batch_size.snap index c27d527df0b6a..9fd07fa6f4e1b 100644 --- a/datafusion-cli/tests/snapshots/cli_quick_test@batch_size.snap +++ b/datafusion-cli/tests/snapshots/cli_quick_test@batch_size.snap @@ -1,5 +1,5 @@ --- -source: tests/cli_integration.rs +source: datafusion-cli/tests/cli_integration.rs info: program: datafusion-cli args: diff --git a/datafusion-cli/tests/snapshots/cli_quick_test@default_explain_plan.snap b/datafusion-cli/tests/snapshots/cli_quick_test@default_explain_plan.snap index 46ee6be64f624..8620f6da84488 100644 --- a/datafusion-cli/tests/snapshots/cli_quick_test@default_explain_plan.snap +++ b/datafusion-cli/tests/snapshots/cli_quick_test@default_explain_plan.snap @@ -5,7 +5,6 @@ info: args: - "--command" - EXPLAIN SELECT 123 -snapshot_kind: text --- success: true exit_code: 0 diff --git a/datafusion-cli/tests/snapshots/cli_quick_test@files.snap b/datafusion-cli/tests/snapshots/cli_quick_test@files.snap index 7c44e41729a17..df3a10b6bb54b 100644 --- a/datafusion-cli/tests/snapshots/cli_quick_test@files.snap +++ b/datafusion-cli/tests/snapshots/cli_quick_test@files.snap @@ -1,5 +1,5 @@ --- -source: tests/cli_integration.rs +source: datafusion-cli/tests/cli_integration.rs info: program: datafusion-cli args: diff --git a/datafusion-cli/tests/snapshots/cli_quick_test@statements.snap b/datafusion-cli/tests/snapshots/cli_quick_test@statements.snap index 3b975bb6a927d..a394458768d1b 100644 --- a/datafusion-cli/tests/snapshots/cli_quick_test@statements.snap +++ b/datafusion-cli/tests/snapshots/cli_quick_test@statements.snap @@ -1,5 +1,5 @@ --- -source: tests/cli_integration.rs +source: datafusion-cli/tests/cli_integration.rs info: program: datafusion-cli args: diff --git a/datafusion/common/src/dfschema.rs b/datafusion/common/src/dfschema.rs index 668e72c759826..55a031d870122 100644 --- a/datafusion/common/src/dfschema.rs +++ b/datafusion/common/src/dfschema.rs @@ -2070,7 +2070,7 @@ mod tests { fn test_print_schema_empty() { let schema = DFSchema::empty(); let output = schema.tree_string(); - insta::assert_snapshot!(output, @r###"root"###); + insta::assert_snapshot!(output, @"root"); } #[test] diff --git a/datafusion/core/src/datasource/file_format/avro.rs b/datafusion/core/src/datasource/file_format/avro.rs index b287b1ef3a4e9..cad35d43db486 100644 --- a/datafusion/core/src/datasource/file_format/avro.rs +++ b/datafusion/core/src/datasource/file_format/avro.rs @@ -117,20 +117,20 @@ mod tests { let batches = collect(exec, task_ctx).await?; assert_eq!(batches.len(), 1); - assert_snapshot!(batches_to_string(&batches),@r###" - +----+----------+-------------+--------------+---------+------------+-----------+------------+------------------+------------+---------------------+ - | id | bool_col | tinyint_col | smallint_col | int_col | bigint_col | float_col | double_col | date_string_col | string_col | timestamp_col | - +----+----------+-------------+--------------+---------+------------+-----------+------------+------------------+------------+---------------------+ - | 4 | true | 0 | 0 | 0 | 0 | 0.0 | 0.0 | 30332f30312f3039 | 30 | 2009-03-01T00:00:00 | - | 5 | false | 1 | 1 | 1 | 10 | 1.1 | 10.1 | 30332f30312f3039 | 31 | 2009-03-01T00:01:00 | - | 6 | true | 0 | 0 | 0 | 0 | 0.0 | 0.0 | 30342f30312f3039 | 30 | 2009-04-01T00:00:00 | - | 7 | false | 1 | 1 | 1 | 10 | 1.1 | 10.1 | 30342f30312f3039 | 31 | 2009-04-01T00:01:00 | - | 2 | true | 0 | 0 | 0 | 0 | 0.0 | 0.0 | 30322f30312f3039 | 30 | 2009-02-01T00:00:00 | - | 3 | false | 1 | 1 | 1 | 10 | 1.1 | 10.1 | 30322f30312f3039 | 31 | 2009-02-01T00:01:00 | - | 0 | true | 0 | 0 | 0 | 0 | 0.0 | 0.0 | 30312f30312f3039 | 30 | 2009-01-01T00:00:00 | - | 1 | false | 1 | 1 | 1 | 10 | 1.1 | 10.1 | 30312f30312f3039 | 31 | 2009-01-01T00:01:00 | - +----+----------+-------------+--------------+---------+------------+-----------+------------+------------------+------------+---------------------+ - "###); + assert_snapshot!(batches_to_string(&batches),@r" + +----+----------+-------------+--------------+---------+------------+-----------+------------+------------------+------------+---------------------+ + | id | bool_col | tinyint_col | smallint_col | int_col | bigint_col | float_col | double_col | date_string_col | string_col | timestamp_col | + +----+----------+-------------+--------------+---------+------------+-----------+------------+------------------+------------+---------------------+ + | 4 | true | 0 | 0 | 0 | 0 | 0.0 | 0.0 | 30332f30312f3039 | 30 | 2009-03-01T00:00:00 | + | 5 | false | 1 | 1 | 1 | 10 | 1.1 | 10.1 | 30332f30312f3039 | 31 | 2009-03-01T00:01:00 | + | 6 | true | 0 | 0 | 0 | 0 | 0.0 | 0.0 | 30342f30312f3039 | 30 | 2009-04-01T00:00:00 | + | 7 | false | 1 | 1 | 1 | 10 | 1.1 | 10.1 | 30342f30312f3039 | 31 | 2009-04-01T00:01:00 | + | 2 | true | 0 | 0 | 0 | 0 | 0.0 | 0.0 | 30322f30312f3039 | 30 | 2009-02-01T00:00:00 | + | 3 | false | 1 | 1 | 1 | 10 | 1.1 | 10.1 | 30322f30312f3039 | 31 | 2009-02-01T00:01:00 | + | 0 | true | 0 | 0 | 0 | 0 | 0.0 | 0.0 | 30312f30312f3039 | 30 | 2009-01-01T00:00:00 | + | 1 | false | 1 | 1 | 1 | 10 | 1.1 | 10.1 | 30312f30312f3039 | 31 | 2009-01-01T00:01:00 | + +----+----------+-------------+--------------+---------+------------+-----------+------------+------------------+------------+---------------------+ + "); Ok(()) } diff --git a/datafusion/core/src/datasource/file_format/csv.rs b/datafusion/core/src/datasource/file_format/csv.rs index 4b855ba582652..ddbf81079651f 100644 --- a/datafusion/core/src/datasource/file_format/csv.rs +++ b/datafusion/core/src/datasource/file_format/csv.rs @@ -621,15 +621,15 @@ mod tests { .collect() .await?; - assert_snapshot!(batches_to_string(&record_batch), @r###" - +----+------+ - | c2 | c3 | - +----+------+ - | 5 | 36 | - | 5 | -31 | - | 5 | -101 | - +----+------+ - "###); + assert_snapshot!(batches_to_string(&record_batch), @r" + +----+------+ + | c2 | c3 | + +----+------+ + | 5 | 36 | + | 5 | -31 | + | 5 | -101 | + +----+------+ + "); Ok(()) } @@ -736,13 +736,13 @@ mod tests { let query_result = ctx.sql(query).await?.collect().await?; let actual_partitions = count_query_csv_partitions(&ctx, query).await?; - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r###" + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r" +--------------+ | sum(aggr.c2) | +--------------+ | 285 | +--------------+ - "###); + "); } assert_eq!(n_partitions, actual_partitions); @@ -775,13 +775,13 @@ mod tests { let query_result = ctx.sql(query).await?.collect().await?; let actual_partitions = count_query_csv_partitions(&ctx, query).await?; - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r###" + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r" +--------------+ | sum(aggr.c3) | +--------------+ | 781 | +--------------+ - "###); + "); } assert_eq!(1, actual_partitions); // Compressed csv won't be scanned in parallel @@ -812,13 +812,13 @@ mod tests { let query_result = ctx.sql(query).await?.collect().await?; let actual_partitions = count_query_csv_partitions(&ctx, query).await?; - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r###" + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r" +--------------+ | sum(aggr.c3) | +--------------+ | 781 | +--------------+ - "###); + "); } assert_eq!(1, actual_partitions); // csv won't be scanned in parallel when newlines_in_values is set @@ -843,10 +843,10 @@ mod tests { let query = "select * from empty where random() > 0.5;"; let query_result = ctx.sql(query).await?.collect().await?; - assert_snapshot!(batches_to_string(&query_result),@r###" - ++ - ++ - "###); + assert_snapshot!(batches_to_string(&query_result),@r" + ++ + ++ + "); Ok(()) } @@ -868,10 +868,10 @@ mod tests { let query = "select * from empty where random() > 0.5;"; let query_result = ctx.sql(query).await?.collect().await?; - assert_snapshot!(batches_to_string(&query_result),@r###" - ++ - ++ - "###); + assert_snapshot!(batches_to_string(&query_result),@r" + ++ + ++ + "); Ok(()) } @@ -1036,10 +1036,10 @@ mod tests { let query = "select * from empty where random() > 0.5;"; let query_result = ctx.sql(query).await?.collect().await?; - assert_snapshot!(batches_to_string(&query_result),@r###" - ++ - ++ - "###); + assert_snapshot!(batches_to_string(&query_result),@r" + ++ + ++ + "); Ok(()) } @@ -1088,13 +1088,13 @@ mod tests { let query_result = ctx.sql(query).await?.collect().await?; let actual_partitions = count_query_csv_partitions(&ctx, query).await?; - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r###" - +---------------------+ - | sum(empty.column_1) | - +---------------------+ - | 10 | - +---------------------+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r" + +---------------------+ + | sum(empty.column_1) | + +---------------------+ + | 10 | + +---------------------+ + ");} assert_eq!(n_partitions, actual_partitions); // Won't get partitioned if all files are empty @@ -1136,13 +1136,13 @@ mod tests { file_size }; - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r###" + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r" +-----------------------+ | sum(one_col.column_1) | +-----------------------+ | 50 | +-----------------------+ - "###); + "); } assert_eq!(expected_partitions, actual_partitions); @@ -1175,13 +1175,13 @@ mod tests { let query_result = ctx.sql(query).await?.collect().await?; let actual_partitions = count_query_csv_partitions(&ctx, query).await?; - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r###" - +---------------+ - | sum_of_5_cols | - +---------------+ - | 15 | - +---------------+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&query_result),@r" + +---------------+ + | sum_of_5_cols | + +---------------+ + | 15 | + +---------------+ + ");} assert_eq!(n_partitions, actual_partitions); diff --git a/datafusion/core/src/datasource/file_format/json.rs b/datafusion/core/src/datasource/file_format/json.rs index 1d20d458ede0a..4d5ed34399693 100644 --- a/datafusion/core/src/datasource/file_format/json.rs +++ b/datafusion/core/src/datasource/file_format/json.rs @@ -218,13 +218,13 @@ mod tests { let result = ctx.sql(query).await?.collect().await?; let actual_partitions = count_num_partitions(&ctx, query).await?; - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&result),@r###" - +----------------------+ - | sum(json_parallel.a) | - +----------------------+ - | -7 | - +----------------------+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&result),@r" + +----------------------+ + | sum(json_parallel.a) | + +----------------------+ + | -7 | + +----------------------+ + ");} assert_eq!(n_partitions, actual_partitions); @@ -249,10 +249,10 @@ mod tests { let result = ctx.sql(query).await?.collect().await?; - assert_snapshot!(batches_to_string(&result),@r###" - ++ - ++ - "###); + assert_snapshot!(batches_to_string(&result),@r" + ++ + ++ + "); Ok(()) } @@ -284,15 +284,15 @@ mod tests { } assert_eq!(deserializer.next()?, DeserializerOutput::InputExhausted); - assert_snapshot!(batches_to_string(&[all_batches]),@r###" - +----+----+----+----+----+ - | c1 | c2 | c3 | c4 | c5 | - +----+----+----+----+----+ - | 1 | 2 | 3 | 4 | 5 | - | 6 | 7 | 8 | 9 | 10 | - | 11 | 12 | 13 | 14 | 15 | - +----+----+----+----+----+ - "###); + assert_snapshot!(batches_to_string(&[all_batches]),@r" + +----+----+----+----+----+ + | c1 | c2 | c3 | c4 | c5 | + +----+----+----+----+----+ + | 1 | 2 | 3 | 4 | 5 | + | 6 | 7 | 8 | 9 | 10 | + | 11 | 12 | 13 | 14 | 15 | + +----+----+----+----+----+ + "); Ok(()) } @@ -324,14 +324,14 @@ mod tests { } assert_eq!(deserializer.next()?, DeserializerOutput::RequiresMoreData); - insta::assert_snapshot!(fmt_batches(&[all_batches]),@r###" - +----+----+----+----+----+ - | c1 | c2 | c3 | c4 | c5 | - +----+----+----+----+----+ - | 1 | 2 | 3 | 4 | 5 | - | 6 | 7 | 8 | 9 | 10 | - +----+----+----+----+----+ - "###); + insta::assert_snapshot!(fmt_batches(&[all_batches]),@r" + +----+----+----+----+----+ + | c1 | c2 | c3 | c4 | c5 | + +----+----+----+----+----+ + | 1 | 2 | 3 | 4 | 5 | + | 6 | 7 | 8 | 9 | 10 | + +----+----+----+----+----+ + "); Ok(()) } diff --git a/datafusion/core/src/datasource/file_format/parquet.rs b/datafusion/core/src/datasource/file_format/parquet.rs index 050212bc6b846..44cf09c1ae46e 100644 --- a/datafusion/core/src/datasource/file_format/parquet.rs +++ b/datafusion/core/src/datasource/file_format/parquet.rs @@ -1206,10 +1206,10 @@ mod tests { let result = df.collect().await?; - assert_snapshot!(batches_to_string(&result), @r###" - ++ - ++ - "###); + assert_snapshot!(batches_to_string(&result), @r" + ++ + ++ + "); Ok(()) } @@ -1235,10 +1235,10 @@ mod tests { let result = df.collect().await?; - assert_snapshot!(batches_to_string(&result), @r###" - ++ - ++ - "###); + assert_snapshot!(batches_to_string(&result), @r" + ++ + ++ + "); Ok(()) } diff --git a/datafusion/core/src/datasource/listing/table.rs b/datafusion/core/src/datasource/listing/table.rs index 7f957108cf787..e205cec115504 100644 --- a/datafusion/core/src/datasource/listing/table.rs +++ b/datafusion/core/src/datasource/listing/table.rs @@ -875,13 +875,13 @@ mod tests { let res = collect(plan, session_ctx.task_ctx()).await?; // Insert returns the number of rows written, in our case this would be 6. - insta::allow_duplicates! {insta::assert_snapshot!(batches_to_string(&res),@r###" - +-------+ - | count | - +-------+ - | 20 | - +-------+ - "###);} + insta::allow_duplicates! {insta::assert_snapshot!(batches_to_string(&res),@r" + +-------+ + | count | + +-------+ + | 20 | + +-------+ + ");} // Read the records in the table let batches = session_ctx @@ -890,13 +890,13 @@ mod tests { .collect() .await?; - insta::allow_duplicates! {insta::assert_snapshot!(batches_to_string(&batches),@r###" - +-------+ - | count | - +-------+ - | 20 | - +-------+ - "###);} + insta::allow_duplicates! {insta::assert_snapshot!(batches_to_string(&batches),@r" + +-------+ + | count | + +-------+ + | 20 | + +-------+ + ");} // Assert that `target_partition_number` many files were added to the table. let num_files = tmp_dir.path().read_dir()?.count(); @@ -911,13 +911,13 @@ mod tests { // Again, execute the physical plan and collect the results let res = collect(plan, session_ctx.task_ctx()).await?; - insta::allow_duplicates! {insta::assert_snapshot!(batches_to_string(&res),@r###" - +-------+ - | count | - +-------+ - | 20 | - +-------+ - "###);} + insta::allow_duplicates! {insta::assert_snapshot!(batches_to_string(&res),@r" + +-------+ + | count | + +-------+ + | 20 | + +-------+ + ");} // Read the contents of the table let batches = session_ctx @@ -926,13 +926,13 @@ mod tests { .collect() .await?; - insta::allow_duplicates! {insta::assert_snapshot!(batches_to_string(&batches),@r###" - +-------+ - | count | - +-------+ - | 40 | - +-------+ - "###);} + insta::allow_duplicates! {insta::assert_snapshot!(batches_to_string(&batches),@r" + +-------+ + | count | + +-------+ + | 40 | + +-------+ + ");} // Assert that another `target_partition_number` many files were added to the table. let num_files = tmp_dir.path().read_dir()?.count(); @@ -990,15 +990,15 @@ mod tests { .collect() .await?; - insta::allow_duplicates! {insta::assert_snapshot!(batches_to_string(&batches),@r###" - +-----+-----+---+ - | a | b | c | - +-----+-----+---+ - | foo | bar | 1 | - | foo | bar | 2 | - | foo | bar | 3 | - +-----+-----+---+ - "###);} + insta::allow_duplicates! {insta::assert_snapshot!(batches_to_string(&batches),@r" + +-----+-----+---+ + | a | b | c | + +-----+-----+---+ + | foo | bar | 1 | + | foo | bar | 2 | + | foo | bar | 3 | + +-----+-----+---+ + ");} Ok(()) } diff --git a/datafusion/core/src/datasource/mod.rs b/datafusion/core/src/datasource/mod.rs index 7d37ef8cf24aa..a6989a3cc5afc 100644 --- a/datafusion/core/src/datasource/mod.rs +++ b/datafusion/core/src/datasource/mod.rs @@ -140,13 +140,13 @@ mod tests { let task_ctx = session_ctx.task_ctx(); let read = collect(parquet_exec, task_ctx).await.unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&read),@r###" + insta::assert_snapshot!(batches_to_sort_string(&read),@r" +----+--------------+ | id | extra_column | +----+--------------+ | 1 | foo | +----+--------------+ - "###); + "); } #[test] diff --git a/datafusion/core/src/datasource/physical_plan/avro.rs b/datafusion/core/src/datasource/physical_plan/avro.rs index 4f8fc6d0b9717..2954a47403299 100644 --- a/datafusion/core/src/datasource/physical_plan/avro.rs +++ b/datafusion/core/src/datasource/physical_plan/avro.rs @@ -105,20 +105,20 @@ mod tests { .expect("plan iterator empty") .expect("plan iterator returned an error"); - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch]), @r###" - +----+----------+-------------+ - | id | bool_col | tinyint_col | - +----+----------+-------------+ - | 4 | true | 0 | - | 5 | false | 1 | - | 6 | true | 0 | - | 7 | false | 1 | - | 2 | true | 0 | - | 3 | false | 1 | - | 0 | true | 0 | - | 1 | false | 1 | - +----+----------+-------------+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch]), @r" + +----+----------+-------------+ + | id | bool_col | tinyint_col | + +----+----------+-------------+ + | 4 | true | 0 | + | 5 | false | 1 | + | 6 | true | 0 | + | 7 | false | 1 | + | 2 | true | 0 | + | 3 | false | 1 | + | 0 | true | 0 | + | 1 | false | 1 | + +----+----------+-------------+ + ");} let batch = results.next().await; assert!(batch.is_none()); @@ -178,20 +178,20 @@ mod tests { .expect("plan iterator empty") .expect("plan iterator returned an error"); - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch]), @r###" - +----+----------+-------------+-------------+ - | id | bool_col | tinyint_col | missing_col | - +----+----------+-------------+-------------+ - | 4 | true | 0 | | - | 5 | false | 1 | | - | 6 | true | 0 | | - | 7 | false | 1 | | - | 2 | true | 0 | | - | 3 | false | 1 | | - | 0 | true | 0 | | - | 1 | false | 1 | | - +----+----------+-------------+-------------+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch]), @r" + +----+----------+-------------+-------------+ + | id | bool_col | tinyint_col | missing_col | + +----+----------+-------------+-------------+ + | 4 | true | 0 | | + | 5 | false | 1 | | + | 6 | true | 0 | | + | 7 | false | 1 | | + | 2 | true | 0 | | + | 3 | false | 1 | | + | 0 | true | 0 | | + | 1 | false | 1 | | + +----+----------+-------------+-------------+ + ");} let batch = results.next().await; assert!(batch.is_none()); @@ -255,20 +255,20 @@ mod tests { .expect("plan iterator empty") .expect("plan iterator returned an error"); - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch]), @r###" - +----+----------+------------+-------------+ - | id | bool_col | date | tinyint_col | - +----+----------+------------+-------------+ - | 4 | true | 2021-10-26 | 0 | - | 5 | false | 2021-10-26 | 1 | - | 6 | true | 2021-10-26 | 0 | - | 7 | false | 2021-10-26 | 1 | - | 2 | true | 2021-10-26 | 0 | - | 3 | false | 2021-10-26 | 1 | - | 0 | true | 2021-10-26 | 0 | - | 1 | false | 2021-10-26 | 1 | - +----+----------+------------+-------------+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch]), @r" + +----+----------+------------+-------------+ + | id | bool_col | date | tinyint_col | + +----+----------+------------+-------------+ + | 4 | true | 2021-10-26 | 0 | + | 5 | false | 2021-10-26 | 1 | + | 6 | true | 2021-10-26 | 0 | + | 7 | false | 2021-10-26 | 1 | + | 2 | true | 2021-10-26 | 0 | + | 3 | false | 2021-10-26 | 1 | + | 0 | true | 2021-10-26 | 0 | + | 1 | false | 2021-10-26 | 1 | + +----+----------+------------+-------------+ + ");} let batch = results.next().await; assert!(batch.is_none()); diff --git a/datafusion/core/src/datasource/physical_plan/csv.rs b/datafusion/core/src/datasource/physical_plan/csv.rs index 892ae5b58635d..cfdf98413845c 100644 --- a/datafusion/core/src/datasource/physical_plan/csv.rs +++ b/datafusion/core/src/datasource/physical_plan/csv.rs @@ -142,17 +142,17 @@ mod tests { assert_eq!(3, batch.num_columns()); assert_eq!(100, batch.num_rows()); - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch.slice(0, 5)]), @r###" - +----+-----+------------+ - | c1 | c3 | c5 | - +----+-----+------------+ - | c | 1 | 2033001162 | - | d | -40 | 706441268 | - | b | 29 | 994303988 | - | a | -85 | 1171968280 | - | b | -82 | 1824882165 | - +----+-----+------------+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch.slice(0, 5)]), @r" + +----+-----+------------+ + | c1 | c3 | c5 | + +----+-----+------------+ + | c | 1 | 2033001162 | + | d | -40 | 706441268 | + | b | 29 | 994303988 | + | a | -85 | 1171968280 | + | b | -82 | 1824882165 | + +----+-----+------------+ + ");} Ok(()) } @@ -213,17 +213,17 @@ mod tests { assert_eq!(3, batch.num_columns()); assert_eq!(100, batch.num_rows()); - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch.slice(0, 5)]), @r###" - +------------+----+-----+ - | c5 | c1 | c3 | - +------------+----+-----+ - | 2033001162 | c | 1 | - | 706441268 | d | -40 | - | 994303988 | b | 29 | - | 1171968280 | a | -85 | - | 1824882165 | b | -82 | - +------------+----+-----+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch.slice(0, 5)]), @r" + +------------+----+-----+ + | c5 | c1 | c3 | + +------------+----+-----+ + | 2033001162 | c | 1 | + | 706441268 | d | -40 | + | 994303988 | b | 29 | + | 1171968280 | a | -85 | + | 1824882165 | b | -82 | + +------------+----+-----+ + ");} Ok(()) } @@ -285,17 +285,17 @@ mod tests { assert_eq!(13, batch.num_columns()); assert_eq!(5, batch.num_rows()); - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch]), @r###" - +----+----+-----+--------+------------+----------------------+-----+-------+------------+----------------------+-------------+---------------------+--------------------------------+ - | c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 | c10 | c11 | c12 | c13 | - +----+----+-----+--------+------------+----------------------+-----+-------+------------+----------------------+-------------+---------------------+--------------------------------+ - | c | 2 | 1 | 18109 | 2033001162 | -6513304855495910254 | 25 | 43062 | 1491205016 | 5863949479783605708 | 0.110830784 | 0.9294097332465232 | 6WfVFBVGJSQb7FhA7E0lBwdvjfZnSW | - | d | 5 | -40 | 22614 | 706441268 | -7542719935673075327 | 155 | 14337 | 3373581039 | 11720144131976083864 | 0.69632107 | 0.3114712539863804 | C2GT5KVyOPZpgKVl110TyZO0NcJ434 | - | b | 1 | 29 | -18218 | 994303988 | 5983957848665088916 | 204 | 9489 | 3275293996 | 14857091259186476033 | 0.53840446 | 0.17909035118828576 | AyYVExXK6AR2qUTxNZ7qRHQOVGMLcz | - | a | 1 | -85 | -15154 | 1171968280 | 1919439543497968449 | 77 | 52286 | 774637006 | 12101411955859039553 | 0.12285209 | 0.6864391962767343 | 0keZ5G8BffGwgF2RwQD59TFzMStxCB | - | b | 5 | -82 | 22080 | 1824882165 | 7373730676428214987 | 208 | 34331 | 3342719438 | 3330177516592499461 | 0.82634634 | 0.40975383525297016 | Ig1QcuKsjHXkproePdERo2w0mYzIqd | - +----+----+-----+--------+------------+----------------------+-----+-------+------------+----------------------+-------------+---------------------+--------------------------------+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch]), @r" + +----+----+-----+--------+------------+----------------------+-----+-------+------------+----------------------+-------------+---------------------+--------------------------------+ + | c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 | c10 | c11 | c12 | c13 | + +----+----+-----+--------+------------+----------------------+-----+-------+------------+----------------------+-------------+---------------------+--------------------------------+ + | c | 2 | 1 | 18109 | 2033001162 | -6513304855495910254 | 25 | 43062 | 1491205016 | 5863949479783605708 | 0.110830784 | 0.9294097332465232 | 6WfVFBVGJSQb7FhA7E0lBwdvjfZnSW | + | d | 5 | -40 | 22614 | 706441268 | -7542719935673075327 | 155 | 14337 | 3373581039 | 11720144131976083864 | 0.69632107 | 0.3114712539863804 | C2GT5KVyOPZpgKVl110TyZO0NcJ434 | + | b | 1 | 29 | -18218 | 994303988 | 5983957848665088916 | 204 | 9489 | 3275293996 | 14857091259186476033 | 0.53840446 | 0.17909035118828576 | AyYVExXK6AR2qUTxNZ7qRHQOVGMLcz | + | a | 1 | -85 | -15154 | 1171968280 | 1919439543497968449 | 77 | 52286 | 774637006 | 12101411955859039553 | 0.12285209 | 0.6864391962767343 | 0keZ5G8BffGwgF2RwQD59TFzMStxCB | + | b | 5 | -82 | 22080 | 1824882165 | 7373730676428214987 | 208 | 34331 | 3342719438 | 3330177516592499461 | 0.82634634 | 0.40975383525297016 | Ig1QcuKsjHXkproePdERo2w0mYzIqd | + +----+----+-----+--------+------------+----------------------+-----+-------+------------+----------------------+-------------+---------------------+--------------------------------+ + ");} Ok(()) } @@ -431,17 +431,17 @@ mod tests { assert_eq!(2, batch.num_columns()); assert_eq!(100, batch.num_rows()); - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch.slice(0, 5)]), @r###" - +----+------------+ - | c1 | date | - +----+------------+ - | c | 2021-10-26 | - | d | 2021-10-26 | - | b | 2021-10-26 | - | a | 2021-10-26 | - | b | 2021-10-26 | - +----+------------+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&[batch.slice(0, 5)]), @r" + +----+------------+ + | c1 | date | + +----+------------+ + | c | 2021-10-26 | + | d | 2021-10-26 | + | b | 2021-10-26 | + | a | 2021-10-26 | + | b | 2021-10-26 | + +----+------------+ + ");} let metrics = csv.metrics().expect("doesn't found metrics"); let time_elapsed_processing = get_value(&metrics, "time_elapsed_processing"); @@ -576,14 +576,14 @@ mod tests { let result = df.collect().await.unwrap(); - assert_snapshot!(batches_to_string(&result), @r###" - +---+---+ - | a | b | - +---+---+ - | 1 | 2 | - | 3 | 4 | - +---+---+ - "###); + assert_snapshot!(batches_to_string(&result), @r" + +---+---+ + | a | b | + +---+---+ + | 1 | 2 | + | 3 | 4 | + +---+---+ + "); } #[tokio::test] @@ -605,14 +605,14 @@ mod tests { let result = df.collect().await.unwrap(); - assert_snapshot!(batches_to_string(&result),@r###" - +---+---+ - | a | b | - +---+---+ - | 1 | 2 | - | 3 | 4 | - +---+---+ - "###); + assert_snapshot!(batches_to_string(&result),@r" + +---+---+ + | a | b | + +---+---+ + | 1 | 2 | + | 3 | 4 | + +---+---+ + "); let e = session_ctx .read_csv("memory:///", CsvReadOptions::new().terminator(Some(b'\n'))) @@ -645,16 +645,16 @@ mod tests { .await?; let df = ctx.sql(r#"select * from t1"#).await?.collect().await?; - assert_snapshot!(batches_to_string(&df),@r###" - +------+--------+ - | col1 | col2 | - +------+--------+ - | id0 | value0 | - | id1 | value1 | - | id2 | value2 | - | id3 | value3 | - +------+--------+ - "###); + assert_snapshot!(batches_to_string(&df),@r" + +------+--------+ + | col1 | col2 | + +------+--------+ + | id0 | value0 | + | id1 | value1 | + | id2 | value2 | + | id3 | value3 | + +------+--------+ + "); Ok(()) } diff --git a/datafusion/core/src/datasource/physical_plan/json.rs b/datafusion/core/src/datasource/physical_plan/json.rs index 922d13fa1759b..8de6a60258f08 100644 --- a/datafusion/core/src/datasource/physical_plan/json.rs +++ b/datafusion/core/src/datasource/physical_plan/json.rs @@ -142,16 +142,16 @@ mod tests { let frame = ctx.read_json(path, read_options).await.unwrap(); let results = frame.collect().await.unwrap(); - insta::allow_duplicates! {assert_snapshot!(batches_to_string(&results), @r###" - +-----+------------------+---------------+------+ - | a | b | c | d | - +-----+------------------+---------------+------+ - | 1 | [2.0, 1.3, -6.1] | [false, true] | 4 | - | -10 | [2.0, 1.3, -6.1] | [true, true] | 4 | - | 2 | [2.0, , -6.1] | [false, ] | text | - | | | | | - +-----+------------------+---------------+------+ - "###);} + insta::allow_duplicates! {assert_snapshot!(batches_to_string(&results), @r" + +-----+------------------+---------------+------+ + | a | b | c | d | + +-----+------------------+---------------+------+ + | 1 | [2.0, 1.3, -6.1] | [false, true] | 4 | + | -10 | [2.0, 1.3, -6.1] | [true, true] | 4 | + | 2 | [2.0, , -6.1] | [false, ] | text | + | | | | | + +-----+------------------+---------------+------+ + ");} Ok(()) } diff --git a/datafusion/core/src/datasource/physical_plan/parquet.rs b/datafusion/core/src/datasource/physical_plan/parquet.rs index 4613561c666e9..abcd6bcf2e0c1 100644 --- a/datafusion/core/src/datasource/physical_plan/parquet.rs +++ b/datafusion/core/src/datasource/physical_plan/parquet.rs @@ -337,13 +337,13 @@ mod tests { .await; let batches = rt.batches.unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&batches),@r###" + insta::assert_snapshot!(batches_to_sort_string(&batches),@r" +----+----+ | c1 | c2 | +----+----+ | 1 | | +----+----+ - "###); + "); let metrics = rt.parquet_exec.metrics().unwrap(); let metric = get_value(&metrics, "pushdown_rows_pruned"); @@ -395,13 +395,13 @@ mod tests { .await; let batches = rt.batches.unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&batches),@r###" + insta::assert_snapshot!(batches_to_sort_string(&batches),@r" +----+----+ | c1 | c2 | +----+----+ | 1 | | +----+----+ - "###); + "); let metrics = rt.parquet_exec.metrics().unwrap(); let metric = get_value(&metrics, "pushdown_rows_pruned"); @@ -457,13 +457,13 @@ mod tests { .await; let batches = rt.batches.unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&batches),@r###" + insta::assert_snapshot!(batches_to_sort_string(&batches),@r" +----+----+----+ | c1 | c2 | c3 | +----+----+----+ | 1 | | 7 | +----+----+----+ - "###); + "); let metrics = rt.parquet_exec.metrics().unwrap(); let metric = get_value(&metrics, "pushdown_rows_pruned"); @@ -519,13 +519,13 @@ mod tests { .await; let batches = rt.batches.unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&batches),@r###" + insta::assert_snapshot!(batches_to_sort_string(&batches),@r" +----+----+----+ | c1 | c2 | c3 | +----+----+----+ | | | 7 | +----+----+----+ - "###); + "); let metrics = rt.parquet_exec.metrics().unwrap(); let metric = get_value(&metrics, "pushdown_rows_pruned"); @@ -568,13 +568,13 @@ mod tests { let batches = rt.batches.unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&batches),@r###" + insta::assert_snapshot!(batches_to_sort_string(&batches),@r" +----+----+----+ | c1 | c2 | c3 | +----+----+----+ | 1 | | 10 | +----+----+----+ - "###); + "); let metrics = rt.parquet_exec.metrics().unwrap(); let metric = get_value(&metrics, "pushdown_rows_pruned"); @@ -598,7 +598,7 @@ mod tests { let batches = rt.batches.unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&batches),@r###" + insta::assert_snapshot!(batches_to_sort_string(&batches),@r" +----+----+----+ | c1 | c2 | c3 | +----+----+----+ @@ -606,7 +606,7 @@ mod tests { | 4 | | 40 | | 5 | | 50 | +----+----+----+ - "###); + "); let metrics = rt.parquet_exec.metrics().unwrap(); let metric = get_value(&metrics, "pushdown_rows_pruned"); @@ -635,7 +635,7 @@ mod tests { .await .unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&read), @r###" + insta::assert_snapshot!(batches_to_sort_string(&read), @r" +-----+----+----+ | c1 | c2 | c3 | +-----+----+----+ @@ -649,7 +649,7 @@ mod tests { | bar | | | | bar | | | +-----+----+----+ - "###); + "); } #[tokio::test] @@ -750,18 +750,18 @@ mod tests { .await .unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&read),@r###" - +-----+----+----+ - | c1 | c3 | c2 | - +-----+----+----+ - | | | | - | | 10 | 1 | - | | 20 | | - | | 20 | 2 | - | Foo | 10 | | - | bar | | | - +-----+----+----+ - "###); + insta::assert_snapshot!(batches_to_sort_string(&read),@r" + +-----+----+----+ + | c1 | c3 | c2 | + +-----+----+----+ + | | | | + | | 10 | 1 | + | | 20 | | + | | 20 | 2 | + | Foo | 10 | | + | bar | | | + +-----+----+----+ + "); } #[tokio::test] @@ -782,14 +782,14 @@ mod tests { .round_trip(vec![batch1, batch2]) .await; - insta::assert_snapshot!(batches_to_sort_string(&rt.batches.unwrap()), @r###" + insta::assert_snapshot!(batches_to_sort_string(&rt.batches.unwrap()), @r" +----+----+----+ | c1 | c3 | c2 | +----+----+----+ | | 10 | 1 | | | 20 | 2 | +----+----+----+ - "###); + "); let metrics = rt.parquet_exec.metrics().unwrap(); // Note there are were 6 rows in total (across three batches) assert_eq!(get_value(&metrics, "pushdown_rows_pruned"), 4); @@ -825,7 +825,7 @@ mod tests { .await .unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&read), @r###" + insta::assert_snapshot!(batches_to_sort_string(&read), @r" +-----+-----+ | c1 | c4 | +-----+-----+ @@ -836,7 +836,7 @@ mod tests { | bar | | | bar | | +-----+-----+ - "###); + "); } #[tokio::test] @@ -1049,18 +1049,18 @@ mod tests { // In a real query where this predicate was pushed down from a filter stage instead of created directly in the `DataSourceExec`, // the filter stage would be preserved as a separate execution plan stage so the actual query results would be as expected. - insta::assert_snapshot!(batches_to_sort_string(&read),@r###" - +-----+----+ - | c1 | c2 | - +-----+----+ - | | | - | | | - | | 1 | - | | 2 | - | Foo | | - | bar | | - +-----+----+ - "###); + insta::assert_snapshot!(batches_to_sort_string(&read),@r" + +-----+----+ + | c1 | c2 | + +-----+----+ + | | | + | | | + | | 1 | + | | 2 | + | Foo | | + | bar | | + +-----+----+ + "); } #[tokio::test] @@ -1085,13 +1085,13 @@ mod tests { .round_trip(vec![batch1, batch2]) .await; - insta::assert_snapshot!(batches_to_sort_string(&rt.batches.unwrap()), @r###" + insta::assert_snapshot!(batches_to_sort_string(&rt.batches.unwrap()), @r" +----+----+ | c1 | c2 | +----+----+ | | 1 | +----+----+ - "###); + "); let metrics = rt.parquet_exec.metrics().unwrap(); // Note there are were 6 rows in total (across three batches) assert_eq!(get_value(&metrics, "pushdown_rows_pruned"), 5); @@ -1145,7 +1145,7 @@ mod tests { .round_trip(vec![batch1, batch2, batch3, batch4]) .await; - insta::assert_snapshot!(batches_to_sort_string(&rt.batches.unwrap()), @r###" + insta::assert_snapshot!(batches_to_sort_string(&rt.batches.unwrap()), @r" +------+----+ | c1 | c2 | +------+----+ @@ -1162,7 +1162,7 @@ mod tests { | Foo2 | | | Foo3 | | +------+----+ - "###); + "); let metrics = rt.parquet_exec.metrics().unwrap(); // There are 4 rows pruned in each of batch2, batch3, and @@ -1194,14 +1194,14 @@ mod tests { .await .unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&read),@r###" - +-----+----+ - | c1 | c2 | - +-----+----+ - | Foo | 1 | - | bar | | - +-----+----+ - "###); + insta::assert_snapshot!(batches_to_sort_string(&read),@r" + +-----+----+ + | c1 | c2 | + +-----+----+ + | Foo | 1 | + | bar | | + +-----+----+ + "); } #[tokio::test] @@ -1224,15 +1224,15 @@ mod tests { .await .unwrap(); - insta::assert_snapshot!(batches_to_sort_string(&read),@r###" - +-----+----+ - | c1 | c2 | - +-----+----+ - | | 2 | - | Foo | 1 | - | bar | | - +-----+----+ - "###); + insta::assert_snapshot!(batches_to_sort_string(&read),@r" + +-----+----+ + | c1 | c2 | + +-----+----+ + | | 2 | + | Foo | 1 | + | bar | | + +-----+----+ + "); } #[tokio::test] @@ -1682,20 +1682,20 @@ mod tests { let batch = results.next().await.unwrap()?; assert_eq!(batch.schema().as_ref(), &expected_schema); - assert_snapshot!(batches_to_string(&[batch]),@r###" - +----+----------+-------------+-------+-----+ - | id | bool_col | tinyint_col | month | day | - +----+----------+-------------+-------+-----+ - | 4 | true | 0 | 10 | 26 | - | 5 | false | 1 | 10 | 26 | - | 6 | true | 0 | 10 | 26 | - | 7 | false | 1 | 10 | 26 | - | 2 | true | 0 | 10 | 26 | - | 3 | false | 1 | 10 | 26 | - | 0 | true | 0 | 10 | 26 | - | 1 | false | 1 | 10 | 26 | - +----+----------+-------------+-------+-----+ - "###); + assert_snapshot!(batches_to_string(&[batch]),@r" + +----+----------+-------------+-------+-----+ + | id | bool_col | tinyint_col | month | day | + +----+----------+-------------+-------+-----+ + | 4 | true | 0 | 10 | 26 | + | 5 | false | 1 | 10 | 26 | + | 6 | true | 0 | 10 | 26 | + | 7 | false | 1 | 10 | 26 | + | 2 | true | 0 | 10 | 26 | + | 3 | false | 1 | 10 | 26 | + | 0 | true | 0 | 10 | 26 | + | 1 | false | 1 | 10 | 26 | + +----+----------+-------------+-------+-----+ + "); let batch = results.next().await; assert!(batch.is_none()); @@ -1767,14 +1767,14 @@ mod tests { let metrics = rt.parquet_exec.metrics().unwrap(); - assert_snapshot!(batches_to_sort_string(&rt.batches.unwrap()),@r###" - +-----+ - | int | - +-----+ - | 4 | - | 5 | - +-----+ - "###); + assert_snapshot!(batches_to_sort_string(&rt.batches.unwrap()),@r" + +-----+ + | int | + +-----+ + | 4 | + | 5 | + +-----+ + "); let (page_index_pruned, page_index_matched) = get_pruning_metric(&metrics, "page_index_rows_pruned"); assert_eq!(page_index_pruned, 4); @@ -1820,14 +1820,14 @@ mod tests { let metrics = rt.parquet_exec.metrics().unwrap(); // assert the batches and some metrics - assert_snapshot!(batches_to_string(&rt.batches.unwrap()),@r###" - +-----+ - | c1 | - +-----+ - | Foo | - | zzz | - +-----+ - "###); + assert_snapshot!(batches_to_string(&rt.batches.unwrap()),@r" + +-----+ + | c1 | + +-----+ + | Foo | + | zzz | + +-----+ + "); // pushdown predicates have eliminated all 4 bar rows and the // null row for 5 rows total @@ -1938,16 +1938,16 @@ mod tests { let metrics = rt.parquet_exec.metrics().unwrap(); // Verify the result rows - assert_snapshot!(batches_to_string(&rt.batches.unwrap()),@r###" - +-----+----+ - | c1 | c2 | - +-----+----+ - | baz | 20 | - | foo | 12 | - | baz | 25 | - | qux | 30 | - +-----+----+ - "###); + assert_snapshot!(batches_to_string(&rt.batches.unwrap()),@r" + +-----+----+ + | c1 | c2 | + +-----+----+ + | baz | 20 | + | foo | 12 | + | baz | 25 | + | qux | 30 | + +-----+----+ + "); // Verify metrics - this is the key test let pushdown_rows_matched = get_value(&metrics, "pushdown_rows_matched"); @@ -2210,13 +2210,13 @@ mod tests { let sql = "select * from base_table where name='test02'"; let batch = ctx.sql(sql).await.unwrap().collect().await.unwrap(); assert_eq!(batch.len(), 1); - insta::assert_snapshot!(batches_to_string(&batch),@r###" - +---------------------+----+--------+ - | struct | id | name | - +---------------------+----+--------+ - | {id: 4, name: aaa2} | 2 | test02 | - +---------------------+----+--------+ - "###); + insta::assert_snapshot!(batches_to_string(&batch),@r" + +---------------------+----+--------+ + | struct | id | name | + +---------------------+----+--------+ + | {id: 4, name: aaa2} | 2 | test02 | + +---------------------+----+--------+ + "); Ok(()) } @@ -2239,13 +2239,13 @@ mod tests { let sql = "select * from base_table where name='test02'"; let batch = ctx.sql(sql).await.unwrap().collect().await.unwrap(); assert_eq!(batch.len(), 1); - insta::assert_snapshot!(batches_to_string(&batch),@r###" - +---------------------+----+--------+ - | struct | id | name | - +---------------------+----+--------+ - | {id: 4, name: aaa2} | 2 | test02 | - +---------------------+----+--------+ - "###); + insta::assert_snapshot!(batches_to_string(&batch),@r" + +---------------------+----+--------+ + | struct | id | name | + +---------------------+----+--------+ + | {id: 4, name: aaa2} | 2 | test02 | + +---------------------+----+--------+ + "); Ok(()) } diff --git a/datafusion/core/src/datasource/view_test.rs b/datafusion/core/src/datasource/view_test.rs index 7227294ba1f1c..35418d6dea632 100644 --- a/datafusion/core/src/datasource/view_test.rs +++ b/datafusion/core/src/datasource/view_test.rs @@ -46,13 +46,13 @@ mod tests { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&results),@r###" + insta::assert_snapshot!(batches_to_string(&results),@r" +---+ | b | +---+ | 2 | +---+ - "###); + "); Ok(()) } @@ -96,14 +96,14 @@ mod tests { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&results),@r###" + insta::assert_snapshot!(batches_to_string(&results),@r" +---------+---------+---------+ | column1 | column2 | column3 | +---------+---------+---------+ | 1 | 2 | 3 | | 4 | 5 | 6 | +---------+---------+---------+ - "###); + "); let view_sql = "CREATE VIEW replace_xyz AS SELECT * REPLACE (column1*2 as column1) FROM xyz"; @@ -115,14 +115,14 @@ mod tests { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&results),@r###" + insta::assert_snapshot!(batches_to_string(&results),@r" +---------+---------+---------+ | column1 | column2 | column3 | +---------+---------+---------+ | 2 | 2 | 3 | | 8 | 5 | 6 | +---------+---------+---------+ - "###); + "); Ok(()) } @@ -146,14 +146,14 @@ mod tests { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&results),@r###" + insta::assert_snapshot!(batches_to_string(&results),@r" +---------------+ | column1_alias | +---------------+ | 1 | | 4 | +---------------+ - "###); + "); Ok(()) } @@ -177,14 +177,14 @@ mod tests { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&results),@r###" + insta::assert_snapshot!(batches_to_string(&results),@r" +---------------+---------------+ | column2_alias | column1_alias | +---------------+---------------+ | 2 | 1 | | 5 | 4 | +---------------+---------------+ - "###); + "); Ok(()) } @@ -213,14 +213,14 @@ mod tests { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&results),@r###" + insta::assert_snapshot!(batches_to_string(&results),@r" +---------+ | column1 | +---------+ | 1 | | 4 | +---------+ - "###); + "); Ok(()) } @@ -249,13 +249,13 @@ mod tests { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&results),@r###" + insta::assert_snapshot!(batches_to_string(&results),@r" +---------+ | column1 | +---------+ | 4 | +---------+ - "###); + "); Ok(()) } @@ -287,14 +287,14 @@ mod tests { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&results),@r###" + insta::assert_snapshot!(batches_to_string(&results),@r" +---------+---------+---------+ | column2 | column1 | column3 | +---------+---------+---------+ | 2 | 1 | 3 | | 5 | 4 | 6 | +---------+---------+---------+ - "###); + "); Ok(()) } @@ -445,14 +445,14 @@ mod tests { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&results),@r###" + insta::assert_snapshot!(batches_to_string(&results),@r" +---------+ | column1 | +---------+ | 1 | | 4 | +---------+ - "###); + "); Ok(()) } diff --git a/datafusion/core/tests/dataframe/mod.rs b/datafusion/core/tests/dataframe/mod.rs index c87e9fa7ab3b5..7b5e853465a92 100644 --- a/datafusion/core/tests/dataframe/mod.rs +++ b/datafusion/core/tests/dataframe/mod.rs @@ -413,14 +413,14 @@ async fn select_with_periods() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +------+ | f.c1 | +------+ | 1 | | 10 | +------+ - "### + " ); Ok(()) @@ -568,14 +568,14 @@ async fn drop_with_quotes() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r#" +------+ | f"c2 | +------+ | 11 | | 2 | +------+ - "### + "# ); Ok(()) @@ -600,14 +600,14 @@ async fn drop_with_periods() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +------+ | f.c2 | +------+ | 11 | | 2 | +------+ - "### + " ); Ok(()) @@ -744,23 +744,23 @@ async fn test_aggregate_with_pk() -> Result<()> { assert_snapshot!( physical_plan_to_string(&df).await, - @r###" + @r" AggregateExec: mode=Single, gby=[id@0 as id, name@1 as name], aggr=[] DataSourceExec: partitions=1, partition_sizes=[1] - "### + " ); let df_results = df.collect().await?; assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+------+ | id | name | +----+------+ | 1 | a | +----+------+ - "### + " ); Ok(()) @@ -798,13 +798,13 @@ async fn test_aggregate_with_pk2() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+------+ | id | name | +----+------+ | 1 | a | +----+------+ - "### + " ); Ok(()) @@ -846,13 +846,13 @@ async fn test_aggregate_with_pk3() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+------+ | id | name | +----+------+ | 1 | a | +----+------+ - "### + " ); Ok(()) @@ -894,13 +894,13 @@ async fn test_aggregate_with_pk4() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+ | id | +----+ | 1 | +----+ - "### + " ); Ok(()) @@ -922,7 +922,7 @@ async fn test_aggregate_alias() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+ | c2 | +----+ @@ -932,7 +932,7 @@ async fn test_aggregate_alias() -> Result<()> { | 5 | | 6 | +----+ - "### + " ); Ok(()) @@ -969,7 +969,7 @@ async fn test_aggregate_with_union() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+------------+ | c1 | sum_result | +----+------------+ @@ -979,7 +979,7 @@ async fn test_aggregate_with_union() -> Result<()> { | d | 126 | | e | 121 | +----+------------+ - "### + " ); Ok(()) } @@ -1005,7 +1005,7 @@ async fn test_aggregate_subexpr() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----------------+------+ | c2 + Int32(10) | sum | +----------------+------+ @@ -1015,7 +1015,7 @@ async fn test_aggregate_subexpr() -> Result<()> { | 15 | 95 | | 16 | -146 | +----------------+------+ - "### + " ); Ok(()) @@ -1038,7 +1038,7 @@ async fn test_aggregate_name_collision() -> Result<()> { // The select expr has the same display_name as the group_expr, // but since they are different expressions, it should fail. .expect_err("Expected error"); - assert_snapshot!(df.strip_backtrace(), @r###"Schema error: No field named aggregate_test_100.c2. Valid fields are "aggregate_test_100.c2 + aggregate_test_100.c3"."###); + assert_snapshot!(df.strip_backtrace(), @r#"Schema error: No field named aggregate_test_100.c2. Valid fields are "aggregate_test_100.c2 + aggregate_test_100.c3"."#); Ok(()) } @@ -1097,7 +1097,7 @@ async fn window_using_aggregates() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df), - @r###" + @r" +-------------+----------+-----------------+---------------+--------+-----+------+----+------+ | first_value | last_val | approx_distinct | approx_median | median | max | min | c2 | c3 | +-------------+----------+-----------------+---------------+--------+-----+------+----+------+ @@ -1123,7 +1123,7 @@ async fn window_using_aggregates() -> Result<()> { | -85 | 65 | 17 | -17 | -18 | 83 | -101 | 5 | -101 | | -85 | 83 | 5 | -25 | -25 | 83 | -85 | 2 | -48 | +-------------+----------+-----------------+---------------+--------+-----+------+----+------+ - "### + " ); Ok(()) @@ -1190,7 +1190,7 @@ async fn window_aggregates_with_filter() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +---------+---------+---------+---------+---------+----+-----+ | sum_pos | avg_pos | min_pos | max_pos | cnt_pos | ts | val | +---------+---------+---------+---------+---------+----+-----+ @@ -1200,7 +1200,7 @@ async fn window_aggregates_with_filter() -> Result<()> { | 5 | 2.5 | 1 | 4 | 2 | 4 | 4 | | 5 | 2.5 | 1 | 4 | 2 | 5 | -1 | +---------+---------+---------+---------+---------+----+-----+ - "### + " ); Ok(()) @@ -1256,7 +1256,7 @@ async fn test_distinct_sort_by() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+ | c1 | +----+ @@ -1266,7 +1266,7 @@ async fn test_distinct_sort_by() -> Result<()> { | d | | e | +----+ - "### + " ); Ok(()) @@ -1304,7 +1304,7 @@ async fn test_distinct_on() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+ | c1 | +----+ @@ -1314,7 +1314,7 @@ async fn test_distinct_on() -> Result<()> { | d | | e | +----+ - "### + " ); Ok(()) @@ -1339,7 +1339,7 @@ async fn test_distinct_on_sort_by() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+ | c1 | +----+ @@ -1349,7 +1349,7 @@ async fn test_distinct_on_sort_by() -> Result<()> { | d | | e | +----+ - "### + " ); Ok(()) @@ -1413,13 +1413,13 @@ async fn join_coercion_unnamed() -> Result<()> { assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----+------+ | id | name | +----+------+ | 10 | d | +----+------+ - "### + " ); Ok(()) } @@ -1438,13 +1438,13 @@ async fn join_on() -> Result<()> { [col("a.c1").not_eq(col("b.c1")), col("a.c2").eq(col("b.c2"))], )?; - assert_snapshot!(join.logical_plan(), @r###" + assert_snapshot!(join.logical_plan(), @r" Inner Join: Filter: a.c1 != b.c1 AND a.c2 = b.c2 Projection: a.c1, a.c2 TableScan: a Projection: b.c1, b.c2 TableScan: b - "###); + "); Ok(()) } @@ -1467,7 +1467,11 @@ async fn join_on_filter_datatype() -> Result<()> { let err = join.into_optimized_plan().unwrap_err(); assert_snapshot!( err.strip_backtrace(), - @"type_coercion\ncaused by\nError during planning: Join condition must be boolean type, but got Utf8" + @r" + type_coercion + caused by + Error during planning: Join condition must be boolean type, but got Utf8 + " ); Ok(()) } @@ -1664,7 +1668,7 @@ async fn register_table() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+-----------------------------+ | c1 | sum(aggregate_test_100.c12) | +----+-----------------------------+ @@ -1674,13 +1678,13 @@ async fn register_table() -> Result<()> { | d | 8.793968289758968 | | e | 10.206140546981722 | +----+-----------------------------+ - "### + " ); // the results are the same as the results from the view, modulo the leaf table name assert_snapshot!( batches_to_sort_string(table_results), - @r###" + @r" +----+---------------------+ | c1 | sum(test_table.c12) | +----+---------------------+ @@ -1690,7 +1694,7 @@ async fn register_table() -> Result<()> { | d | 8.793968289758968 | | e | 10.206140546981722 | +----+---------------------+ - "### + " ); Ok(()) } @@ -1739,7 +1743,7 @@ async fn with_column() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+----+-----+-----+ | c1 | c2 | c3 | sum | +----+----+-----+-----+ @@ -1750,7 +1754,7 @@ async fn with_column() -> Result<()> { | a | 3 | 14 | 17 | | a | 3 | 17 | 20 | +----+----+-----+-----+ - "### + " ); // check that col with the same name overwritten @@ -1762,7 +1766,7 @@ async fn with_column() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results_overwrite), - @r###" + @r" +-----+----+-----+-----+ | c1 | c2 | c3 | sum | +-----+----+-----+-----+ @@ -1773,7 +1777,7 @@ async fn with_column() -> Result<()> { | 17 | 3 | 14 | 17 | | 20 | 3 | 17 | 20 | +-----+----+-----+-----+ - "### + " ); // check that col with the same name overwritten using same name as reference @@ -1785,7 +1789,7 @@ async fn with_column() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results_overwrite_self), - @r###" + @r" +----+----+-----+-----+ | c1 | c2 | c3 | sum | +----+----+-----+-----+ @@ -1796,7 +1800,7 @@ async fn with_column() -> Result<()> { | a | 4 | 14 | 17 | | a | 4 | 17 | 20 | +----+----+-----+-----+ - "### + " ); Ok(()) @@ -1824,14 +1828,14 @@ async fn test_window_function_with_column() -> Result<()> { let df_results = df.clone().collect().await?; assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+----+-----+-----+---+ | c1 | c2 | c3 | s | r | +----+----+-----+-----+---+ | c | 2 | 1 | 3 | 1 | | d | 5 | -40 | -35 | 2 | +----+----+-----+-----+---+ - "### + " ); Ok(()) @@ -1866,13 +1870,13 @@ async fn with_column_join_same_columns() -> Result<()> { let df_results = df.clone().collect().await?; assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+----+ | c1 | c1 | +----+----+ | a | a | +----+----+ - "### + " ); let df_with_column = df.clone().with_column("new_column", lit(true))?; @@ -1895,7 +1899,7 @@ async fn with_column_join_same_columns() -> Result<()> { assert_snapshot!( df_with_column.clone().into_optimized_plan().unwrap(), - @r###" + @r" Projection: t1.c1, t2.c1, Boolean(true) AS new_column Sort: t1.c1 ASC NULLS FIRST, fetch=1 Inner Join: t1.c1 = t2.c1 @@ -1903,20 +1907,20 @@ async fn with_column_join_same_columns() -> Result<()> { TableScan: aggregate_test_100 projection=[c1] SubqueryAlias: t2 TableScan: aggregate_test_100 projection=[c1] - "### + " ); let df_results = df_with_column.collect().await?; assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+----+------------+ | c1 | c1 | new_column | +----+----+------------+ | a | a | true | +----+----+------------+ - "### + " ); Ok(()) @@ -1966,13 +1970,13 @@ async fn with_column_renamed() -> Result<()> { assert_snapshot!( batches_to_sort_string(batches), - @r###" + @r" +-----+-----+-----+-------+ | one | two | c3 | total | +-----+-----+-----+-------+ | a | 3 | -72 | -69 | +-----+-----+-----+-------+ - "### + " ); Ok(()) @@ -2037,13 +2041,13 @@ async fn with_column_renamed_join() -> Result<()> { let df_results = df.clone().collect().await?; assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+----+-----+----+----+-----+ | c1 | c2 | c3 | c1 | c2 | c3 | +----+----+-----+----+----+-----+ | a | 1 | -85 | a | 1 | -85 | +----+----+-----+----+----+-----+ - "### + " ); let df_renamed = df.clone().with_column_renamed("t1.c1", "AAA")?; @@ -2066,7 +2070,7 @@ async fn with_column_renamed_join() -> Result<()> { assert_snapshot!( df_renamed.clone().into_optimized_plan().unwrap(), - @r###" + @r" Projection: t1.c1 AS AAA, t1.c2, t1.c3, t2.c1, t2.c2, t2.c3 Sort: t1.c1 ASC NULLS FIRST, t1.c2 ASC NULLS FIRST, t1.c3 ASC NULLS FIRST, t2.c1 ASC NULLS FIRST, t2.c2 ASC NULLS FIRST, t2.c3 ASC NULLS FIRST, fetch=1 Inner Join: t1.c1 = t2.c1 @@ -2074,20 +2078,20 @@ async fn with_column_renamed_join() -> Result<()> { TableScan: aggregate_test_100 projection=[c1, c2, c3] SubqueryAlias: t2 TableScan: aggregate_test_100 projection=[c1, c2, c3] - "### + " ); let df_results = df_renamed.collect().await?; assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +-----+----+-----+----+----+-----+ | AAA | c2 | c3 | c1 | c2 | c3 | +-----+----+-----+----+----+-----+ | a | 1 | -85 | a | 1 | -85 | +-----+----+-----+----+----+-----+ - "### + " ); Ok(()) @@ -2122,13 +2126,13 @@ async fn with_column_renamed_case_sensitive() -> Result<()> { assert_snapshot!( batches_to_sort_string(res), - @r###" + @r" +---------+ | CoLuMn1 | +---------+ | a | +---------+ - "### + " ); let df_renamed = df_renamed @@ -2138,13 +2142,13 @@ async fn with_column_renamed_case_sensitive() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_renamed), - @r###" + @r" +----+ | c1 | +----+ | a | +----+ - "### + " ); Ok(()) @@ -2182,19 +2186,19 @@ async fn describe_lookup_via_quoted_identifier() -> Result<()> { .await?; assert_snapshot!( batches_to_sort_string(&describe_result.clone().collect().await?), - @r###" - +------------+--------------+ - | describe | CoLu.Mn["1"] | - +------------+--------------+ - | count | 1 | - | max | a | - | mean | null | - | median | null | - | min | a | - | null_count | 0 | - | std | null | - +------------+--------------+ - "### + @r#" + +------------+--------------+ + | describe | CoLu.Mn["1"] | + +------------+--------------+ + | count | 1 | + | max | a | + | mean | null | + | median | null | + | min | a | + | null_count | 0 | + | std | null | + +------------+--------------+ + "# ); Ok(()) @@ -2212,13 +2216,13 @@ async fn cast_expr_test() -> Result<()> { df.clone().show().await?; assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +----+----+-----+ | c2 | c3 | sum | +----+----+-----+ | 2 | 1 | 3 | +----+----+-----+ - "### + " ); Ok(()) @@ -2280,14 +2284,14 @@ async fn with_column_name() -> Result<()> { assert_snapshot!( batches_to_sort_string(&df_results), - @r###" + @r" +------+-------+ | f.c1 | f.c2 | +------+-------+ | 1 | hello | | 10 | hello | +------+-------+ - "### + " ); Ok(()) @@ -2323,13 +2327,13 @@ async fn cache_test() -> Result<()> { let cached_df_results = cached_df.collect().await?; assert_snapshot!( batches_to_sort_string(&cached_df_results), - @r###" + @r" +----+----+-----+ | c2 | c3 | sum | +----+----+-----+ | 2 | 1 | 3 | +----+----+-----+ - "### + " ); assert_eq!(&df_results, &cached_df_results); @@ -2349,13 +2353,13 @@ async fn cache_producer_test() -> Result<()> { assert_snapshot!( cached_df.clone().into_optimized_plan().unwrap(), - @r###" + @r" CacheNode Projection: aggregate_test_100.c2, aggregate_test_100.c3, CAST(CAST(aggregate_test_100.c2 AS Int64) + CAST(aggregate_test_100.c3 AS Int64) AS Int64) AS sum Projection: aggregate_test_100.c2, aggregate_test_100.c3 Limit: skip=0, fetch=1 TableScan: aggregate_test_100, fetch=1 - "### + " ); Ok(()) } @@ -2629,13 +2633,13 @@ async fn filtered_aggr_with_param_values() -> Result<()> { let df_results = df?.collect().await?; assert_snapshot!( batches_to_string(&df_results), - @r###" + @r" +------------------------------------------------+ | count(table1.c2) FILTER (WHERE table1.c3 > $1) | +------------------------------------------------+ | 54 | +------------------------------------------------+ - "### + " ); Ok(()) @@ -2683,7 +2687,7 @@ async fn write_parquet_with_order() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +---+---+ | a | b | +---+---+ @@ -2693,7 +2697,7 @@ async fn write_parquet_with_order() -> Result<()> { | 5 | 3 | | 7 | 4 | +---+---+ - "### + " ); Ok(()) @@ -2741,7 +2745,7 @@ async fn write_csv_with_order() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +---+---+ | a | b | +---+---+ @@ -2751,7 +2755,7 @@ async fn write_csv_with_order() -> Result<()> { | 5 | 3 | | 7 | 4 | +---+---+ - "### + " ); Ok(()) } @@ -2798,7 +2802,7 @@ async fn write_json_with_order() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +---+---+ | a | b | +---+---+ @@ -2808,7 +2812,7 @@ async fn write_json_with_order() -> Result<()> { | 5 | 3 | | 7 | 4 | +---+---+ - "### + " ); Ok(()) } @@ -2857,7 +2861,7 @@ async fn write_table_with_order() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +-----------+ | tablecol1 | +-----------+ @@ -2867,7 +2871,7 @@ async fn write_table_with_order() -> Result<()> { | x | | z | +-----------+ - "### + " ); Ok(()) } @@ -3176,7 +3180,7 @@ async fn union_with_mix_of_presorted_and_explicitly_resorted_inputs_with_reparti -> Result<()> { assert_snapshot!( union_with_mix_of_presorted_and_explicitly_resorted_inputs_impl(true).await?, - @r#" + @r" AggregateExec: mode=Final, gby=[id@0 as id], aggr=[], ordering_mode=Sorted SortPreservingMergeExec: [id@0 ASC NULLS LAST] AggregateExec: mode=Partial, gby=[id@0 as id], aggr=[], ordering_mode=Sorted @@ -3184,7 +3188,7 @@ async fn union_with_mix_of_presorted_and_explicitly_resorted_inputs_with_reparti DataSourceExec: file_groups={1 group: [[{testdata}/alltypes_tiny_pages.parquet]]}, projection=[id], output_ordering=[id@0 ASC NULLS LAST], file_type=parquet SortExec: expr=[id@0 ASC NULLS LAST], preserve_partitioning=[false] DataSourceExec: file_groups={1 group: [[{testdata}/alltypes_tiny_pages.parquet]]}, projection=[id], file_type=parquet - "#); + "); Ok(()) } @@ -3269,7 +3273,7 @@ async fn test_count_wildcard_on_aggregate() -> Result<()> { assert_snapshot!( pretty_format_batches(&sql_results).unwrap(), - @r###" + @r" +---------------+-----------------------------------------------------+ | plan_type | plan | +---------------+-----------------------------------------------------+ @@ -3280,7 +3284,7 @@ async fn test_count_wildcard_on_aggregate() -> Result<()> { | | PlaceholderRowExec | | | | +---------------+-----------------------------------------------------+ - "### + " ); // add `.select(vec![count_wildcard()])?` to make sure we can analyze all node instead of just top node. @@ -3490,7 +3494,7 @@ async fn sort_on_unprojected_columns() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +-----+ | a | +-----+ @@ -3499,7 +3503,7 @@ async fn sort_on_unprojected_columns() -> Result<()> { | 10 | | 1 | +-----+ - "### + " ); Ok(()) @@ -3537,7 +3541,7 @@ async fn sort_on_distinct_columns() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +-----+ | a | +-----+ @@ -3545,7 +3549,7 @@ async fn sort_on_distinct_columns() -> Result<()> { | 10 | | 1 | +-----+ - "### + " ); Ok(()) } @@ -3676,14 +3680,14 @@ async fn filter_with_alias_overwrite() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +------+ | a | +------+ | true | | true | +------+ - "### + " ); Ok(()) @@ -3712,7 +3716,7 @@ async fn select_with_alias_overwrite() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +-------+ | a | +-------+ @@ -3721,7 +3725,7 @@ async fn select_with_alias_overwrite() -> Result<()> { | true | | false | +-------+ - "### + " ); Ok(()) @@ -3747,7 +3751,7 @@ async fn test_grouping_sets() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +-----------+-----+---------------+ | a | b | count(test.a) | +-----------+-----+---------------+ @@ -3763,7 +3767,7 @@ async fn test_grouping_sets() -> Result<()> { | 123AbcDef | | 1 | | 123AbcDef | 100 | 1 | +-----------+-----+---------------+ - "### + " ); Ok(()) @@ -3790,7 +3794,7 @@ async fn test_grouping_sets_count() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +----+----+-----------------+ | c1 | c2 | count(Int32(1)) | +----+----+-----------------+ @@ -3805,7 +3809,7 @@ async fn test_grouping_sets_count() -> Result<()> { | b | | 19 | | a | | 21 | +----+----+-----------------+ - "### + " ); Ok(()) @@ -3839,7 +3843,7 @@ async fn test_grouping_set_array_agg_with_overflow() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +----+----+--------+---------------------+ | c1 | c2 | sum_c3 | avg_c3 | +----+----+--------+---------------------+ @@ -3879,7 +3883,7 @@ async fn test_grouping_set_array_agg_with_overflow() -> Result<()> { | a | 2 | -46 | -15.333333333333334 | | a | 1 | -88 | -17.6 | +----+----+--------+---------------------+ - "### + " ); Ok(()) @@ -3916,25 +3920,25 @@ async fn join_with_alias_filter() -> Result<()> { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" + @r" Projection: t1.a, t2.a, t1.b, t1.c, t2.b, t2.c [a:UInt32, a:UInt32, b:Utf8, c:Int32, b:Utf8, c:Int32] Inner Join: t1.a + UInt32(3) = t2.a + UInt32(1) [a:UInt32, b:Utf8, c:Int32, a:UInt32, b:Utf8, c:Int32] TableScan: t1 projection=[a, b, c] [a:UInt32, b:Utf8, c:Int32] TableScan: t2 projection=[a, b, c] [a:UInt32, b:Utf8, c:Int32] - "### + " ); let results = df.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----+----+---+----+---+---+ | a | a | b | c | b | c | +----+----+---+----+---+---+ | 1 | 3 | a | 10 | a | 1 | | 11 | 13 | c | 30 | c | 3 | +----+----+---+----+---+---+ - "### + " ); Ok(()) @@ -3961,27 +3965,27 @@ async fn right_semi_with_alias_filter() -> Result<()> { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" + @r" RightSemi Join: t1.a = t2.a [a:UInt32, b:Utf8, c:Int32] Projection: t1.a [a:UInt32] Filter: t1.c > Int32(1) [a:UInt32, c:Int32] TableScan: t1 projection=[a, c] [a:UInt32, c:Int32] Filter: t2.c > Int32(1) [a:UInt32, b:Utf8, c:Int32] TableScan: t2 projection=[a, b, c] [a:UInt32, b:Utf8, c:Int32] - "### + " ); let results = df.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +-----+---+---+ | a | b | c | +-----+---+---+ | 10 | b | 2 | | 100 | d | 4 | +-----+---+---+ - "### + " ); Ok(()) @@ -4008,26 +4012,26 @@ async fn right_anti_filter_push_down() -> Result<()> { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" + @r" RightAnti Join: t1.a = t2.a Filter: t2.c > Int32(1) [a:UInt32, b:Utf8, c:Int32] Projection: t1.a [a:UInt32] Filter: t1.c > Int32(1) [a:UInt32, c:Int32] TableScan: t1 projection=[a, c] [a:UInt32, c:Int32] TableScan: t2 projection=[a, b, c] [a:UInt32, b:Utf8, c:Int32] - "### + " ); let results = df.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----+---+---+ | a | b | c | +----+---+---+ | 13 | c | 3 | | 3 | a | 1 | +----+---+---+ - "### + " ); Ok(()) @@ -4040,37 +4044,37 @@ async fn unnest_columns() -> Result<()> { let results = df.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" - +----------+---------------------------------+--------------------------+ - | shape_id | points | tags | - +----------+---------------------------------+--------------------------+ - | 1 | [{x: 5, y: -8}, {x: -3, y: -4}] | [tag1] | - | 2 | [{x: 6, y: 2}, {x: -2, y: -8}] | [tag1] | - | 3 | [{x: -9, y: -7}, {x: -2, y: 5}] | [tag1, tag2, tag3, tag4] | - | 4 | | [tag1, tag2, tag3] | - +----------+---------------------------------+--------------------------+ - "###); + @r" + +----------+---------------------------------+--------------------------+ + | shape_id | points | tags | + +----------+---------------------------------+--------------------------+ + | 1 | [{x: 5, y: -8}, {x: -3, y: -4}] | [tag1] | + | 2 | [{x: 6, y: 2}, {x: -2, y: -8}] | [tag1] | + | 3 | [{x: -9, y: -7}, {x: -2, y: 5}] | [tag1, tag2, tag3, tag4] | + | 4 | | [tag1, tag2, tag3] | + +----------+---------------------------------+--------------------------+ + "); // Unnest tags let df = table_with_nested_types(NUM_ROWS).await?; let results = df.unnest_columns(&["tags"])?.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" - +----------+---------------------------------+------+ - | shape_id | points | tags | - +----------+---------------------------------+------+ - | 1 | [{x: 5, y: -8}, {x: -3, y: -4}] | tag1 | - | 2 | [{x: 6, y: 2}, {x: -2, y: -8}] | tag1 | - | 3 | [{x: -9, y: -7}, {x: -2, y: 5}] | tag1 | - | 3 | [{x: -9, y: -7}, {x: -2, y: 5}] | tag2 | - | 3 | [{x: -9, y: -7}, {x: -2, y: 5}] | tag3 | - | 3 | [{x: -9, y: -7}, {x: -2, y: 5}] | tag4 | - | 4 | | tag1 | - | 4 | | tag2 | - | 4 | | tag3 | - +----------+---------------------------------+------+ - "###); + @r" + +----------+---------------------------------+------+ + | shape_id | points | tags | + +----------+---------------------------------+------+ + | 1 | [{x: 5, y: -8}, {x: -3, y: -4}] | tag1 | + | 2 | [{x: 6, y: 2}, {x: -2, y: -8}] | tag1 | + | 3 | [{x: -9, y: -7}, {x: -2, y: 5}] | tag1 | + | 3 | [{x: -9, y: -7}, {x: -2, y: 5}] | tag2 | + | 3 | [{x: -9, y: -7}, {x: -2, y: 5}] | tag3 | + | 3 | [{x: -9, y: -7}, {x: -2, y: 5}] | tag4 | + | 4 | | tag1 | + | 4 | | tag2 | + | 4 | | tag3 | + +----------+---------------------------------+------+ + "); // Test aggregate results for tags. let df = table_with_nested_types(NUM_ROWS).await?; @@ -4082,19 +4086,19 @@ async fn unnest_columns() -> Result<()> { let results = df.unnest_columns(&["points"])?.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" - +----------+----------------+--------------------------+ - | shape_id | points | tags | - +----------+----------------+--------------------------+ - | 1 | {x: -3, y: -4} | [tag1] | - | 1 | {x: 5, y: -8} | [tag1] | - | 2 | {x: -2, y: -8} | [tag1] | - | 2 | {x: 6, y: 2} | [tag1] | - | 3 | {x: -2, y: 5} | [tag1, tag2, tag3, tag4] | - | 3 | {x: -9, y: -7} | [tag1, tag2, tag3, tag4] | - | 4 | | [tag1, tag2, tag3] | - +----------+----------------+--------------------------+ - "###); + @r" + +----------+----------------+--------------------------+ + | shape_id | points | tags | + +----------+----------------+--------------------------+ + | 1 | {x: -3, y: -4} | [tag1] | + | 1 | {x: 5, y: -8} | [tag1] | + | 2 | {x: -2, y: -8} | [tag1] | + | 2 | {x: 6, y: 2} | [tag1] | + | 3 | {x: -2, y: 5} | [tag1, tag2, tag3, tag4] | + | 3 | {x: -9, y: -7} | [tag1, tag2, tag3, tag4] | + | 4 | | [tag1, tag2, tag3] | + +----------+----------------+--------------------------+ + "); // Test aggregate results for points. let df = table_with_nested_types(NUM_ROWS).await?; @@ -4110,27 +4114,27 @@ async fn unnest_columns() -> Result<()> { .await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" - +----------+----------------+------+ - | shape_id | points | tags | - +----------+----------------+------+ - | 1 | {x: -3, y: -4} | tag1 | - | 1 | {x: 5, y: -8} | tag1 | - | 2 | {x: -2, y: -8} | tag1 | - | 2 | {x: 6, y: 2} | tag1 | - | 3 | {x: -2, y: 5} | tag1 | - | 3 | {x: -2, y: 5} | tag2 | - | 3 | {x: -2, y: 5} | tag3 | - | 3 | {x: -2, y: 5} | tag4 | - | 3 | {x: -9, y: -7} | tag1 | - | 3 | {x: -9, y: -7} | tag2 | - | 3 | {x: -9, y: -7} | tag3 | - | 3 | {x: -9, y: -7} | tag4 | - | 4 | | tag1 | - | 4 | | tag2 | - | 4 | | tag3 | - +----------+----------------+------+ - "###); + @r" + +----------+----------------+------+ + | shape_id | points | tags | + +----------+----------------+------+ + | 1 | {x: -3, y: -4} | tag1 | + | 1 | {x: 5, y: -8} | tag1 | + | 2 | {x: -2, y: -8} | tag1 | + | 2 | {x: 6, y: 2} | tag1 | + | 3 | {x: -2, y: 5} | tag1 | + | 3 | {x: -2, y: 5} | tag2 | + | 3 | {x: -2, y: 5} | tag3 | + | 3 | {x: -2, y: 5} | tag4 | + | 3 | {x: -9, y: -7} | tag1 | + | 3 | {x: -9, y: -7} | tag2 | + | 3 | {x: -9, y: -7} | tag3 | + | 3 | {x: -9, y: -7} | tag4 | + | 4 | | tag1 | + | 4 | | tag2 | + | 4 | | tag3 | + +----------+----------------+------+ + "); // Test aggregate results for points and tags. let df = table_with_nested_types(NUM_ROWS).await?; @@ -4170,7 +4174,7 @@ async fn unnest_dict_encoded_columns() -> Result<()> { let results = df.collect().await.unwrap(); assert_snapshot!( batches_to_string(&results), - @r###" + @r" +-----------------+---------+ | make_array_expr | column1 | +-----------------+---------+ @@ -4178,7 +4182,7 @@ async fn unnest_dict_encoded_columns() -> Result<()> { | y | y | | z | z | +-----------------+---------+ - "### + " ); // make_array(dict_encoded_string,literal string) @@ -4198,7 +4202,7 @@ async fn unnest_dict_encoded_columns() -> Result<()> { let results = df.collect().await.unwrap(); assert_snapshot!( batches_to_string(&results), - @r###" + @r" +-----------------+---------+ | make_array_expr | column1 | +-----------------+---------+ @@ -4209,7 +4213,7 @@ async fn unnest_dict_encoded_columns() -> Result<()> { | z | z | | fixed_string | z | +-----------------+---------+ - "### + " ); Ok(()) } @@ -4220,7 +4224,7 @@ async fn unnest_column_nulls() -> Result<()> { let results = df.clone().collect().await?; assert_snapshot!( batches_to_string(&results), - @r###" + @r" +--------+----+ | list | id | +--------+----+ @@ -4229,7 +4233,7 @@ async fn unnest_column_nulls() -> Result<()> { | [] | C | | [3] | D | +--------+----+ - "### + " ); // Unnest, preserving nulls (row with B is preserved) @@ -4242,7 +4246,7 @@ async fn unnest_column_nulls() -> Result<()> { .await?; assert_snapshot!( batches_to_string(&results), - @r###" + @r" +------+----+ | list | id | +------+----+ @@ -4251,7 +4255,7 @@ async fn unnest_column_nulls() -> Result<()> { | | B | | 3 | D | +------+----+ - "### + " ); let options = UnnestOptions::new().with_preserve_nulls(false); @@ -4261,7 +4265,7 @@ async fn unnest_column_nulls() -> Result<()> { .await?; assert_snapshot!( batches_to_string(&results), - @r###" + @r" +------+----+ | list | id | +------+----+ @@ -4269,7 +4273,7 @@ async fn unnest_column_nulls() -> Result<()> { | 2 | A | | 3 | D | +------+----+ - "### + " ); Ok(()) @@ -4286,7 +4290,7 @@ async fn unnest_fixed_list() -> Result<()> { let results = df.clone().collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+----------------+ | shape_id | tags | +----------+----------------+ @@ -4297,7 +4301,7 @@ async fn unnest_fixed_list() -> Result<()> { | 5 | [tag51, tag52] | | 6 | [tag61, tag62] | +----------+----------------+ - "### + " ); let options = UnnestOptions::new().with_preserve_nulls(true); @@ -4308,7 +4312,7 @@ async fn unnest_fixed_list() -> Result<()> { .await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+-------+ | shape_id | tags | +----------+-------+ @@ -4323,7 +4327,7 @@ async fn unnest_fixed_list() -> Result<()> { | 6 | tag61 | | 6 | tag62 | +----------+-------+ - "### + " ); Ok(()) @@ -4340,7 +4344,7 @@ async fn unnest_fixed_list_drop_nulls() -> Result<()> { let results = df.clone().collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+----------------+ | shape_id | tags | +----------+----------------+ @@ -4351,7 +4355,7 @@ async fn unnest_fixed_list_drop_nulls() -> Result<()> { | 5 | [tag51, tag52] | | 6 | [tag61, tag62] | +----------+----------------+ - "### + " ); let options = UnnestOptions::new().with_preserve_nulls(false); @@ -4362,7 +4366,7 @@ async fn unnest_fixed_list_drop_nulls() -> Result<()> { .await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+-------+ | shape_id | tags | +----------+-------+ @@ -4375,7 +4379,7 @@ async fn unnest_fixed_list_drop_nulls() -> Result<()> { | 6 | tag61 | | 6 | tag62 | +----------+-------+ - "### + " ); Ok(()) @@ -4411,7 +4415,7 @@ async fn unnest_fixed_list_non_null() -> Result<()> { let results = df.clone().collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+----------------+ | shape_id | tags | +----------+----------------+ @@ -4422,7 +4426,7 @@ async fn unnest_fixed_list_non_null() -> Result<()> { | 5 | [tag51, tag52] | | 6 | [tag61, tag62] | +----------+----------------+ - "### + " ); let options = UnnestOptions::new().with_preserve_nulls(true); @@ -4432,7 +4436,7 @@ async fn unnest_fixed_list_non_null() -> Result<()> { .await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+-------+ | shape_id | tags | +----------+-------+ @@ -4449,7 +4453,7 @@ async fn unnest_fixed_list_non_null() -> Result<()> { | 6 | tag61 | | 6 | tag62 | +----------+-------+ - "### + " ); Ok(()) @@ -4463,17 +4467,17 @@ async fn unnest_aggregate_columns() -> Result<()> { let results = df.select_columns(&["tags"])?.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" - +--------------------------+ - | tags | - +--------------------------+ - | [tag1, tag2, tag3, tag4] | - | [tag1, tag2, tag3] | - | [tag1, tag2] | - | [tag1] | - | [tag1] | - +--------------------------+ - "### + @r" + +--------------------------+ + | tags | + +--------------------------+ + | [tag1, tag2, tag3, tag4] | + | [tag1, tag2, tag3] | + | [tag1, tag2] | + | [tag1] | + | [tag1] | + +--------------------------+ + " ); let df = table_with_nested_types(NUM_ROWS).await?; @@ -4484,13 +4488,13 @@ async fn unnest_aggregate_columns() -> Result<()> { .await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +-------------+ | count(tags) | +-------------+ | 11 | +-------------+ - "### + " ); Ok(()) @@ -4563,7 +4567,7 @@ async fn unnest_array_agg() -> Result<()> { assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+--------+ | shape_id | tag_id | +----------+--------+ @@ -4577,7 +4581,7 @@ async fn unnest_array_agg() -> Result<()> { | 3 | 32 | | 3 | 33 | +----------+--------+ - "### + " ); // Doing an `array_agg` by `shape_id` produces: @@ -4591,7 +4595,7 @@ async fn unnest_array_agg() -> Result<()> { .await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+--------------+ | shape_id | tag_id | +----------+--------------+ @@ -4599,7 +4603,7 @@ async fn unnest_array_agg() -> Result<()> { | 2 | [21, 22, 23] | | 3 | [31, 32, 33] | +----------+--------------+ - "### + " ); // Unnesting again should produce the original batch. @@ -4615,7 +4619,7 @@ async fn unnest_array_agg() -> Result<()> { .await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+--------+ | shape_id | tag_id | +----------+--------+ @@ -4629,7 +4633,7 @@ async fn unnest_array_agg() -> Result<()> { | 3 | 32 | | 3 | 33 | +----------+--------+ - "### + " ); Ok(()) @@ -4659,7 +4663,7 @@ async fn unnest_with_redundant_columns() -> Result<()> { let results = df.clone().collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+--------+ | shape_id | tag_id | +----------+--------+ @@ -4673,7 +4677,7 @@ async fn unnest_with_redundant_columns() -> Result<()> { | 3 | 32 | | 3 | 33 | +----------+--------+ - "### + " ); // Doing an `array_agg` by `shape_id` produces: @@ -4703,7 +4707,7 @@ async fn unnest_with_redundant_columns() -> Result<()> { let results = df.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----------+ | shape_id | +----------+ @@ -4717,7 +4721,7 @@ async fn unnest_with_redundant_columns() -> Result<()> { | 3 | | 3 | +----------+ - "### + " ); Ok(()) @@ -4758,7 +4762,7 @@ async fn unnest_multiple_columns() -> Result<()> { // string: a, b, c, d assert_snapshot!( batches_to_string(&results), - @r###" + @r" +------+------------+------------+--------+ | list | large_list | fixed_list | string | +------+------------+------------+--------+ @@ -4772,7 +4776,7 @@ async fn unnest_multiple_columns() -> Result<()> { | | | 4 | c | | | | | d | +------+------------+------------+--------+ - "### + " ); // Test with `preserve_nulls = false`` @@ -4789,7 +4793,7 @@ async fn unnest_multiple_columns() -> Result<()> { // string: a, b, c, d assert_snapshot!( batches_to_string(&results), - @r###" + @r" +------+------------+------------+--------+ | list | large_list | fixed_list | string | +------+------------+------------+--------+ @@ -4802,7 +4806,7 @@ async fn unnest_multiple_columns() -> Result<()> { | | | 3 | c | | | | 4 | c | +------+------------+------------+--------+ - "### + " ); Ok(()) @@ -4831,7 +4835,7 @@ async fn unnest_non_nullable_list() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +----+ | c1 | +----+ @@ -4839,7 +4843,7 @@ async fn unnest_non_nullable_list() -> Result<()> { | 2 | | | +----+ - "### + " ); Ok(()) @@ -4884,7 +4888,7 @@ async fn test_read_batches() -> Result<()> { let results = df.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----+--------+ | id | number | +----+--------+ @@ -4897,7 +4901,7 @@ async fn test_read_batches() -> Result<()> { | 5 | 3.33 | | 5 | 6.66 | +----+--------+ - "### + " ); Ok(()) } @@ -4918,10 +4922,10 @@ async fn test_read_batches_empty() -> Result<()> { let results = df.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" ++ ++ - "### + " ); Ok(()) } @@ -4970,14 +4974,14 @@ async fn consecutive_projection_same_schema() -> Result<()> { let results = df.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +----+----+----+ | id | t | t2 | +----+----+----+ | 0 | | | | 1 | 10 | 10 | +----+----+----+ - "### + " ); Ok(()) @@ -5291,13 +5295,13 @@ async fn test_array_agg() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +-------------------------------------+ | array_agg(test.a) | +-------------------------------------+ | [abcDEF, abc123, CBAdef, 123AbcDef] | +-------------------------------------+ - "### + " ); Ok(()) @@ -5365,10 +5369,10 @@ async fn test_dataframe_placeholder_missing_param_values() -> Result<()> { // N.B., the test is basically `SELECT 1 as a WHERE a = 3;` which returns no results. assert_snapshot!( batches_to_string(&df.collect().await.unwrap()), - @r###" + @r" ++ ++ - "### + " ); Ok(()) @@ -5424,13 +5428,13 @@ async fn test_dataframe_placeholder_column_parameter() -> Result<()> { assert_snapshot!( batches_to_string(&df.collect().await.unwrap()), - @r###" + @r" +----+ | $1 | +----+ | 3 | +----+ - "### + " ); Ok(()) @@ -5497,13 +5501,13 @@ async fn test_dataframe_placeholder_like_expression() -> Result<()> { assert_snapshot!( batches_to_string(&df.collect().await.unwrap()), - @r###" + @r" +-----+ | a | +-----+ | foo | +-----+ - "### + " ); Ok(()) @@ -5561,13 +5565,13 @@ async fn write_partitioned_parquet_results() -> Result<()> { let results = filter_df.collect().await?; assert_snapshot!( batches_to_string(&results), - @r###" + @r" +-----+ | c1 | +-----+ | abc | +-----+ - "### + " ); // Read the entire set of parquet files @@ -5583,14 +5587,14 @@ async fn write_partitioned_parquet_results() -> Result<()> { let results = df.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +-----+-----+ | c1 | c2 | +-----+-----+ | abc | 123 | | def | 456 | +-----+-----+ - "### + " ); Ok(()) @@ -5747,7 +5751,7 @@ async fn sparse_union_is_null() { // view_all assert_snapshot!( batches_to_sort_string(&df.clone().collect().await.unwrap()), - @r###" + @r" +----------+ | my_union | +----------+ @@ -5758,14 +5762,14 @@ async fn sparse_union_is_null() { | {C=a} | | {C=} | +----------+ - "### + " ); // filter where is null let result_df = df.clone().filter(col("my_union").is_null()).unwrap(); assert_snapshot!( batches_to_sort_string(&result_df.collect().await.unwrap()), - @r###" + @r" +----------+ | my_union | +----------+ @@ -5773,14 +5777,14 @@ async fn sparse_union_is_null() { | {B=} | | {C=} | +----------+ - "### + " ); // filter where is not null let result_df = df.filter(col("my_union").is_not_null()).unwrap(); assert_snapshot!( batches_to_sort_string(&result_df.collect().await.unwrap()), - @r###" + @r" +----------+ | my_union | +----------+ @@ -5788,7 +5792,7 @@ async fn sparse_union_is_null() { | {B=3.2} | | {C=a} | +----------+ - "### + " ); } @@ -5830,7 +5834,7 @@ async fn dense_union_is_null() { // view_all assert_snapshot!( batches_to_sort_string(&df.clone().collect().await.unwrap()), - @r###" + @r" +----------+ | my_union | +----------+ @@ -5841,14 +5845,14 @@ async fn dense_union_is_null() { | {C=a} | | {C=} | +----------+ - "### + " ); // filter where is null let result_df = df.clone().filter(col("my_union").is_null()).unwrap(); assert_snapshot!( batches_to_sort_string(&result_df.collect().await.unwrap()), - @r###" + @r" +----------+ | my_union | +----------+ @@ -5856,14 +5860,14 @@ async fn dense_union_is_null() { | {B=} | | {C=} | +----------+ - "### + " ); // filter where is not null let result_df = df.filter(col("my_union").is_not_null()).unwrap(); assert_snapshot!( batches_to_sort_string(&result_df.collect().await.unwrap()), - @r###" + @r" +----------+ | my_union | +----------+ @@ -5871,7 +5875,7 @@ async fn dense_union_is_null() { | {B=3.2} | | {C=a} | +----------+ - "### + " ); } @@ -5903,7 +5907,7 @@ async fn boolean_dictionary_as_filter() { // view_all assert_snapshot!( batches_to_string(&df.clone().collect().await.unwrap()), - @r###" + @r" +---------+ | my_dict | +---------+ @@ -5915,14 +5919,14 @@ async fn boolean_dictionary_as_filter() { | true | | false | +---------+ - "### + " ); let result_df = df.clone().filter(col("my_dict")).unwrap(); assert_snapshot!( batches_to_string(&result_df.collect().await.unwrap()), - @r###" + @r" +---------+ | my_dict | +---------+ @@ -5930,7 +5934,7 @@ async fn boolean_dictionary_as_filter() { | true | | true | +---------+ - "### + " ); // test nested dictionary @@ -5961,26 +5965,26 @@ async fn boolean_dictionary_as_filter() { // view_all assert_snapshot!( batches_to_string(&df.clone().collect().await.unwrap()), - @r###" + @r" +----------------+ | my_nested_dict | +----------------+ | true | | false | +----------------+ - "### + " ); let result_df = df.clone().filter(col("my_nested_dict")).unwrap(); assert_snapshot!( batches_to_string(&result_df.collect().await.unwrap()), - @r###" + @r" +----------------+ | my_nested_dict | +----------------+ | true | +----------------+ - "### + " ); } @@ -6058,11 +6062,11 @@ async fn test_alias() -> Result<()> { .into_unoptimized_plan() .display_indent_schema() .to_string(); - assert_snapshot!(plan, @r###" + assert_snapshot!(plan, @r" SubqueryAlias: table_alias [a:Utf8, b:Int32, one:Int32] Projection: test.a, test.b, Int32(1) AS one [a:Utf8, b:Int32, one:Int32] TableScan: test [a:Utf8, b:Int32] - "###); + "); // Select over the aliased DataFrame let df = df.select(vec![ @@ -6071,7 +6075,7 @@ async fn test_alias() -> Result<()> { ])?; assert_snapshot!( batches_to_sort_string(&df.collect().await.unwrap()), - @r###" + @r" +-----------+---------------------------------+ | a | table_alias.b + table_alias.one | +-----------+---------------------------------+ @@ -6080,7 +6084,7 @@ async fn test_alias() -> Result<()> { | abc123 | 11 | | abcDEF | 2 | +-----------+---------------------------------+ - "### + " ); Ok(()) } @@ -6110,7 +6114,7 @@ async fn test_alias_self_join() -> Result<()> { let joined = left.join(right, JoinType::Full, &["a"], &["a"], None)?; assert_snapshot!( batches_to_sort_string(&joined.collect().await.unwrap()), - @r###" + @r" +-----------+-----+-----------+-----+ | a | b | a | b | +-----------+-----+-----------+-----+ @@ -6119,7 +6123,7 @@ async fn test_alias_self_join() -> Result<()> { | abc123 | 10 | abc123 | 10 | | abcDEF | 1 | abcDEF | 1 | +-----------+-----+-----------+-----+ - "### + " ); Ok(()) } @@ -6132,14 +6136,14 @@ async fn test_alias_empty() -> Result<()> { .into_unoptimized_plan() .display_indent_schema() .to_string(); - assert_snapshot!(plan, @r###" + assert_snapshot!(plan, @r" SubqueryAlias: [a:Utf8, b:Int32] TableScan: test [a:Utf8, b:Int32] - "###); + "); assert_snapshot!( batches_to_sort_string(&df.select(vec![col("a"), col("b")])?.collect().await.unwrap()), - @r###" + @r" +-----------+-----+ | a | b | +-----------+-----+ @@ -6148,7 +6152,7 @@ async fn test_alias_empty() -> Result<()> { | abc123 | 10 | | abcDEF | 1 | +-----------+-----+ - "### + " ); Ok(()) @@ -6167,12 +6171,12 @@ async fn test_alias_nested() -> Result<()> { .into_optimized_plan()? .display_indent_schema() .to_string(); - assert_snapshot!(plan, @r###" + assert_snapshot!(plan, @r" SubqueryAlias: alias2 [a:Utf8, b:Int32, one:Int32] SubqueryAlias: alias1 [a:Utf8, b:Int32, one:Int32] Projection: test.a, test.b, Int32(1) AS one [a:Utf8, b:Int32, one:Int32] TableScan: test projection=[a, b] [a:Utf8, b:Int32] - "###); + "); // Select over the aliased DataFrame let select1 = df @@ -6181,7 +6185,7 @@ async fn test_alias_nested() -> Result<()> { assert_snapshot!( batches_to_sort_string(&select1.collect().await.unwrap()), - @r###" + @r" +-----------+-----------------------+ | a | alias2.b + alias2.one | +-----------+-----------------------+ @@ -6190,7 +6194,7 @@ async fn test_alias_nested() -> Result<()> { | abc123 | 11 | | abcDEF | 2 | +-----------+-----------------------+ - "### + " ); // Only the outermost alias is visible @@ -6360,7 +6364,7 @@ async fn test_fill_null() -> Result<()> { let results = df_filled.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +---+---------+ | a | b | +---+---------+ @@ -6368,7 +6372,7 @@ async fn test_fill_null() -> Result<()> { | 1 | x | | 3 | z | +---+---------+ - "### + " ); Ok(()) @@ -6388,7 +6392,7 @@ async fn test_fill_null_all_columns() -> Result<()> { assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +---+---------+ | a | b | +---+---------+ @@ -6396,7 +6400,7 @@ async fn test_fill_null_all_columns() -> Result<()> { | 1 | x | | 3 | z | +---+---------+ - "### + " ); // Fill column "a" null values with a value that cannot be cast to Int32. @@ -6405,7 +6409,7 @@ async fn test_fill_null_all_columns() -> Result<()> { let results = df_filled.collect().await?; assert_snapshot!( batches_to_sort_string(&results), - @r###" + @r" +---+---------+ | a | b | +---+---------+ @@ -6413,7 +6417,7 @@ async fn test_fill_null_all_columns() -> Result<()> { | 1 | x | | 3 | z | +---+---------+ - "### + " ); Ok(()) } @@ -6486,14 +6490,14 @@ async fn test_insert_into_casting_support() -> Result<()> { assert_snapshot!( batches_to_string(&res), - @r###" + @r" +------+ | a | +------+ | a123 | | b456 | +------+ - "### + " ); Ok(()) } @@ -6629,13 +6633,13 @@ async fn test_copy_to_preserves_order() -> Result<()> { // Expect that input to the DataSinkExec is sorted correctly assert_snapshot!( physical_plan_format, - @r###" + @r" UnionExec DataSinkExec: sink=CsvSink(file_groups=[]) SortExec: expr=[column1@0 DESC], preserve_partitioning=[false] DataSourceExec: partitions=1, partition_sizes=[1] DataSourceExec: partitions=1, partition_sizes=[1] - "### + " ); Ok(()) } diff --git a/datafusion/core/tests/expr_api/simplification.rs b/datafusion/core/tests/expr_api/simplification.rs index 470e10b592616..a42dfc951da0d 100644 --- a/datafusion/core/tests/expr_api/simplification.rs +++ b/datafusion/core/tests/expr_api/simplification.rs @@ -243,10 +243,10 @@ fn to_timestamp_expr_folded() -> Result<()> { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" + @r#" Projection: TimestampNanosecond(1599566400000000000, None) AS to_timestamp(Utf8("2020-09-08T12:00:00+00:00")) TableScan: test - "### + "# ); Ok(()) } @@ -273,10 +273,10 @@ fn now_less_than_timestamp() -> Result<()> { assert_snapshot!( actual, - @r###" + @r" Filter: Boolean(true) TableScan: test - "### + " ); Ok(()) } @@ -312,10 +312,10 @@ fn select_date_plus_interval() -> Result<()> { assert_snapshot!( actual, - @r###" + @r#" Projection: Date32("2021-01-09") AS to_timestamp(Utf8("2020-09-08T12:05:00+00:00")) + IntervalDayTime("IntervalDayTime { days: 123, milliseconds: 0 }") TableScan: test - "### + "# ); Ok(()) } @@ -334,10 +334,10 @@ fn simplify_project_scalar_fn() -> Result<()> { let actual = formatter.trim(); assert_snapshot!( actual, - @r###" + @r" Projection: test.f AS power(test.f,Float64(1)) TableScan: test - "### + " ); Ok(()) } diff --git a/datafusion/core/tests/physical_optimizer/combine_partial_final_agg.rs b/datafusion/core/tests/physical_optimizer/combine_partial_final_agg.rs index e73f5318079e2..2fdfece2a86e7 100644 --- a/datafusion/core/tests/physical_optimizer/combine_partial_final_agg.rs +++ b/datafusion/core/tests/physical_optimizer/combine_partial_final_agg.rs @@ -191,7 +191,7 @@ fn aggregations_combined() -> datafusion_common::Result<()> { // should combine the Partial/Final AggregateExecs to the Single AggregateExec assert_optimized!( plan, - @ " + @ r" AggregateExec: mode=Single, gby=[], aggr=[COUNT(1)] DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c], file_type=parquet " diff --git a/datafusion/core/tests/physical_optimizer/enforce_distribution.rs b/datafusion/core/tests/physical_optimizer/enforce_distribution.rs index 04dffced31b0f..4815f4a8a8a36 100644 --- a/datafusion/core/tests/physical_optimizer/enforce_distribution.rs +++ b/datafusion/core/tests/physical_optimizer/enforce_distribution.rs @@ -1221,21 +1221,21 @@ fn reorder_join_keys_to_left_input() -> Result<()> { assert_eq!(captured_join_type, join_type.to_string()); insta::allow_duplicates! {insta::assert_snapshot!(modified_plan, @r" -HashJoinExec: mode=Partitioned, join_type=..., on=[(AA@1, a1@5), (B@2, b1@6), (C@3, c@2)] - ProjectionExec: expr=[a@0 as A, a@0 as AA, b@1 as B, c@2 as C] - HashJoinExec: mode=Partitioned, join_type=Inner, on=[(a@0, a1@0), (b@1, b1@1), (c@2, c1@2)] - RepartitionExec: partitioning=Hash([a@0, b@1, c@2], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - RepartitionExec: partitioning=Hash([a1@0, b1@1, c1@2], 10), input_partitions=1 - ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - HashJoinExec: mode=Partitioned, join_type=Inner, on=[(c@2, c1@2), (b@1, b1@1), (a@0, a1@0)] - RepartitionExec: partitioning=Hash([c@2, b@1, a@0], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - RepartitionExec: partitioning=Hash([c1@2, b1@1, a1@0], 10), input_partitions=1 - ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -");} + HashJoinExec: mode=Partitioned, join_type=..., on=[(AA@1, a1@5), (B@2, b1@6), (C@3, c@2)] + ProjectionExec: expr=[a@0 as A, a@0 as AA, b@1 as B, c@2 as C] + HashJoinExec: mode=Partitioned, join_type=Inner, on=[(a@0, a1@0), (b@1, b1@1), (c@2, c1@2)] + RepartitionExec: partitioning=Hash([a@0, b@1, c@2], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + RepartitionExec: partitioning=Hash([a1@0, b1@1, c1@2], 10), input_partitions=1 + ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + HashJoinExec: mode=Partitioned, join_type=Inner, on=[(c@2, c1@2), (b@1, b1@1), (a@0, a1@0)] + RepartitionExec: partitioning=Hash([c@2, b@1, a@0], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + RepartitionExec: partitioning=Hash([c1@2, b1@1, a1@0], 10), input_partitions=1 + ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + ");} } Ok(()) @@ -1349,21 +1349,21 @@ fn reorder_join_keys_to_right_input() -> Result<()> { let (_, plan_str) = hide_first(reordered.as_ref(), r"join_type=(\w+)", "join_type=..."); insta::allow_duplicates! {insta::assert_snapshot!(plan_str, @r" -HashJoinExec: mode=Partitioned, join_type=..., on=[(C@3, c@2), (B@2, b1@6), (AA@1, a1@5)] - ProjectionExec: expr=[a@0 as A, a@0 as AA, b@1 as B, c@2 as C] - HashJoinExec: mode=Partitioned, join_type=Inner, on=[(a@0, a1@0), (b@1, b1@1)] - RepartitionExec: partitioning=Hash([a@0, b@1], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - RepartitionExec: partitioning=Hash([a1@0, b1@1], 10), input_partitions=1 - ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - HashJoinExec: mode=Partitioned, join_type=Inner, on=[(c@2, c1@2), (b@1, b1@1), (a@0, a1@0)] - RepartitionExec: partitioning=Hash([c@2, b@1, a@0], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - RepartitionExec: partitioning=Hash([c1@2, b1@1, a1@0], 10), input_partitions=1 - ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -");} + HashJoinExec: mode=Partitioned, join_type=..., on=[(C@3, c@2), (B@2, b1@6), (AA@1, a1@5)] + ProjectionExec: expr=[a@0 as A, a@0 as AA, b@1 as B, c@2 as C] + HashJoinExec: mode=Partitioned, join_type=Inner, on=[(a@0, a1@0), (b@1, b1@1)] + RepartitionExec: partitioning=Hash([a@0, b@1], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + RepartitionExec: partitioning=Hash([a1@0, b1@1], 10), input_partitions=1 + ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + HashJoinExec: mode=Partitioned, join_type=Inner, on=[(c@2, c1@2), (b@1, b1@1), (a@0, a1@0)] + RepartitionExec: partitioning=Hash([c@2, b@1, a@0], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + RepartitionExec: partitioning=Hash([c1@2, b1@1, a1@0], 10), input_partitions=1 + ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + ");} } Ok(()) @@ -1424,19 +1424,19 @@ fn multi_smj_joins() -> Result<()> { // Should include 6 RepartitionExecs (3 hash, 3 round-robin), 3 SortExecs JoinType::Inner | JoinType::Left | JoinType::LeftSemi | JoinType::LeftAnti => { assert_plan!(plan_distrib, @r" -SortMergeJoin: join_type=..., on=[(a@0, c@2)] - SortMergeJoin: join_type=..., on=[(a@0, b1@1)] - SortExec: expr=[a@0 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - SortExec: expr=[b1@1 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([b1@1], 10), input_partitions=1 - ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1, d@3 as d1, e@4 as e1] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - SortExec: expr=[c@2 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([c@2], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortMergeJoin: join_type=..., on=[(a@0, c@2)] + SortMergeJoin: join_type=..., on=[(a@0, b1@1)] + SortExec: expr=[a@0 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + SortExec: expr=[b1@1 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([b1@1], 10), input_partitions=1 + ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1, d@3 as d1, e@4 as e1] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + SortExec: expr=[c@2 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([c@2], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); } // Should include 7 RepartitionExecs (4 hash, 3 round-robin), 4 SortExecs // Since ordering of the left child is not preserved after SortMergeJoin @@ -1449,21 +1449,21 @@ SortMergeJoin: join_type=..., on=[(a@0, c@2)] // cases when mode is Inner, Left, LeftSemi, LeftAnti _ => { assert_plan!(plan_distrib, @r" -SortMergeJoin: join_type=..., on=[(a@0, c@2)] - SortExec: expr=[a@0 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=10 - SortMergeJoin: join_type=..., on=[(a@0, b1@1)] - SortExec: expr=[a@0 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - SortExec: expr=[b1@1 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([b1@1], 10), input_partitions=1 - ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1, d@3 as d1, e@4 as e1] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - SortExec: expr=[c@2 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([c@2], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortMergeJoin: join_type=..., on=[(a@0, c@2)] + SortExec: expr=[a@0 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=10 + SortMergeJoin: join_type=..., on=[(a@0, b1@1)] + SortExec: expr=[a@0 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + SortExec: expr=[b1@1 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([b1@1], 10), input_partitions=1 + ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1, d@3 as d1, e@4 as e1] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + SortExec: expr=[c@2 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([c@2], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); } } @@ -1536,39 +1536,39 @@ SortMergeJoin: join_type=..., on=[(a@0, c@2)] JoinType::Inner | JoinType::Right => { // TODO(wiedld): show different test result if enforce sorting first. assert_plan!(plan_distrib, @r" -SortMergeJoin: join_type=..., on=[(b1@6, c@2)] - SortMergeJoin: join_type=..., on=[(a@0, b1@1)] - SortExec: expr=[a@0 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - SortExec: expr=[b1@1 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([b1@1], 10), input_partitions=1 - ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1, d@3 as d1, e@4 as e1] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - SortExec: expr=[c@2 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([c@2], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortMergeJoin: join_type=..., on=[(b1@6, c@2)] + SortMergeJoin: join_type=..., on=[(a@0, b1@1)] + SortExec: expr=[a@0 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + SortExec: expr=[b1@1 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([b1@1], 10), input_partitions=1 + ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1, d@3 as d1, e@4 as e1] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + SortExec: expr=[c@2 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([c@2], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); } // Should include 7 RepartitionExecs (4 hash, 3 round-robin) and 4 SortExecs JoinType::Left | JoinType::Full => { // TODO(wiedld): show different test result if enforce sorting first. assert_plan!(plan_distrib, @r" -SortMergeJoin: join_type=..., on=[(b1@6, c@2)] - SortExec: expr=[b1@6 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([b1@6], 10), input_partitions=10 - SortMergeJoin: join_type=..., on=[(a@0, b1@1)] - SortExec: expr=[a@0 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - SortExec: expr=[b1@1 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([b1@1], 10), input_partitions=1 - ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1, d@3 as d1, e@4 as e1] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - SortExec: expr=[c@2 ASC], preserve_partitioning=[true] - RepartitionExec: partitioning=Hash([c@2], 10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortMergeJoin: join_type=..., on=[(b1@6, c@2)] + SortExec: expr=[b1@6 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([b1@6], 10), input_partitions=10 + SortMergeJoin: join_type=..., on=[(a@0, b1@1)] + SortExec: expr=[a@0 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + SortExec: expr=[b1@1 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([b1@1], 10), input_partitions=1 + ProjectionExec: expr=[a@0 as a1, b@1 as b1, c@2 as c1, d@3 as d1, e@4 as e1] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + SortExec: expr=[c@2 ASC], preserve_partitioning=[true] + RepartitionExec: partitioning=Hash([c@2], 10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); } // this match arm cannot be reached _ => unreachable!() @@ -1682,23 +1682,23 @@ fn smj_join_key_ordering() -> Result<()> { // Only two RepartitionExecs added let plan_distrib = test_config.to_plan(join.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -SortMergeJoin: join_type=Inner, on=[(b3@1, b2@1), (a3@0, a2@0)] - SortExec: expr=[b3@1 ASC, a3@0 ASC], preserve_partitioning=[true] - ProjectionExec: expr=[a1@0 as a3, b1@1 as b3] - ProjectionExec: expr=[a1@1 as a1, b1@0 as b1] - AggregateExec: mode=FinalPartitioned, gby=[b1@0 as b1, a1@1 as a1], aggr=[] - RepartitionExec: partitioning=Hash([b1@0, a1@1], 10), input_partitions=10 - AggregateExec: mode=Partial, gby=[b@1 as b1, a@0 as a1], aggr=[] - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - SortExec: expr=[b2@1 ASC, a2@0 ASC], preserve_partitioning=[true] - ProjectionExec: expr=[a@1 as a2, b@0 as b2] - AggregateExec: mode=FinalPartitioned, gby=[b@0 as b, a@1 as a], aggr=[] - RepartitionExec: partitioning=Hash([b@0, a@1], 10), input_partitions=10 - AggregateExec: mode=Partial, gby=[b@1 as b, a@0 as a], aggr=[] - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortMergeJoin: join_type=Inner, on=[(b3@1, b2@1), (a3@0, a2@0)] + SortExec: expr=[b3@1 ASC, a3@0 ASC], preserve_partitioning=[true] + ProjectionExec: expr=[a1@0 as a3, b1@1 as b3] + ProjectionExec: expr=[a1@1 as a1, b1@0 as b1] + AggregateExec: mode=FinalPartitioned, gby=[b1@0 as b1, a1@1 as a1], aggr=[] + RepartitionExec: partitioning=Hash([b1@0, a1@1], 10), input_partitions=10 + AggregateExec: mode=Partial, gby=[b@1 as b1, a@0 as a1], aggr=[] + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + SortExec: expr=[b2@1 ASC, a2@0 ASC], preserve_partitioning=[true] + ProjectionExec: expr=[a@1 as a2, b@0 as b2] + AggregateExec: mode=FinalPartitioned, gby=[b@0 as b, a@1 as a], aggr=[] + RepartitionExec: partitioning=Hash([b@0, a@1], 10), input_partitions=10 + AggregateExec: mode=Partial, gby=[b@1 as b, a@0 as a], aggr=[] + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Test: result IS DIFFERENT, if EnforceSorting is run first: let plan_sort = test_config.to_plan(join, &SORT_DISTRIB_DISTRIB); @@ -1756,10 +1756,10 @@ fn merge_does_not_need_sort() -> Result<()> { let plan_distrib = test_config.to_plan(exec.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -SortPreservingMergeExec: [a@0 ASC] - CoalesceBatchesExec: target_batch_size=4096 - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet -"); + SortPreservingMergeExec: [a@0 ASC] + CoalesceBatchesExec: target_batch_size=4096 + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet + "); // Test: result IS DIFFERENT, if EnforceSorting is run first: // @@ -1770,11 +1770,11 @@ SortPreservingMergeExec: [a@0 ASC] let plan_sort = test_config.to_plan(exec, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_sort, @r" -SortExec: expr=[a@0 ASC], preserve_partitioning=[false] - CoalescePartitionsExec - CoalesceBatchesExec: target_batch_size=4096 - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet -"); + SortExec: expr=[a@0 ASC], preserve_partitioning=[false] + CoalescePartitionsExec + CoalesceBatchesExec: target_batch_size=4096 + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet + "); Ok(()) } @@ -1951,11 +1951,11 @@ fn repartition_sorted_limit() -> Result<()> { let plan_distrib = test_config.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -GlobalLimitExec: skip=0, fetch=100 - LocalLimitExec: fetch=100 - SortExec: expr=[c@2 ASC], preserve_partitioning=[false] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + GlobalLimitExec: skip=0, fetch=100 + LocalLimitExec: fetch=100 + SortExec: expr=[c@2 ASC], preserve_partitioning=[false] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // data is sorted so can't repartition here let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -2006,19 +2006,19 @@ fn repartition_ignores_limit() -> Result<()> { let plan_distrib = test_config.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=10 - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - GlobalLimitExec: skip=0, fetch=100 - CoalescePartitionsExec - LocalLimitExec: fetch=100 - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - GlobalLimitExec: skip=0, fetch=100 - LocalLimitExec: fetch=100 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=Hash([a@0], 10), input_partitions=10 + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + GlobalLimitExec: skip=0, fetch=100 + CoalescePartitionsExec + LocalLimitExec: fetch=100 + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + GlobalLimitExec: skip=0, fetch=100 + LocalLimitExec: fetch=100 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // repartition should happen prior to the filter to maximize parallelism // Expect no repartition to happen for local limit (DataSourceExec) @@ -2036,13 +2036,13 @@ fn repartition_ignores_union() -> Result<()> { let plan_distrib = test_config.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -UnionExec - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + UnionExec + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Expect no repartition of DataSourceExec let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -2065,9 +2065,9 @@ fn repartition_through_sort_preserving_merge() -> Result<()> { let plan_distrib = test_config.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -SortExec: expr=[c@2 ASC], preserve_partitioning=[false] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortExec: expr=[c@2 ASC], preserve_partitioning=[false] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -2093,9 +2093,9 @@ fn repartition_ignores_sort_preserving_merge() -> Result<()> { // Test: run EnforceDistribution, then EnforceSort assert_plan!(plan_distrib, @r" -SortPreservingMergeExec: [c@2 ASC] - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + SortPreservingMergeExec: [c@2 ASC] + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); // should not sort (as the data was already sorted) // should not repartition, since increased parallelism is not beneficial for SortPReservingMerge @@ -2103,10 +2103,10 @@ SortPreservingMergeExec: [c@2 ASC] let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_sort, @r" -SortExec: expr=[c@2 ASC], preserve_partitioning=[false] - CoalescePartitionsExec - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + SortExec: expr=[c@2 ASC], preserve_partitioning=[false] + CoalescePartitionsExec + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); Ok(()) } @@ -2131,11 +2131,11 @@ fn repartition_ignores_sort_preserving_merge_with_union() -> Result<()> { // Test: run EnforceDistribution, then EnforceSort. assert_plan!(plan_distrib, @r" -SortPreservingMergeExec: [c@2 ASC] - UnionExec - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + SortPreservingMergeExec: [c@2 ASC] + UnionExec + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); // // should not repartition / sort (as the data was already sorted) @@ -2143,12 +2143,12 @@ SortPreservingMergeExec: [c@2 ASC] let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_sort, @r" -SortExec: expr=[c@2 ASC], preserve_partitioning=[false] - CoalescePartitionsExec - UnionExec - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + SortExec: expr=[c@2 ASC], preserve_partitioning=[false] + CoalescePartitionsExec + UnionExec + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); Ok(()) } @@ -2215,13 +2215,13 @@ fn repartition_does_not_destroy_sort_more_complex() -> Result<()> { let plan_distrib = test_config.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -UnionExec - SortRequiredExec: [c@2 ASC] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + UnionExec + SortRequiredExec: [c@2 ASC] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // union input 1: no repartitioning // union input 2: should repartition // @@ -2258,23 +2258,23 @@ fn repartition_transitively_with_projection() -> Result<()> { let plan_distrib = test_config.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -SortPreservingMergeExec: [sum@0 ASC] - SortExec: expr=[sum@0 ASC], preserve_partitioning=[true] - ProjectionExec: expr=[a@0 + b@1 as sum] - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortPreservingMergeExec: [sum@0 ASC] + SortExec: expr=[sum@0 ASC], preserve_partitioning=[true] + ProjectionExec: expr=[a@0 + b@1 as sum] + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Test: result IS DIFFERENT, if EnforceSorting is run first: let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_sort, @r" -SortExec: expr=[sum@0 ASC], preserve_partitioning=[false] - CoalescePartitionsExec - ProjectionExec: expr=[a@0 + b@1 as sum] - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortExec: expr=[sum@0 ASC], preserve_partitioning=[false] + CoalescePartitionsExec + ProjectionExec: expr=[a@0 + b@1 as sum] + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Since this projection is not trivial, increasing parallelism is beneficial Ok(()) @@ -2306,10 +2306,10 @@ fn repartition_ignores_transitively_with_projection() -> Result<()> { let plan_distrib = test_config.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -SortRequiredExec: [c@2 ASC] - ProjectionExec: expr=[a@0 as a, b@1 as b, c@2 as c] - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + SortRequiredExec: [c@2 ASC] + ProjectionExec: expr=[a@0 as a, b@1 as b, c@2 as c] + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); // Since this projection is trivial, increasing parallelism is not beneficial let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); @@ -2343,10 +2343,10 @@ fn repartition_transitively_past_sort_with_projection() -> Result<()> { let plan_distrib = test_config.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -SortExec: expr=[c@2 ASC], preserve_partitioning=[false] - ProjectionExec: expr=[a@0 as a, b@1 as b, c@2 as c] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortExec: expr=[c@2 ASC], preserve_partitioning=[false] + ProjectionExec: expr=[a@0 as a, b@1 as b, c@2 as c] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Since this projection is trivial, increasing parallelism is not beneficial let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -2368,12 +2368,12 @@ fn repartition_transitively_past_sort_with_filter() -> Result<()> { let plan_distrib = test_config.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -SortPreservingMergeExec: [a@0 ASC] - SortExec: expr=[a@0 ASC], preserve_partitioning=[true] - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortPreservingMergeExec: [a@0 ASC] + SortExec: expr=[a@0 ASC], preserve_partitioning=[true] + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Expect repartition on the input to the sort (as it can benefit from additional parallelism) @@ -2381,12 +2381,12 @@ SortPreservingMergeExec: [a@0 ASC] let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_sort, @r" -SortExec: expr=[a@0 ASC], preserve_partitioning=[false] - CoalescePartitionsExec - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortExec: expr=[a@0 ASC], preserve_partitioning=[false] + CoalescePartitionsExec + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Expect repartition on the input of the filter (as it can benefit from additional parallelism) Ok(()) @@ -2417,13 +2417,13 @@ fn repartition_transitively_past_sort_with_projection_and_filter() -> Result<()> let plan_distrib = test_config.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -SortPreservingMergeExec: [a@0 ASC] - SortExec: expr=[a@0 ASC], preserve_partitioning=[true] - ProjectionExec: expr=[a@0 as a, b@1 as b, c@2 as c] - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortPreservingMergeExec: [a@0 ASC] + SortExec: expr=[a@0 ASC], preserve_partitioning=[true] + ProjectionExec: expr=[a@0 as a, b@1 as b, c@2 as c] + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Expect repartition on the input to the sort (as it can benefit from additional parallelism) // repartition is lowest down @@ -2432,13 +2432,13 @@ SortPreservingMergeExec: [a@0 ASC] let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_sort, @r" -SortExec: expr=[a@0 ASC], preserve_partitioning=[false] - CoalescePartitionsExec - ProjectionExec: expr=[a@0 as a, b@1 as b, c@2 as c] - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortExec: expr=[a@0 ASC], preserve_partitioning=[false] + CoalescePartitionsExec + ProjectionExec: expr=[a@0 as a, b@1 as b, c@2 as c] + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); Ok(()) } @@ -2458,11 +2458,11 @@ fn parallelization_single_partition() -> Result<()> { test_config.to_plan(plan_parquet.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_parquet_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - DataSourceExec: file_groups={2 groups: [[x:0..50], [x:50..100]]}, projection=[a, b, c, d, e], file_type=parquet -"); + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + DataSourceExec: file_groups={2 groups: [[x:0..50], [x:50..100]]}, projection=[a, b, c, d, e], file_type=parquet + "); let plan_parquet_sort = test_config.to_plan(plan_parquet, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_parquet_distrib, plan_parquet_sort); @@ -2470,11 +2470,11 @@ AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] let plan_csv_distrib = test_config.to_plan(plan_csv.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_csv_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - DataSourceExec: file_groups={2 groups: [[x:0..50], [x:50..100]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false -"); + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + DataSourceExec: file_groups={2 groups: [[x:0..50], [x:50..100]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + "); let plan_csv_sort = test_config.to_plan(plan_csv, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_csv_distrib, plan_csv_sort); @@ -2506,10 +2506,10 @@ fn parallelization_multiple_files() -> Result<()> { test_config_concurrency_3.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_3_distrib, @r" -SortRequiredExec: [a@0 ASC] - FilterExec: c@2 = 0 - DataSourceExec: file_groups={3 groups: [[x:0..50], [y:0..100], [x:50..100]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet -"); + SortRequiredExec: [a@0 ASC] + FilterExec: c@2 = 0 + DataSourceExec: file_groups={3 groups: [[x:0..50], [y:0..100], [x:50..100]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet + "); let plan_3_sort = test_config_concurrency_3.to_plan(plan.clone(), &SORT_DISTRIB_DISTRIB); assert_plan!(plan_3_distrib, plan_3_sort); @@ -2519,10 +2519,10 @@ SortRequiredExec: [a@0 ASC] test_config_concurrency_8.to_plan(plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_8_distrib, @r" -SortRequiredExec: [a@0 ASC] - FilterExec: c@2 = 0 - DataSourceExec: file_groups={8 groups: [[x:0..25], [y:0..25], [x:25..50], [y:25..50], [x:50..75], [y:50..75], [x:75..100], [y:75..100]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet -"); + SortRequiredExec: [a@0 ASC] + FilterExec: c@2 = 0 + DataSourceExec: file_groups={8 groups: [[x:0..25], [y:0..25], [x:25..50], [y:25..50], [x:50..75], [y:50..75], [x:75..100], [y:75..100]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet + "); let plan_8_sort = test_config_concurrency_8.to_plan(plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_8_distrib, plan_8_sort); @@ -2570,21 +2570,21 @@ fn parallelization_compressed_csv() -> Result<()> { // Compressed files cannot be partitioned assert_plan!(plan_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false -"); + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + "); } else { // Uncompressed files can be partitioned assert_plan!(plan_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - DataSourceExec: file_groups={2 groups: [[x:0..50], [x:50..100]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false -"); + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + DataSourceExec: file_groups={2 groups: [[x:0..50], [x:50..100]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + "); } let plan_sort = test_config.to_plan(plan, &SORT_DISTRIB_DISTRIB); @@ -2609,11 +2609,11 @@ fn parallelization_two_partitions() -> Result<()> { test_config.to_plan(plan_parquet.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_parquet_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - DataSourceExec: file_groups={2 groups: [[x:0..100], [y:0..100]]}, projection=[a, b, c, d, e], file_type=parquet -"); + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + DataSourceExec: file_groups={2 groups: [[x:0..100], [y:0..100]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Plan already has two partitions let plan_parquet_sort = test_config.to_plan(plan_parquet, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_parquet_distrib, plan_parquet_sort); @@ -2621,11 +2621,11 @@ AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] // Test: with csv let plan_csv_distrib = test_config.to_plan(plan_csv.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_csv_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - DataSourceExec: file_groups={2 groups: [[x:0..100], [y:0..100]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false -"); + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=Hash([a@0], 2), input_partitions=2 + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + DataSourceExec: file_groups={2 groups: [[x:0..100], [y:0..100]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + "); // Plan already has two partitions let plan_csv_sort = test_config.to_plan(plan_csv, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_csv_distrib, plan_csv_sort); @@ -2649,11 +2649,11 @@ fn parallelization_two_partitions_into_four() -> Result<()> { // Multiple source files split across partitions assert_plan!(plan_parquet_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=4 - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - DataSourceExec: file_groups={4 groups: [[x:0..50], [x:50..100], [y:0..50], [y:50..100]]}, projection=[a, b, c, d, e], file_type=parquet -"); + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=4 + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + DataSourceExec: file_groups={4 groups: [[x:0..50], [x:50..100], [y:0..50], [y:50..100]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Multiple source files split across partitions let plan_parquet_sort = test_config.to_plan(plan_parquet, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_parquet_distrib, plan_parquet_sort); @@ -2662,11 +2662,11 @@ AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] let plan_csv_distrib = test_config.to_plan(plan_csv.clone(), &DISTRIB_DISTRIB_SORT); // Multiple source files split across partitions assert_plan!(plan_csv_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=4 - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - DataSourceExec: file_groups={4 groups: [[x:0..50], [x:50..100], [y:0..50], [y:50..100]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false -"); + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=4 + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + DataSourceExec: file_groups={4 groups: [[x:0..50], [x:50..100], [y:0..50], [y:50..100]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + "); // Multiple source files split across partitions let plan_csv_sort = test_config.to_plan(plan_csv, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_csv_distrib, plan_csv_sort); @@ -2691,11 +2691,11 @@ fn parallelization_sorted_limit() -> Result<()> { let plan_parquet_distrib = test_config.to_plan(plan_parquet.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_parquet_distrib, @r" -GlobalLimitExec: skip=0, fetch=100 - LocalLimitExec: fetch=100 - SortExec: expr=[c@2 ASC], preserve_partitioning=[false] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + GlobalLimitExec: skip=0, fetch=100 + LocalLimitExec: fetch=100 + SortExec: expr=[c@2 ASC], preserve_partitioning=[false] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // data is sorted so can't repartition here // Doesn't parallelize for SortExec without preserve_partitioning let plan_parquet_sort = test_config.to_plan(plan_parquet, &SORT_DISTRIB_DISTRIB); @@ -2705,11 +2705,11 @@ GlobalLimitExec: skip=0, fetch=100 let plan_csv_distrib = test_config.to_plan(plan_csv.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_csv_distrib, @r" -GlobalLimitExec: skip=0, fetch=100 - LocalLimitExec: fetch=100 - SortExec: expr=[c@2 ASC], preserve_partitioning=[false] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false -"); + GlobalLimitExec: skip=0, fetch=100 + LocalLimitExec: fetch=100 + SortExec: expr=[c@2 ASC], preserve_partitioning=[false] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + "); // data is sorted so can't repartition here // Doesn't parallelize for SortExec without preserve_partitioning let plan_csv_sort = test_config.to_plan(plan_csv, &SORT_DISTRIB_DISTRIB); @@ -2844,13 +2844,13 @@ fn parallelization_union_inputs() -> Result<()> { test_config.to_plan(plan_parquet.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_parquet_distrib, @r" -UnionExec - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + UnionExec + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // Union doesn't benefit from input partitioning - no parallelism let plan_parquet_sort = test_config.to_plan(plan_parquet, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_parquet_distrib, plan_parquet_sort); @@ -2859,13 +2859,13 @@ UnionExec let plan_csv_distrib = test_config.to_plan(plan_csv.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_csv_distrib, @r" -UnionExec - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false -"); + UnionExec + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=csv, has_header=false + "); // Union doesn't benefit from input partitioning - no parallelism let plan_csv_sort = test_config.to_plan(plan_csv, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_csv_distrib, plan_csv_sort); @@ -3071,9 +3071,9 @@ fn parallelization_ignores_transitively_with_projection_parquet() -> Result<()> // data should not be repartitioned / resorted assert_plan!(plan_parquet_distrib, @r" -ProjectionExec: expr=[a@0 as a2, c@2 as c2] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + ProjectionExec: expr=[a@0 as a2, c@2 as c2] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); let plan_parquet_sort = test_config.to_plan(plan_parquet, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_parquet_distrib, plan_parquet_sort); @@ -3106,18 +3106,18 @@ fn parallelization_ignores_transitively_with_projection_csv() -> Result<()> { let plan_csv = sort_preserving_merge_exec(sort_key_after_projection, proj_csv); assert_plan!(plan_csv, @r" -SortPreservingMergeExec: [c2@1 ASC] - ProjectionExec: expr=[a@0 as a2, c@2 as c2] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=csv, has_header=false -"); + SortPreservingMergeExec: [c2@1 ASC] + ProjectionExec: expr=[a@0 as a2, c@2 as c2] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=csv, has_header=false + "); let test_config = TestConfig::default(); let plan_distrib = test_config.to_plan(plan_csv.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -ProjectionExec: expr=[a@0 as a2, c@2 as c2] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=csv, has_header=false -"); + ProjectionExec: expr=[a@0 as a2, c@2 as c2] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=csv, has_header=false + "); // Expected Outcome: // data should not be repartitioned / resorted let plan_sort = test_config.to_plan(plan_csv, &SORT_DISTRIB_DISTRIB); @@ -3133,21 +3133,21 @@ fn remove_redundant_roundrobins() -> Result<()> { let physical_plan = repartition_exec(filter_exec(repartition)); assert_plan!(physical_plan, @r" -RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=10 - FilterExec: c@2 = 0 RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=10 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=10 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); let test_config = TestConfig::default(); let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -3175,11 +3175,11 @@ fn remove_unnecessary_spm_after_filter() -> Result<()> { // This is still satisfied since, after filter that column is constant. assert_plan!(plan_distrib, @r" -CoalescePartitionsExec - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2, preserve_order=true, sort_exprs=c@2 ASC - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + CoalescePartitionsExec + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2, preserve_order=true, sort_exprs=c@2 ASC + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -3204,11 +3204,11 @@ fn preserve_ordering_through_repartition() -> Result<()> { let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -SortPreservingMergeExec: [d@3 ASC] - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2, preserve_order=true, sort_exprs=d@3 ASC - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[d@3 ASC], file_type=parquet -"); + SortPreservingMergeExec: [d@3 ASC] + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2, preserve_order=true, sort_exprs=d@3 ASC + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[d@3 ASC], file_type=parquet + "); let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -3232,23 +3232,23 @@ fn do_not_preserve_ordering_through_repartition() -> Result<()> { // Test: run EnforceDistribution, then EnforceSort. assert_plan!(plan_distrib, @r" -SortPreservingMergeExec: [a@0 ASC] - SortExec: expr=[a@0 ASC], preserve_partitioning=[true] - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet -"); + SortPreservingMergeExec: [a@0 ASC] + SortExec: expr=[a@0 ASC], preserve_partitioning=[true] + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet + "); // Test: result IS DIFFERENT, if EnforceSorting is run first: let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_sort, @r" -SortExec: expr=[a@0 ASC], preserve_partitioning=[false] - CoalescePartitionsExec - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet -"); + SortExec: expr=[a@0 ASC], preserve_partitioning=[false] + CoalescePartitionsExec + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet + "); Ok(()) } @@ -3267,11 +3267,11 @@ fn no_need_for_sort_after_filter() -> Result<()> { let test_config = TestConfig::default(); let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -CoalescePartitionsExec - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + CoalescePartitionsExec + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); // After CoalescePartitionsExec c is still constant. Hence c@2 ASC ordering is already satisfied. @@ -3303,24 +3303,24 @@ fn do_not_preserve_ordering_through_repartition2() -> Result<()> { // Test: run EnforceDistribution, then EnforceSort. assert_plan!(plan_distrib, @r" -SortPreservingMergeExec: [a@0 ASC] - SortExec: expr=[a@0 ASC], preserve_partitioning=[true] - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + SortPreservingMergeExec: [a@0 ASC] + SortExec: expr=[a@0 ASC], preserve_partitioning=[true] + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); // Test: result IS DIFFERENT, if EnforceSorting is run first: let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_sort, @r" -SortExec: expr=[a@0 ASC], preserve_partitioning=[false] - CoalescePartitionsExec - SortExec: expr=[a@0 ASC], preserve_partitioning=[true] - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + SortExec: expr=[a@0 ASC], preserve_partitioning=[false] + CoalescePartitionsExec + SortExec: expr=[a@0 ASC], preserve_partitioning=[true] + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); Ok(()) } @@ -3340,10 +3340,10 @@ fn do_not_preserve_ordering_through_repartition3() -> Result<()> { let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2 + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -3363,10 +3363,10 @@ fn do_not_put_sort_when_input_is_invalid() -> Result<()> { // Ordering requirement of sort required exec is NOT satisfied // by existing ordering at the source. assert_plan!(physical_plan, @r" -SortRequiredExec: [a@0 ASC] - FilterExec: c@2 = 0 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortRequiredExec: [a@0 ASC] + FilterExec: c@2 = 0 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); let mut config = ConfigOptions::new(); config.execution.target_partitions = 10; @@ -3376,11 +3376,11 @@ SortRequiredExec: [a@0 ASC] // Since at the start of the rule ordering requirement is not satisfied // EnforceDistribution rule doesn't satisfy this requirement either. assert_plan!(dist_plan, @r" -SortRequiredExec: [a@0 ASC] - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortRequiredExec: [a@0 ASC] + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); Ok(()) } @@ -3399,10 +3399,10 @@ fn put_sort_when_input_is_valid() -> Result<()> { // Ordering requirement of sort required exec is satisfied // by existing ordering at the source. assert_plan!(physical_plan, @r" -SortRequiredExec: [a@0 ASC] - FilterExec: c@2 = 0 - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet -"); + SortRequiredExec: [a@0 ASC] + FilterExec: c@2 = 0 + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet + "); let mut config = ConfigOptions::new(); config.execution.target_partitions = 10; @@ -3412,10 +3412,10 @@ SortRequiredExec: [a@0 ASC] // Since at the start of the rule ordering requirement is satisfied // EnforceDistribution rule satisfy this requirement also. assert_plan!(dist_plan, @r" -SortRequiredExec: [a@0 ASC] - FilterExec: c@2 = 0 - DataSourceExec: file_groups={10 groups: [[x:0..20], [y:0..20], [x:20..40], [y:20..40], [x:40..60], [y:40..60], [x:60..80], [y:60..80], [x:80..100], [y:80..100]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet -"); + SortRequiredExec: [a@0 ASC] + FilterExec: c@2 = 0 + DataSourceExec: file_groups={10 groups: [[x:0..20], [y:0..20], [x:20..40], [y:20..40], [x:40..60], [y:40..60], [x:60..80], [y:60..80], [x:80..100], [y:80..100]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet + "); Ok(()) } @@ -3439,10 +3439,10 @@ fn do_not_add_unnecessary_hash() -> Result<()> { let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -3469,14 +3469,14 @@ fn do_not_add_unnecessary_hash2() -> Result<()> { let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=4 - AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] - RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=2 - DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet -"); + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + AggregateExec: mode=FinalPartitioned, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=Hash([a@0], 4), input_partitions=4 + AggregateExec: mode=Partial, gby=[a@0 as a], aggr=[] + RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=2 + DataSourceExec: file_groups={2 groups: [[x], [y]]}, projection=[a, b, c, d, e], output_ordering=[c@2 ASC], file_type=parquet + "); // Since hash requirements of this operator is satisfied. There shouldn't be // a hash repartition here let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); @@ -3490,17 +3490,15 @@ fn optimize_away_unnecessary_repartition() -> Result<()> { let physical_plan = coalesce_partitions_exec(repartition_exec(parquet_exec())); assert_plan!(physical_plan, @r" -CoalescePartitionsExec - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + CoalescePartitionsExec + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); let test_config = TestConfig::default(); let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, - @r" -DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + @"DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet"); let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -3514,23 +3512,23 @@ fn optimize_away_unnecessary_repartition2() -> Result<()> { ))); assert_plan!(physical_plan, @r" -FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - CoalescePartitionsExec - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + CoalescePartitionsExec + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); let test_config = TestConfig::default(); let plan_distrib = test_config.to_plan(physical_plan.clone(), &DISTRIB_DISTRIB_SORT); assert_plan!(plan_distrib, @r" -FilterExec: c@2 = 0 - FilterExec: c@2 = 0 - RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + FilterExec: c@2 = 0 + FilterExec: c@2 = 0 + RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1 + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); let plan_sort = test_config.to_plan(physical_plan, &SORT_DISTRIB_DISTRIB); assert_plan!(plan_distrib, plan_sort); @@ -3554,29 +3552,29 @@ async fn test_distribute_sort_parquet() -> Result<()> { // prior to optimization, this is the starting plan assert_plan!(physical_plan, @r" -SortExec: expr=[c@2 ASC], preserve_partitioning=[false] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortExec: expr=[c@2 ASC], preserve_partitioning=[false] + DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet + "); // what the enforce distribution run does. let plan_distribution = test_config.to_plan(physical_plan.clone(), &[Run::Distribution]); assert_plan!(plan_distribution, @r" -SortExec: expr=[c@2 ASC], preserve_partitioning=[false] - CoalescePartitionsExec - DataSourceExec: file_groups={10 groups: [[x:0..8192000], [x:8192000..16384000], [x:16384000..24576000], [x:24576000..32768000], [x:32768000..40960000], [x:40960000..49152000], [x:49152000..57344000], [x:57344000..65536000], [x:65536000..73728000], [x:73728000..81920000]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortExec: expr=[c@2 ASC], preserve_partitioning=[false] + CoalescePartitionsExec + DataSourceExec: file_groups={10 groups: [[x:0..8192000], [x:8192000..16384000], [x:16384000..24576000], [x:24576000..32768000], [x:32768000..40960000], [x:40960000..49152000], [x:49152000..57344000], [x:57344000..65536000], [x:65536000..73728000], [x:73728000..81920000]]}, projection=[a, b, c, d, e], file_type=parquet + "); // what the sort parallelization (in enforce sorting), does after the enforce distribution changes let plan_both = test_config.to_plan(physical_plan, &[Run::Distribution, Run::Sorting]); assert_plan!(plan_both, @r" -SortPreservingMergeExec: [c@2 ASC] - SortExec: expr=[c@2 ASC], preserve_partitioning=[true] - DataSourceExec: file_groups={10 groups: [[x:0..8192000], [x:8192000..16384000], [x:16384000..24576000], [x:24576000..32768000], [x:32768000..40960000], [x:40960000..49152000], [x:49152000..57344000], [x:57344000..65536000], [x:65536000..73728000], [x:73728000..81920000]]}, projection=[a, b, c, d, e], file_type=parquet -"); + SortPreservingMergeExec: [c@2 ASC] + SortExec: expr=[c@2 ASC], preserve_partitioning=[true] + DataSourceExec: file_groups={10 groups: [[x:0..8192000], [x:8192000..16384000], [x:16384000..24576000], [x:24576000..32768000], [x:32768000..40960000], [x:40960000..49152000], [x:49152000..57344000], [x:57344000..65536000], [x:65536000..73728000], [x:73728000..81920000]]}, projection=[a, b, c, d, e], file_type=parquet + "); Ok(()) } @@ -3603,10 +3601,10 @@ async fn test_distribute_sort_memtable() -> Result<()> { // this is the final, optimized plan assert_plan!(physical_plan, @r" -SortPreservingMergeExec: [id@0 ASC NULLS LAST] - SortExec: expr=[id@0 ASC NULLS LAST], preserve_partitioning=[true] - DataSourceExec: partitions=3, partition_sizes=[34, 33, 33] -"); + SortPreservingMergeExec: [id@0 ASC NULLS LAST] + SortExec: expr=[id@0 ASC NULLS LAST], preserve_partitioning=[true] + DataSourceExec: partitions=3, partition_sizes=[34, 33, 33] + "); Ok(()) } diff --git a/datafusion/core/tests/physical_optimizer/pushdown_sort.rs b/datafusion/core/tests/physical_optimizer/pushdown_sort.rs index 131ef90e79aca..1d31374076b4f 100644 --- a/datafusion/core/tests/physical_optimizer/pushdown_sort.rs +++ b/datafusion/core/tests/physical_optimizer/pushdown_sort.rs @@ -44,7 +44,7 @@ fn test_sort_pushdown_disabled() { insta::assert_snapshot!( OptimizationTest::new(plan, PushdownSort::new(), false), - @r###" + @r" OptimizationTest: input: - SortExec: expr=[a@0 ASC], preserve_partitioning=[false] @@ -53,7 +53,7 @@ fn test_sort_pushdown_disabled() { Ok: - SortExec: expr=[a@0 ASC], preserve_partitioning=[false] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - "### + " ); } @@ -270,7 +270,7 @@ fn test_no_prefix_match_wrong_direction() { insta::assert_snapshot!( OptimizationTest::new(plan, PushdownSort::new(), true), - @r###" + @r" OptimizationTest: input: - SortExec: expr=[a@0 DESC NULLS LAST], preserve_partitioning=[false] @@ -279,7 +279,7 @@ fn test_no_prefix_match_wrong_direction() { Ok: - SortExec: expr=[a@0 DESC NULLS LAST], preserve_partitioning=[false] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[a@0 DESC NULLS LAST, b@1 ASC], file_type=parquet - "### + " ); } @@ -301,7 +301,7 @@ fn test_no_prefix_match_longer_than_source() { insta::assert_snapshot!( OptimizationTest::new(plan, PushdownSort::new(), true), - @r###" + @r" OptimizationTest: input: - SortExec: expr=[a@0 ASC, b@1 DESC NULLS LAST], preserve_partitioning=[false] @@ -310,7 +310,7 @@ fn test_no_prefix_match_longer_than_source() { Ok: - SortExec: expr=[a@0 ASC, b@1 DESC NULLS LAST], preserve_partitioning=[false] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[a@0 DESC NULLS LAST], file_type=parquet - "### + " ); } @@ -417,7 +417,7 @@ fn test_non_sort_plans_unchanged() { insta::assert_snapshot!( OptimizationTest::new(plan, PushdownSort::new(), true), - @r###" + @r" OptimizationTest: input: - CoalesceBatchesExec: target_batch_size=1024 @@ -426,7 +426,7 @@ fn test_non_sort_plans_unchanged() { Ok: - CoalesceBatchesExec: target_batch_size=1024 - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - "### + " ); } @@ -550,7 +550,7 @@ fn test_no_pushdown_for_unordered_source() { insta::assert_snapshot!( OptimizationTest::new(plan, PushdownSort::new(), true), - @r###" + @r" OptimizationTest: input: - SortExec: expr=[a@0 ASC], preserve_partitioning=[false] @@ -559,7 +559,7 @@ fn test_no_pushdown_for_unordered_source() { Ok: - SortExec: expr=[a@0 ASC], preserve_partitioning=[false] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], file_type=parquet - "### + " ); } @@ -580,7 +580,7 @@ fn test_no_pushdown_for_non_reverse_sort() { insta::assert_snapshot!( OptimizationTest::new(plan, PushdownSort::new(), true), - @r###" + @r" OptimizationTest: input: - SortExec: expr=[b@1 ASC], preserve_partitioning=[false] @@ -589,7 +589,7 @@ fn test_no_pushdown_for_non_reverse_sort() { Ok: - SortExec: expr=[b@1 ASC], preserve_partitioning=[false] - DataSourceExec: file_groups={1 group: [[x]]}, projection=[a, b, c, d, e], output_ordering=[a@0 ASC], file_type=parquet - "### + " ); } diff --git a/datafusion/core/tests/sql/aggregates/basic.rs b/datafusion/core/tests/sql/aggregates/basic.rs index 4b421b5294e01..d1b376b735ab9 100644 --- a/datafusion/core/tests/sql/aggregates/basic.rs +++ b/datafusion/core/tests/sql/aggregates/basic.rs @@ -365,7 +365,7 @@ async fn count_distinct_dictionary_all_null_values() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +-----+---------------+ | cnt | count(t.num2) | +-----+---------------+ @@ -375,7 +375,7 @@ async fn count_distinct_dictionary_all_null_values() -> Result<()> { | 0 | 1 | | 0 | 1 | +-----+---------------+ - "### + " ); // Test with multiple partitions @@ -430,13 +430,13 @@ async fn count_distinct_dictionary_mixed_values() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +------------------------+ | count(DISTINCT t.dict) | +------------------------+ | 2 | +------------------------+ - "### + " ); Ok(()) diff --git a/datafusion/core/tests/sql/aggregates/dict_nulls.rs b/datafusion/core/tests/sql/aggregates/dict_nulls.rs index da4b2c8d25c9d..f9e15a71a20f8 100644 --- a/datafusion/core/tests/sql/aggregates/dict_nulls.rs +++ b/datafusion/core/tests/sql/aggregates/dict_nulls.rs @@ -34,7 +34,7 @@ async fn test_aggregates_null_handling_comprehensive() -> Result<()> { assert_snapshot!( batches_to_string(&results_count), - @r###" + @r" +----------------+-----+ | dict_null_keys | cnt | +----------------+-----+ @@ -42,7 +42,7 @@ async fn test_aggregates_null_handling_comprehensive() -> Result<()> { | group_a | 2 | | group_b | 1 | +----------------+-----+ - "### + " ); // Test SUM null handling with extended data @@ -69,7 +69,7 @@ async fn test_aggregates_null_handling_comprehensive() -> Result<()> { assert_snapshot!( batches_to_string(&results_min), - @r###" + @r" +----------------+---------+ | dict_null_keys | minimum | +----------------+---------+ @@ -78,7 +78,7 @@ async fn test_aggregates_null_handling_comprehensive() -> Result<()> { | group_b | 1 | | group_c | 7 | +----------------+---------+ - "### + " ); // Test MEDIAN null handling with median data @@ -168,7 +168,7 @@ async fn test_first_last_value_order_by_null_handling() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +------------+-------+--------------------+---------------------+-------------------+--------------------+ | dict_group | value | first_ignore_nulls | first_respect_nulls | last_ignore_nulls | last_respect_nulls | +------------+-------+--------------------+---------------------+-------------------+--------------------+ @@ -178,7 +178,7 @@ async fn test_first_last_value_order_by_null_handling() -> Result<()> { | group_a | | 5 | | 20 | | | group_b | | 5 | | 20 | | +------------+-------+--------------------+---------------------+-------------------+--------------------+ - "### + " ); Ok(()) @@ -249,7 +249,7 @@ async fn test_first_last_value_group_by_dict_nulls() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +----------------+-----------+----------+-----+ | dict_null_keys | first_val | last_val | cnt | +----------------+-----------+----------+-----+ @@ -257,7 +257,7 @@ async fn test_first_last_value_group_by_dict_nulls() -> Result<()> { | group_a | 10 | 50 | 2 | | group_b | 30 | 30 | 1 | +----------------+-----------+----------+-----+ - "### + " ); // Test GROUP BY with null values in dictionary @@ -275,7 +275,7 @@ async fn test_first_last_value_group_by_dict_nulls() -> Result<()> { assert_snapshot!( batches_to_string(&results2), - @r###" + @r" +----------------+-----------+----------+-----+ | dict_null_vals | first_val | last_val | cnt | +----------------+-----------+----------+-----+ @@ -283,7 +283,7 @@ async fn test_first_last_value_group_by_dict_nulls() -> Result<()> { | val_x | 10 | 50 | 2 | | val_y | 30 | 30 | 1 | +----------------+-----------+----------+-----+ - "### + " ); Ok(()) @@ -394,7 +394,7 @@ async fn test_count_distinct_with_fuzz_table_dict_nulls() -> Result<()> { assert_snapshot!( batches_to_string(&results), - @r###" + @r" +--------+----------+---------------------+------+------+ | u8_low | utf8_low | dictionary_utf8_low | col1 | col2 | +--------+----------+---------------------+------+------+ @@ -405,7 +405,7 @@ async fn test_count_distinct_with_fuzz_table_dict_nulls() -> Result<()> { | 20 | text_e | | 0 | 1 | | 25 | text_f | group_gamma | 1 | 1 | +--------+----------+---------------------+------+------+ - "### + " ); Ok(()) diff --git a/datafusion/core/tests/sql/explain_analyze.rs b/datafusion/core/tests/sql/explain_analyze.rs index 201bcf178b0ec..75cd78e47aff5 100644 --- a/datafusion/core/tests/sql/explain_analyze.rs +++ b/datafusion/core/tests/sql/explain_analyze.rs @@ -346,12 +346,12 @@ async fn csv_explain_plans() { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" + @r" Explain Projection: aggregate_test_100.c1 Filter: aggregate_test_100.c2 > Int64(10) TableScan: aggregate_test_100 - "### + " ); // // verify the grahviz format of the plan @@ -417,13 +417,12 @@ async fn csv_explain_plans() { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" + @r" Explain Projection: aggregate_test_100.c1 Filter: aggregate_test_100.c2 > Int8(10) TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[aggregate_test_100.c2 > Int8(10)] - - "### + " ); // // verify the grahviz format of the plan @@ -563,12 +562,12 @@ async fn csv_explain_verbose_plans() { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" + @r" Explain Projection: aggregate_test_100.c1 Filter: aggregate_test_100.c2 > Int64(10) TableScan: aggregate_test_100 - "### + " ); // // verify the grahviz format of the plan @@ -634,12 +633,12 @@ async fn csv_explain_verbose_plans() { let actual = formatted.trim(); assert_snapshot!( actual, - @r###" + @r" Explain Projection: aggregate_test_100.c1 Filter: aggregate_test_100.c2 > Int8(10) TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[aggregate_test_100.c2 > Int8(10)] - "### + " ); // // verify the grahviz format of the plan @@ -1082,11 +1081,11 @@ async fn explain_physical_plan_only() { assert_snapshot!( actual, - @r###" + @r" physical_plan ProjectionExec: expr=[2 as count(*)] PlaceholderRowExec - "### + " ); } diff --git a/datafusion/core/tests/sql/joins.rs b/datafusion/core/tests/sql/joins.rs index c7f02e4868970..7c0e89ee96418 100644 --- a/datafusion/core/tests/sql/joins.rs +++ b/datafusion/core/tests/sql/joins.rs @@ -290,16 +290,12 @@ async fn unparse_cross_join() -> Result<()> { .await?; let unopt_sql = plan_to_sql(df.logical_plan())?; - assert_snapshot!(unopt_sql, @r#" - SELECT j1.j1_id, j2.j2_string FROM j1 CROSS JOIN j2 WHERE (j2.j2_id = 0) - "#); + assert_snapshot!(unopt_sql, @"SELECT j1.j1_id, j2.j2_string FROM j1 CROSS JOIN j2 WHERE (j2.j2_id = 0)"); let optimized_plan = df.into_optimized_plan()?; let opt_sql = plan_to_sql(&optimized_plan)?; - assert_snapshot!(opt_sql, @r#" - SELECT j1.j1_id, j2.j2_string FROM j1 CROSS JOIN j2 WHERE (j2.j2_id = 0) - "#); + assert_snapshot!(opt_sql, @"SELECT j1.j1_id, j2.j2_string FROM j1 CROSS JOIN j2 WHERE (j2.j2_id = 0)"); Ok(()) } diff --git a/datafusion/core/tests/user_defined/expr_planner.rs b/datafusion/core/tests/user_defined/expr_planner.rs index c2558fbba24dd..c5e5af731359f 100644 --- a/datafusion/core/tests/user_defined/expr_planner.rs +++ b/datafusion/core/tests/user_defined/expr_planner.rs @@ -77,25 +77,25 @@ async fn plan_and_collect(sql: &str) -> Result> { #[tokio::test] async fn test_custom_operators_arrow() { let actual = plan_and_collect("select 'foo'->'bar';").await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r#" +----------------------------+ | Utf8("foo") || Utf8("bar") | +----------------------------+ | foobar | +----------------------------+ - "###); + "#); } #[tokio::test] async fn test_custom_operators_long_arrow() { let actual = plan_and_collect("select 1->>2;").await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +---------------------+ | Int64(1) + Int64(2) | +---------------------+ | 3 | +---------------------+ - "###); + "); } #[tokio::test] @@ -103,13 +103,13 @@ async fn test_question_select() { let actual = plan_and_collect("select a ? 2 from (select 1 as a);") .await .unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +--------------+ | a ? Int64(2) | +--------------+ | true | +--------------+ - "###); + "); } #[tokio::test] @@ -117,11 +117,11 @@ async fn test_question_filter() { let actual = plan_and_collect("select a from (select 1 as a) where a ? 2;") .await .unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +---+ | a | +---+ | 1 | +---+ - "###); + "); } diff --git a/datafusion/core/tests/user_defined/relation_planner.rs b/datafusion/core/tests/user_defined/relation_planner.rs index e1c7a26184153..bda9b37ebea68 100644 --- a/datafusion/core/tests/user_defined/relation_planner.rs +++ b/datafusion/core/tests/user_defined/relation_planner.rs @@ -349,7 +349,8 @@ mod tests { | 1 | | 2 | | 3 | - +--------+"); + +--------+ + "); } // Virtual table supports standard SQL operations (projection, filter, aggregation). @@ -369,7 +370,8 @@ mod tests { +--------+ | 20 | | 30 | - +--------+"); + +--------+ + "); let aggregated = execute_sql_to_string( &ctx, @@ -383,7 +385,8 @@ mod tests { | count | total | average | +-------+-------+---------+ | 3 | 6 | 2.0 | - +-------+-------+---------+"); + +-------+-------+---------+ + "); } // Multiple planners can coexist and each handles its own virtual table. @@ -401,7 +404,8 @@ mod tests { | 1 | | 2 | | 3 | - +--------+"); + +--------+ + "); let result2 = execute_sql_to_string(&ctx, "SELECT * FROM colors").await; assert_snapshot!(result2, @r" @@ -411,7 +415,8 @@ mod tests { | red | | green | | blue | - +-------+"); + +-------+ + "); } // Last registered planner for the same table name takes precedence (LIFO). @@ -431,7 +436,8 @@ mod tests { | 1 | | 2 | | 3 | - +--------+"); + +--------+ + "); } // Pass-through planner delegates to the catalog without changing behavior. @@ -447,7 +453,8 @@ mod tests { | value | +-------+ | 42 | - +-------+"); + +-------+ + "); } // Catalog is used when no planner claims the relation. @@ -465,7 +472,8 @@ mod tests { +----+-------+ | 1 | Alice | | 2 | Bob | - +----+-------+"); + +----+-------+ + "); } // Planners can block specific constructs and surface custom error messages. @@ -513,6 +521,7 @@ mod tests { | 1 | green | | 2 | red | | 2 | green | - +--------+-------+"); + +--------+-------+ + "); } } diff --git a/datafusion/core/tests/user_defined/user_defined_aggregates.rs b/datafusion/core/tests/user_defined/user_defined_aggregates.rs index ca13b104a56cd..e7bd2241398ad 100644 --- a/datafusion/core/tests/user_defined/user_defined_aggregates.rs +++ b/datafusion/core/tests/user_defined/user_defined_aggregates.rs @@ -69,7 +69,7 @@ async fn test_setup() { let actual = execute(&ctx, sql).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +-------+----------------------------+ | value | time | +-------+----------------------------+ @@ -79,7 +79,7 @@ async fn test_setup() { | 5.0 | 1970-01-01T00:00:00.000005 | | 5.0 | 1970-01-01T00:00:00.000005 | +-------+----------------------------+ - "###); + "); } /// Basic user defined aggregate @@ -91,13 +91,13 @@ async fn test_udaf() { let actual = execute(&ctx, sql).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +----------------------------+ | time_sum(t.time) | +----------------------------+ | 1970-01-01T00:00:00.000019 | +----------------------------+ - "###); + "); // normal aggregates call update_batch assert!(test_state.update_batch()); @@ -112,7 +112,7 @@ async fn test_udaf_as_window() { let actual = execute(&ctx, sql).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +----------------------------+ | time_sum | +----------------------------+ @@ -122,7 +122,7 @@ async fn test_udaf_as_window() { | 1970-01-01T00:00:00.000019 | | 1970-01-01T00:00:00.000019 | +----------------------------+ - "###); + "); // aggregate over the entire window function call update_batch assert!(test_state.update_batch()); @@ -137,7 +137,7 @@ async fn test_udaf_as_window_with_frame() { let actual = execute(&ctx, sql).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +----------------------------+ | time_sum | +----------------------------+ @@ -147,7 +147,7 @@ async fn test_udaf_as_window_with_frame() { | 1970-01-01T00:00:00.000014 | | 1970-01-01T00:00:00.000010 | +----------------------------+ - "###); + "); // user defined aggregates with window frame should be calling retract batch assert!(test_state.update_batch()); @@ -178,13 +178,13 @@ async fn test_udaf_returning_struct() { let actual = execute(&ctx, sql).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +------------------------------------------------+ | first(t.value,t.time) | +------------------------------------------------+ | {value: 2.0, time: 1970-01-01T00:00:00.000002} | +------------------------------------------------+ - "###); + "); } /// Demonstrate extracting the fields from a structure using a subquery @@ -195,13 +195,13 @@ async fn test_udaf_returning_struct_subquery() { let actual = execute(&ctx, sql).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +-----------------+----------------------------+ | sq.first[value] | sq.first[time] | +-----------------+----------------------------+ | 2.0 | 1970-01-01T00:00:00.000002 | +-----------------+----------------------------+ - "###); + "); } #[tokio::test] @@ -215,13 +215,13 @@ async fn test_udaf_shadows_builtin_fn() { // compute with builtin `sum` aggregator let actual = execute(&ctx, sql).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r#" +---------------------------------------+ | sum(arrow_cast(t.time,Utf8("Int64"))) | +---------------------------------------+ | 19000 | +---------------------------------------+ - "###); + "#); // Register `TimeSum` with name `sum`. This will shadow the builtin one TimeSum::register(&mut ctx, test_state.clone(), "sum"); @@ -229,13 +229,13 @@ async fn test_udaf_shadows_builtin_fn() { let actual = execute(&ctx, sql).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +----------------------------+ | sum(t.time) | +----------------------------+ | 1970-01-01T00:00:00.000019 | +----------------------------+ - "###); + "); } async fn execute(ctx: &SessionContext, sql: &str) -> Result> { @@ -275,13 +275,13 @@ async fn simple_udaf() -> Result<()> { let result = ctx.sql("SELECT MY_AVG(a) FROM t").await?.collect().await?; - insta::assert_snapshot!(batches_to_string(&result), @r###" + insta::assert_snapshot!(batches_to_string(&result), @r" +-------------+ | my_avg(t.a) | +-------------+ | 3.0 | +-------------+ - "###); + "); Ok(()) } @@ -344,13 +344,13 @@ async fn case_sensitive_identifiers_user_defined_aggregates() -> Result<()> { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&result), @r###" + insta::assert_snapshot!(batches_to_string(&result), @r" +-------------+ | MY_AVG(t.i) | +-------------+ | 1.0 | +-------------+ - "###); + "); Ok(()) } @@ -376,13 +376,13 @@ async fn test_user_defined_functions_with_alias() -> Result<()> { let result = plan_and_collect(&ctx, "SELECT dummy(i) FROM t").await?; - insta::assert_snapshot!(batches_to_string(&result), @r###" + insta::assert_snapshot!(batches_to_string(&result), @r" +------------+ | dummy(t.i) | +------------+ | 1.0 | +------------+ - "###); + "); let alias_result = plan_and_collect(&ctx, "SELECT dummy_alias(i) FROM t").await?; @@ -453,13 +453,13 @@ async fn test_parameterized_aggregate_udf() -> Result<()> { let actual = DataFrame::new(ctx.state(), plan).collect().await?; - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +------+---+---+ | text | a | b | +------+---+---+ | foo | 1 | 2 | +------+---+---+ - "###); + "); ctx.deregister_table("t")?; Ok(()) diff --git a/datafusion/core/tests/user_defined/user_defined_plan.rs b/datafusion/core/tests/user_defined/user_defined_plan.rs index 6d98d6823c458..d53e076739608 100644 --- a/datafusion/core/tests/user_defined/user_defined_plan.rs +++ b/datafusion/core/tests/user_defined/user_defined_plan.rs @@ -161,7 +161,7 @@ async fn run_and_compare_query(ctx: SessionContext, description: &str) -> Result insta::with_settings!({ description => description, }, { - insta::assert_snapshot!(actual, @r###" + insta::assert_snapshot!(actual, @r" +-------------+---------+ | customer_id | revenue | +-------------+---------+ @@ -169,7 +169,7 @@ async fn run_and_compare_query(ctx: SessionContext, description: &str) -> Result | jorge | 200 | | andy | 150 | +-------------+---------+ - "###); + "); }); } @@ -188,13 +188,13 @@ async fn run_and_compare_query_with_analyzer_rule( insta::with_settings!({ description => description, }, { - insta::assert_snapshot!(actual, @r###" + insta::assert_snapshot!(actual, @r" +------------+--------------------------+ | UInt64(42) | arrow_typeof(UInt64(42)) | +------------+--------------------------+ | 42 | UInt64 | +------------+--------------------------+ - "###); + "); }); Ok(()) @@ -212,7 +212,7 @@ async fn run_and_compare_query_with_auto_schemas( insta::with_settings!({ description => description, }, { - insta::assert_snapshot!(actual, @r###" + insta::assert_snapshot!(actual, @r" +----------+----------+ | column_1 | column_2 | +----------+----------+ @@ -220,7 +220,7 @@ async fn run_and_compare_query_with_auto_schemas( | jorge | 200 | | andy | 150 | +----------+----------+ - "###); + "); }); Ok(()) diff --git a/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs b/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs index d0be7243260e1..b86cd94a8a9b7 100644 --- a/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs +++ b/datafusion/core/tests/user_defined/user_defined_scalar_functions.rs @@ -65,13 +65,13 @@ async fn csv_query_custom_udf_with_cast() -> Result<()> { let sql = "SELECT avg(custom_sqrt(c11)) FROM aggregate_test_100"; let actual = plan_and_collect(&ctx, sql).await?; - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +------------------------------------------+ | avg(custom_sqrt(aggregate_test_100.c11)) | +------------------------------------------+ | 0.6584408483418835 | +------------------------------------------+ - "###); + "); Ok(()) } @@ -84,13 +84,13 @@ async fn csv_query_avg_sqrt() -> Result<()> { let sql = "SELECT avg(custom_sqrt(c12)) FROM aggregate_test_100"; let actual = plan_and_collect(&ctx, sql).await?; - insta::assert_snapshot!(batches_to_string(&actual), @r###" + insta::assert_snapshot!(batches_to_string(&actual), @r" +------------------------------------------+ | avg(custom_sqrt(aggregate_test_100.c12)) | +------------------------------------------+ | 0.6706002946036459 | +------------------------------------------+ - "###); + "); Ok(()) } @@ -155,7 +155,7 @@ async fn scalar_udf() -> Result<()> { let result = DataFrame::new(ctx.state(), plan).collect().await?; - insta::assert_snapshot!(batches_to_string(&result), @r###" + insta::assert_snapshot!(batches_to_string(&result), @r" +-----+-----+-----------------+ | a | b | my_add(t.a,t.b) | +-----+-----+-----------------+ @@ -164,7 +164,7 @@ async fn scalar_udf() -> Result<()> { | 10 | 12 | 22 | | 100 | 120 | 220 | +-----+-----+-----------------+ - "###); + "); let batch = &result[0]; let a = as_int32_array(batch.column(0))?; @@ -281,7 +281,7 @@ async fn scalar_udf_zero_params() -> Result<()> { ctx.register_udf(ScalarUDF::from(get_100_udf)); let result = plan_and_collect(&ctx, "select get_100() a from t").await?; - insta::assert_snapshot!(batches_to_string(&result), @r###" + insta::assert_snapshot!(batches_to_string(&result), @r" +-----+ | a | +-----+ @@ -290,22 +290,22 @@ async fn scalar_udf_zero_params() -> Result<()> { | 100 | | 100 | +-----+ - "###); + "); let result = plan_and_collect(&ctx, "select get_100() a").await?; - insta::assert_snapshot!(batches_to_string(&result), @r###" + insta::assert_snapshot!(batches_to_string(&result), @r" +-----+ | a | +-----+ | 100 | +-----+ - "###); + "); let result = plan_and_collect(&ctx, "select get_100() from t where a=999").await?; - insta::assert_snapshot!(batches_to_string(&result), @r###" + insta::assert_snapshot!(batches_to_string(&result), @r" ++ ++ - "###); + "); Ok(()) } @@ -332,13 +332,13 @@ async fn scalar_udf_override_built_in_scalar_function() -> Result<()> { // Make sure that the UDF is used instead of the built-in function let result = plan_and_collect(&ctx, "select abs(a) a from t").await?; - insta::assert_snapshot!(batches_to_string(&result), @r###" + insta::assert_snapshot!(batches_to_string(&result), @r" +---+ | a | +---+ | 1 | +---+ - "###); + "); Ok(()) } @@ -435,13 +435,13 @@ async fn case_sensitive_identifiers_user_defined_functions() -> Result<()> { // Can call it if you put quotes let result = plan_and_collect(&ctx, "SELECT \"MY_FUNC\"(i) FROM t").await?; - insta::assert_snapshot!(batches_to_string(&result), @r###" + insta::assert_snapshot!(batches_to_string(&result), @r" +--------------+ | MY_FUNC(t.i) | +--------------+ | 1 | +--------------+ - "###); + "); Ok(()) } @@ -472,13 +472,13 @@ async fn test_user_defined_functions_with_alias() -> Result<()> { ctx.register_udf(udf); let result = plan_and_collect(&ctx, "SELECT dummy(i) FROM t").await?; - insta::assert_snapshot!(batches_to_string(&result), @r###" + insta::assert_snapshot!(batches_to_string(&result), @r" +------------+ | dummy(t.i) | +------------+ | 1 | +------------+ - "###); + "); let alias_result = plan_and_collect(&ctx, "SELECT dummy_alias(i) FROM t").await?; insta::assert_snapshot!(batches_to_string(&alias_result), @r" diff --git a/datafusion/core/tests/user_defined/user_defined_table_functions.rs b/datafusion/core/tests/user_defined/user_defined_table_functions.rs index bc3a472078107..8be8609c62480 100644 --- a/datafusion/core/tests/user_defined/user_defined_table_functions.rs +++ b/datafusion/core/tests/user_defined/user_defined_table_functions.rs @@ -55,7 +55,7 @@ async fn test_simple_read_csv_udtf() -> Result<()> { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&rbs), @r###" + insta::assert_snapshot!(batches_to_string(&rbs), @r" +-------------+-----------+-------------+-------------------------------------------------------------------------------------------------------------+ | n_nationkey | n_name | n_regionkey | n_comment | +-------------+-----------+-------------+-------------------------------------------------------------------------------------------------------------+ @@ -65,7 +65,7 @@ async fn test_simple_read_csv_udtf() -> Result<()> { | 4 | EGYPT | 4 | y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d | | 5 | ETHIOPIA | 0 | ven packages wake quickly. regu | +-------------+-----------+-------------+-------------------------------------------------------------------------------------------------------------+ - "###); + "); // just run, return all rows let rbs = ctx @@ -74,7 +74,7 @@ async fn test_simple_read_csv_udtf() -> Result<()> { .collect() .await?; - insta::assert_snapshot!(batches_to_string(&rbs), @r###" + insta::assert_snapshot!(batches_to_string(&rbs), @r" +-------------+-----------+-------------+--------------------------------------------------------------------------------------------------------------------+ | n_nationkey | n_name | n_regionkey | n_comment | +-------------+-----------+-------------+--------------------------------------------------------------------------------------------------------------------+ @@ -89,7 +89,7 @@ async fn test_simple_read_csv_udtf() -> Result<()> { | 9 | INDONESIA | 2 | slyly express asymptotes. regular deposits haggle slyly. carefully ironic hockey players sleep blithely. carefull | | 10 | IRAN | 4 | efully alongside of the slyly final dependencies. | +-------------+-----------+-------------+--------------------------------------------------------------------------------------------------------------------+ - "###); + "); Ok(()) } diff --git a/datafusion/core/tests/user_defined/user_defined_window_functions.rs b/datafusion/core/tests/user_defined/user_defined_window_functions.rs index f62cab523f383..57baf271c5913 100644 --- a/datafusion/core/tests/user_defined/user_defined_window_functions.rs +++ b/datafusion/core/tests/user_defined/user_defined_window_functions.rs @@ -74,22 +74,22 @@ async fn test_setup() { let sql = "SELECT * from t order by x, y"; let actual = execute(&ctx, sql).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" - +---+---+-----+ - | x | y | val | - +---+---+-----+ - | 1 | a | 0 | - | 1 | b | 1 | - | 1 | c | 2 | - | 2 | d | 3 | - | 2 | e | 4 | - | 2 | f | 5 | - | 2 | g | 6 | - | 2 | h | 6 | - | 2 | i | 6 | - | 2 | j | 6 | - +---+---+-----+ - "###); + insta::assert_snapshot!(batches_to_string(&actual), @r" + +---+---+-----+ + | x | y | val | + +---+---+-----+ + | 1 | a | 0 | + | 1 | b | 1 | + | 1 | c | 2 | + | 2 | d | 3 | + | 2 | e | 4 | + | 2 | f | 5 | + | 2 | g | 6 | + | 2 | h | 6 | + | 2 | i | 6 | + | 2 | j | 6 | + +---+---+-----+ + "); } /// Basic user defined window function @@ -100,22 +100,22 @@ async fn test_udwf() { let actual = execute(&ctx, UNBOUNDED_WINDOW_QUERY).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" - +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ - | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | - +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ - | 1 | a | 0 | 1 | - | 1 | b | 1 | 1 | - | 1 | c | 2 | 1 | - | 2 | d | 3 | 2 | - | 2 | e | 4 | 2 | - | 2 | f | 5 | 2 | - | 2 | g | 6 | 2 | - | 2 | h | 6 | 2 | - | 2 | i | 6 | 2 | - | 2 | j | 6 | 2 | - +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ - "###); + insta::assert_snapshot!(batches_to_string(&actual), @r" + +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ + | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | + +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ + | 1 | a | 0 | 1 | + | 1 | b | 1 | 1 | + | 1 | c | 2 | 1 | + | 2 | d | 3 | 2 | + | 2 | e | 4 | 2 | + | 2 | f | 5 | 2 | + | 2 | g | 6 | 2 | + | 2 | h | 6 | 2 | + | 2 | i | 6 | 2 | + | 2 | j | 6 | 2 | + +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ + "); // evaluated on two distinct batches assert_eq!(test_state.evaluate_all_called(), 2); @@ -174,22 +174,22 @@ async fn test_udwf_bounded_window_ignores_frame() { // Since the UDWF doesn't say it needs the window frame, the frame is ignored let actual = execute(&ctx, BOUNDED_WINDOW_QUERY).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING | - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - | 1 | a | 0 | 1 | - | 1 | b | 1 | 1 | - | 1 | c | 2 | 1 | - | 2 | d | 3 | 2 | - | 2 | e | 4 | 2 | - | 2 | f | 5 | 2 | - | 2 | g | 6 | 2 | - | 2 | h | 6 | 2 | - | 2 | i | 6 | 2 | - | 2 | j | 6 | 2 | - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - "###); + insta::assert_snapshot!(batches_to_string(&actual), @r" + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING | + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + | 1 | a | 0 | 1 | + | 1 | b | 1 | 1 | + | 1 | c | 2 | 1 | + | 2 | d | 3 | 2 | + | 2 | e | 4 | 2 | + | 2 | f | 5 | 2 | + | 2 | g | 6 | 2 | + | 2 | h | 6 | 2 | + | 2 | i | 6 | 2 | + | 2 | j | 6 | 2 | + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + "); // evaluated on 2 distinct batches (when x=1 and x=2) assert_eq!(test_state.evaluate_called(), 0); @@ -204,22 +204,22 @@ async fn test_udwf_bounded_window() { let actual = execute(&ctx, BOUNDED_WINDOW_QUERY).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING | - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - | 1 | a | 0 | 1 | - | 1 | b | 1 | 1 | - | 1 | c | 2 | 1 | - | 2 | d | 3 | 1 | - | 2 | e | 4 | 2 | - | 2 | f | 5 | 1 | - | 2 | g | 6 | 1 | - | 2 | h | 6 | 0 | - | 2 | i | 6 | 0 | - | 2 | j | 6 | 0 | - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - "###); + insta::assert_snapshot!(batches_to_string(&actual), @r" + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING | + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + | 1 | a | 0 | 1 | + | 1 | b | 1 | 1 | + | 1 | c | 2 | 1 | + | 2 | d | 3 | 1 | + | 2 | e | 4 | 2 | + | 2 | f | 5 | 1 | + | 2 | g | 6 | 1 | + | 2 | h | 6 | 0 | + | 2 | i | 6 | 0 | + | 2 | j | 6 | 0 | + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + "); // Evaluate is called for each input rows assert_eq!(test_state.evaluate_called(), 10); @@ -236,22 +236,22 @@ async fn test_stateful_udwf() { let actual = execute(&ctx, UNBOUNDED_WINDOW_QUERY).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" - +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ - | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | - +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ - | 1 | a | 0 | 0 | - | 1 | b | 1 | 1 | - | 1 | c | 2 | 1 | - | 2 | d | 3 | 1 | - | 2 | e | 4 | 1 | - | 2 | f | 5 | 2 | - | 2 | g | 6 | 2 | - | 2 | h | 6 | 2 | - | 2 | i | 6 | 2 | - | 2 | j | 6 | 2 | - +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ - "###); + insta::assert_snapshot!(batches_to_string(&actual), @r" + +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ + | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | + +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ + | 1 | a | 0 | 0 | + | 1 | b | 1 | 1 | + | 1 | c | 2 | 1 | + | 2 | d | 3 | 1 | + | 2 | e | 4 | 1 | + | 2 | f | 5 | 2 | + | 2 | g | 6 | 2 | + | 2 | h | 6 | 2 | + | 2 | i | 6 | 2 | + | 2 | j | 6 | 2 | + +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ + "); assert_eq!(test_state.evaluate_called(), 10); assert_eq!(test_state.evaluate_all_called(), 0); @@ -267,22 +267,22 @@ async fn test_stateful_udwf_bounded_window() { let actual = execute(&ctx, BOUNDED_WINDOW_QUERY).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING | - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - | 1 | a | 0 | 1 | - | 1 | b | 1 | 1 | - | 1 | c | 2 | 1 | - | 2 | d | 3 | 1 | - | 2 | e | 4 | 2 | - | 2 | f | 5 | 1 | - | 2 | g | 6 | 1 | - | 2 | h | 6 | 0 | - | 2 | i | 6 | 0 | - | 2 | j | 6 | 0 | - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - "###); + insta::assert_snapshot!(batches_to_string(&actual), @r" + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING | + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + | 1 | a | 0 | 1 | + | 1 | b | 1 | 1 | + | 1 | c | 2 | 1 | + | 2 | d | 3 | 1 | + | 2 | e | 4 | 2 | + | 2 | f | 5 | 1 | + | 2 | g | 6 | 1 | + | 2 | h | 6 | 0 | + | 2 | i | 6 | 0 | + | 2 | j | 6 | 0 | + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + "); // Evaluate and update_state is called for each input row assert_eq!(test_state.evaluate_called(), 10); @@ -297,22 +297,22 @@ async fn test_udwf_query_include_rank() { let actual = execute(&ctx, UNBOUNDED_WINDOW_QUERY).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" - +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ - | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | - +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ - | 1 | a | 0 | 3 | - | 1 | b | 1 | 2 | - | 1 | c | 2 | 1 | - | 2 | d | 3 | 7 | - | 2 | e | 4 | 6 | - | 2 | f | 5 | 5 | - | 2 | g | 6 | 4 | - | 2 | h | 6 | 3 | - | 2 | i | 6 | 2 | - | 2 | j | 6 | 1 | - +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ - "###); + insta::assert_snapshot!(batches_to_string(&actual), @r" + +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ + | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | + +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ + | 1 | a | 0 | 3 | + | 1 | b | 1 | 2 | + | 1 | c | 2 | 1 | + | 2 | d | 3 | 7 | + | 2 | e | 4 | 6 | + | 2 | f | 5 | 5 | + | 2 | g | 6 | 4 | + | 2 | h | 6 | 3 | + | 2 | i | 6 | 2 | + | 2 | j | 6 | 1 | + +---+---+-----+-----------------------------------------------------------------------------------------------------------------------+ + "); assert_eq!(test_state.evaluate_called(), 0); assert_eq!(test_state.evaluate_all_called(), 0); @@ -328,22 +328,22 @@ async fn test_udwf_bounded_query_include_rank() { let actual = execute(&ctx, BOUNDED_WINDOW_QUERY).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING | - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - | 1 | a | 0 | 3 | - | 1 | b | 1 | 2 | - | 1 | c | 2 | 1 | - | 2 | d | 3 | 7 | - | 2 | e | 4 | 6 | - | 2 | f | 5 | 5 | - | 2 | g | 6 | 4 | - | 2 | h | 6 | 3 | - | 2 | i | 6 | 2 | - | 2 | j | 6 | 1 | - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - "###); + insta::assert_snapshot!(batches_to_string(&actual), @r" + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING | + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + | 1 | a | 0 | 3 | + | 1 | b | 1 | 2 | + | 1 | c | 2 | 1 | + | 2 | d | 3 | 7 | + | 2 | e | 4 | 6 | + | 2 | f | 5 | 5 | + | 2 | g | 6 | 4 | + | 2 | h | 6 | 3 | + | 2 | i | 6 | 2 | + | 2 | j | 6 | 1 | + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + "); assert_eq!(test_state.evaluate_called(), 0); assert_eq!(test_state.evaluate_all_called(), 0); @@ -361,22 +361,22 @@ async fn test_udwf_bounded_window_returns_null() { let actual = execute(&ctx, BOUNDED_WINDOW_QUERY).await.unwrap(); - insta::assert_snapshot!(batches_to_string(&actual), @r###" - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING | - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - | 1 | a | 0 | 1 | - | 1 | b | 1 | 1 | - | 1 | c | 2 | 1 | - | 2 | d | 3 | 1 | - | 2 | e | 4 | 2 | - | 2 | f | 5 | 1 | - | 2 | g | 6 | 1 | - | 2 | h | 6 | | - | 2 | i | 6 | | - | 2 | j | 6 | | - +---+---+-----+--------------------------------------------------------------------------------------------------------------+ - "###); + insta::assert_snapshot!(batches_to_string(&actual), @r" + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + | x | y | val | odd_counter(t.val) PARTITION BY [t.x] ORDER BY [t.y ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING | + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + | 1 | a | 0 | 1 | + | 1 | b | 1 | 1 | + | 1 | c | 2 | 1 | + | 2 | d | 3 | 1 | + | 2 | e | 4 | 2 | + | 2 | f | 5 | 1 | + | 2 | g | 6 | 1 | + | 2 | h | 6 | | + | 2 | i | 6 | | + | 2 | j | 6 | | + +---+---+-----+--------------------------------------------------------------------------------------------------------------+ + "); // Evaluate is called for each input rows assert_eq!(test_state.evaluate_called(), 10); diff --git a/datafusion/execution/src/memory_pool/pool.rs b/datafusion/execution/src/memory_pool/pool.rs index b4e16496202cc..bf74b5f6f4c6b 100644 --- a/datafusion/execution/src/memory_pool/pool.rs +++ b/datafusion/execution/src/memory_pool/pool.rs @@ -724,11 +724,11 @@ mod tests { assert!(res.is_err()); let error = res.unwrap_err().strip_backtrace(); allow_duplicates!(assert_snapshot!(error, @r" - Resources exhausted: Additional allocation failed for r0 with top memory consumers (across reservations) as: - r1#[ID](can spill: false) consumed 20.0 B, peak 20.0 B, - r0#[ID](can spill: false) consumed 10.0 B, peak 10.0 B. - Error: Failed to allocate additional 150.0 B for r0 with 10.0 B already allocated for this reservation - 70.0 B remain available for the total pool - ")); + Resources exhausted: Additional allocation failed for r0 with top memory consumers (across reservations) as: + r1#[ID](can spill: false) consumed 20.0 B, peak 20.0 B, + r0#[ID](can spill: false) consumed 10.0 B, peak 10.0 B. + Error: Failed to allocate additional 150.0 B for r0 with 10.0 B already allocated for this reservation - 70.0 B remain available for the total pool + ")); // Test: unregister one // only the remaining one should be listed @@ -737,10 +737,10 @@ mod tests { assert!(res.is_err()); let error = res.unwrap_err().strip_backtrace(); allow_duplicates!(assert_snapshot!(error, @r" - Resources exhausted: Additional allocation failed for r0 with top memory consumers (across reservations) as: - r0#[ID](can spill: false) consumed 10.0 B, peak 10.0 B. - Error: Failed to allocate additional 150.0 B for r0 with 10.0 B already allocated for this reservation - 90.0 B remain available for the total pool - ")); + Resources exhausted: Additional allocation failed for r0 with top memory consumers (across reservations) as: + r0#[ID](can spill: false) consumed 10.0 B, peak 10.0 B. + Error: Failed to allocate additional 150.0 B for r0 with 10.0 B already allocated for this reservation - 90.0 B remain available for the total pool + ")); // Test: actual message we see is the `available is 70`. When it should be `available is 90`. // This is because the pool.shrink() does not automatically occur within the inner_pool.deregister(). @@ -748,10 +748,10 @@ mod tests { assert!(res.is_err()); let error = res.unwrap_err().strip_backtrace(); allow_duplicates!(assert_snapshot!(error, @r" - Resources exhausted: Additional allocation failed for r0 with top memory consumers (across reservations) as: - r0#[ID](can spill: false) consumed 10.0 B, peak 10.0 B. - Error: Failed to allocate additional 150.0 B for r0 with 10.0 B already allocated for this reservation - 90.0 B remain available for the total pool - ")); + Resources exhausted: Additional allocation failed for r0 with top memory consumers (across reservations) as: + r0#[ID](can spill: false) consumed 10.0 B, peak 10.0 B. + Error: Failed to allocate additional 150.0 B for r0 with 10.0 B already allocated for this reservation - 90.0 B remain available for the total pool + ")); // Test: the registration needs to free itself (or be dropped), // for the proper error message @@ -759,10 +759,10 @@ mod tests { assert!(res.is_err()); let error = res.unwrap_err().strip_backtrace(); allow_duplicates!(assert_snapshot!(error, @r" - Resources exhausted: Additional allocation failed for r0 with top memory consumers (across reservations) as: - r0#[ID](can spill: false) consumed 10.0 B, peak 10.0 B. - Error: Failed to allocate additional 150.0 B for r0 with 10.0 B already allocated for this reservation - 90.0 B remain available for the total pool - ")); + Resources exhausted: Additional allocation failed for r0 with top memory consumers (across reservations) as: + r0#[ID](can spill: false) consumed 10.0 B, peak 10.0 B. + Error: Failed to allocate additional 150.0 B for r0 with 10.0 B already allocated for this reservation - 90.0 B remain available for the total pool + ")); } let tracked_spill_pool: Arc = Arc::new(TrackConsumersPool::new( diff --git a/datafusion/optimizer/src/decorrelate_predicate_subquery.rs b/datafusion/optimizer/src/decorrelate_predicate_subquery.rs index 9a8583b51a80e..c8acb044876c4 100644 --- a/datafusion/optimizer/src/decorrelate_predicate_subquery.rs +++ b/datafusion/optimizer/src/decorrelate_predicate_subquery.rs @@ -613,7 +613,7 @@ mod tests { assert_optimized_plan_equal!( plan, - @r###" + @r" Projection: customer.c_custkey [c_custkey:Int64] LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_2.o_custkey [c_custkey:Int64, c_name:Utf8] LeftSemi Join: Filter: customer.c_custkey = __correlated_sq_1.o_custkey [c_custkey:Int64, c_name:Utf8] @@ -624,7 +624,7 @@ mod tests { SubqueryAlias: __correlated_sq_2 [o_custkey:Int64] Projection: orders.o_custkey [o_custkey:Int64] TableScan: orders [o_orderkey:Int64, o_custkey:Int64, o_orderstatus:Utf8, o_totalprice:Float64;N] - "### + " ) } diff --git a/datafusion/optimizer/src/optimize_unions.rs b/datafusion/optimizer/src/optimize_unions.rs index 18234dd124a82..900757b9a0607 100644 --- a/datafusion/optimizer/src/optimize_unions.rs +++ b/datafusion/optimizer/src/optimize_unions.rs @@ -497,9 +497,7 @@ mod tests { OptimizerContext::new().with_max_passes(1), vec![Arc::new(OptimizeUnions::new())], plan, - @r" - TableScan: table - " + @"TableScan: table" ) } } diff --git a/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs b/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs index 0e1e44e92720f..1b25c5ce8a632 100644 --- a/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs +++ b/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs @@ -219,7 +219,7 @@ mod tests { assert_optimized_plan_equal!( table_scan, - @ r"TableScan: test projection=[a], full_filters=[Boolean(true)]" + @ "TableScan: test projection=[a], full_filters=[Boolean(true)]" ) } @@ -252,10 +252,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: test.b > Int32(1) - Projection: test.a - TableScan: test - " + Filter: test.b > Int32(1) + Projection: test.a + TableScan: test + " ) } @@ -270,10 +270,10 @@ mod tests { assert_optimized_plan_equal!( plan, @ r" - Filter: test.b > Int32(1) - Projection: test.a - TableScan: test - " + Filter: test.b > Int32(1) + Projection: test.a + TableScan: test + " ) } diff --git a/datafusion/optimizer/tests/optimizer_integration.rs b/datafusion/optimizer/tests/optimizer_integration.rs index 951d78bc899c6..36a6df54ddaf0 100644 --- a/datafusion/optimizer/tests/optimizer_integration.rs +++ b/datafusion/optimizer/tests/optimizer_integration.rs @@ -67,22 +67,22 @@ fn recursive_cte_with_nested_subquery() -> Result<()> { assert_snapshot!( format!("{plan}"), - @r#" - SubqueryAlias: numbers - Projection: sub.id AS id, sub.level AS level - RecursiveQuery: is_distinct=false - Projection: sub.id, sub.level - SubqueryAlias: sub - Projection: test.col_int32 AS id, Int64(1) AS level - TableScan: test - Projection: t.col_int32, numbers.level + Int64(1) - Inner Join: CAST(t.col_int32 AS Int64) = CAST(numbers.id AS Int64) + Int64(1) - SubqueryAlias: t - Filter: CAST(test.col_int32 AS Int64) IS NOT NULL - TableScan: test - Filter: CAST(numbers.id AS Int64) + Int64(1) IS NOT NULL - TableScan: numbers - "# + @r" + SubqueryAlias: numbers + Projection: sub.id AS id, sub.level AS level + RecursiveQuery: is_distinct=false + Projection: sub.id, sub.level + SubqueryAlias: sub + Projection: test.col_int32 AS id, Int64(1) AS level + TableScan: test + Projection: t.col_int32, numbers.level + Int64(1) + Inner Join: CAST(t.col_int32 AS Int64) = CAST(numbers.id AS Int64) + Int64(1) + SubqueryAlias: t + Filter: CAST(test.col_int32 AS Int64) IS NOT NULL + TableScan: test + Filter: CAST(numbers.id AS Int64) + Int64(1) IS NOT NULL + TableScan: numbers + " ); Ok(()) @@ -95,10 +95,10 @@ fn case_when() -> Result<()> { assert_snapshot!( format!("{plan}"), - @r#" -Projection: CASE WHEN test.col_int32 > Int32(0) THEN Int64(1) ELSE Int64(0) END AS CASE WHEN test.col_int32 > Int64(0) THEN Int64(1) ELSE Int64(0) END - TableScan: test projection=[col_int32] -"# + @r" + Projection: CASE WHEN test.col_int32 > Int32(0) THEN Int64(1) ELSE Int64(0) END AS CASE WHEN test.col_int32 > Int64(0) THEN Int64(1) ELSE Int64(0) END + TableScan: test projection=[col_int32] + " ); let sql = "SELECT CASE WHEN col_uint32 > 0 THEN 1 ELSE 0 END FROM test"; @@ -106,10 +106,10 @@ Projection: CASE WHEN test.col_int32 > Int32(0) THEN Int64(1) ELSE Int64(0) END assert_snapshot!( format!("{plan}"), - @r#" + @r" Projection: CASE WHEN test.col_uint32 > UInt32(0) THEN Int64(1) ELSE Int64(0) END AS CASE WHEN test.col_uint32 > Int64(0) THEN Int64(1) ELSE Int64(0) END TableScan: test projection=[col_uint32] - "# + " ); Ok(()) } @@ -149,11 +149,11 @@ fn case_when_aggregate() -> Result<()> { assert_snapshot!( format!("{plan}"), - @r#" - Projection: test.col_utf8, sum(CASE WHEN test.col_int32 > Int64(0) THEN Int64(1) ELSE Int64(0) END) AS n - Aggregate: groupBy=[[test.col_utf8]], aggr=[[sum(CASE WHEN test.col_int32 > Int32(0) THEN Int64(1) ELSE Int64(0) END) AS sum(CASE WHEN test.col_int32 > Int64(0) THEN Int64(1) ELSE Int64(0) END)]] - TableScan: test projection=[col_int32, col_utf8] - "# + @r" + Projection: test.col_utf8, sum(CASE WHEN test.col_int32 > Int64(0) THEN Int64(1) ELSE Int64(0) END) AS n + Aggregate: groupBy=[[test.col_utf8]], aggr=[[sum(CASE WHEN test.col_int32 > Int32(0) THEN Int64(1) ELSE Int64(0) END) AS sum(CASE WHEN test.col_int32 > Int64(0) THEN Int64(1) ELSE Int64(0) END)]] + TableScan: test projection=[col_int32, col_utf8] + " ); Ok(()) } @@ -165,11 +165,11 @@ fn unsigned_target_type() -> Result<()> { assert_snapshot!( format!("{plan}"), - @r#" + @r" Projection: test.col_utf8 Filter: test.col_uint32 > UInt32(0) TableScan: test projection=[col_uint32, col_utf8] - "# + " ); Ok(()) } @@ -182,10 +182,10 @@ fn distribute_by() -> Result<()> { assert_snapshot!( format!("{plan}"), - @r#" - Repartition: DistributeBy(test.col_utf8) - TableScan: test projection=[col_int32, col_utf8] - "# + @r" + Repartition: DistributeBy(test.col_utf8) + TableScan: test projection=[col_int32, col_utf8] + " ); Ok(()) } @@ -200,16 +200,16 @@ fn semi_join_with_join_filter() -> Result<()> { assert_snapshot!( format!("{plan}"), - @r#" - Projection: test.col_utf8 - LeftSemi Join: test.col_int32 = __correlated_sq_1.col_int32 Filter: test.col_uint32 != __correlated_sq_1.col_uint32 + @r" + Projection: test.col_utf8 + LeftSemi Join: test.col_int32 = __correlated_sq_1.col_int32 Filter: test.col_uint32 != __correlated_sq_1.col_uint32 + Filter: test.col_int32 IS NOT NULL + TableScan: test projection=[col_int32, col_uint32, col_utf8] + SubqueryAlias: __correlated_sq_1 + SubqueryAlias: t2 Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32, col_uint32, col_utf8] - SubqueryAlias: __correlated_sq_1 - SubqueryAlias: t2 - Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32, col_uint32] - "# + TableScan: test projection=[col_int32, col_uint32] + " ); Ok(()) } @@ -224,15 +224,15 @@ fn anti_join_with_join_filter() -> Result<()> { assert_snapshot!( format!("{plan}"), - @r#" -Projection: test.col_utf8 - LeftAnti Join: test.col_int32 = __correlated_sq_1.col_int32 Filter: test.col_uint32 != __correlated_sq_1.col_uint32 - TableScan: test projection=[col_int32, col_uint32, col_utf8] - SubqueryAlias: __correlated_sq_1 - SubqueryAlias: t2 - Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32, col_uint32] -"# + @r" + Projection: test.col_utf8 + LeftAnti Join: test.col_int32 = __correlated_sq_1.col_int32 Filter: test.col_uint32 != __correlated_sq_1.col_uint32 + TableScan: test projection=[col_int32, col_uint32, col_utf8] + SubqueryAlias: __correlated_sq_1 + SubqueryAlias: t2 + Filter: test.col_int32 IS NOT NULL + TableScan: test projection=[col_int32, col_uint32] + " ); Ok(()) } @@ -245,16 +245,16 @@ fn where_exists_distinct() -> Result<()> { assert_snapshot!( format!("{plan}"), - @r#" -LeftSemi Join: test.col_int32 = __correlated_sq_1.col_int32 - Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32] - SubqueryAlias: __correlated_sq_1 - Aggregate: groupBy=[[t2.col_int32]], aggr=[[]] - SubqueryAlias: t2 - Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32] -"# + @r" + LeftSemi Join: test.col_int32 = __correlated_sq_1.col_int32 + Filter: test.col_int32 IS NOT NULL + TableScan: test projection=[col_int32] + SubqueryAlias: __correlated_sq_1 + Aggregate: groupBy=[[t2.col_int32]], aggr=[[]] + SubqueryAlias: t2 + Filter: test.col_int32 IS NOT NULL + TableScan: test projection=[col_int32] + " ); Ok(()) @@ -269,17 +269,17 @@ fn intersect() -> Result<()> { assert_snapshot!( format!("{plan}"), - @r#" -LeftSemi Join: left.col_int32 = test.col_int32, left.col_utf8 = test.col_utf8 - Aggregate: groupBy=[[left.col_int32, left.col_utf8]], aggr=[[]] - LeftSemi Join: left.col_int32 = right.col_int32, left.col_utf8 = right.col_utf8 + @r" + LeftSemi Join: left.col_int32 = test.col_int32, left.col_utf8 = test.col_utf8 Aggregate: groupBy=[[left.col_int32, left.col_utf8]], aggr=[[]] - SubqueryAlias: left - TableScan: test projection=[col_int32, col_utf8] - SubqueryAlias: right - TableScan: test projection=[col_int32, col_utf8] - TableScan: test projection=[col_int32, col_utf8] -"# + LeftSemi Join: left.col_int32 = right.col_int32, left.col_utf8 = right.col_utf8 + Aggregate: groupBy=[[left.col_int32, left.col_utf8]], aggr=[[]] + SubqueryAlias: left + TableScan: test projection=[col_int32, col_utf8] + SubqueryAlias: right + TableScan: test projection=[col_int32, col_utf8] + TableScan: test projection=[col_int32, col_utf8] + " ); Ok(()) } @@ -293,11 +293,11 @@ fn between_date32_plus_interval() -> Result<()> { assert_snapshot!( format!("{plan}"), @r#" -Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] - Projection: - Filter: test.col_date32 >= Date32("1998-03-18") AND test.col_date32 <= Date32("1998-06-16") - TableScan: test projection=[col_date32] -"# + Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] + Projection: + Filter: test.col_date32 >= Date32("1998-03-18") AND test.col_date32 <= Date32("1998-06-16") + TableScan: test projection=[col_date32] + "# ); Ok(()) } @@ -311,11 +311,11 @@ fn between_date64_plus_interval() -> Result<()> { assert_snapshot!( format!("{plan}"), @r#" - Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] - Projection: - Filter: test.col_date64 >= Date64("1998-03-18") AND test.col_date64 <= Date64("1998-06-16") - TableScan: test projection=[col_date64] - "# + Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] + Projection: + Filter: test.col_date64 >= Date64("1998-03-18") AND test.col_date64 <= Date64("1998-06-16") + TableScan: test projection=[col_date64] + "# ); Ok(()) } @@ -339,16 +339,16 @@ fn join_keys_in_subquery_alias() { assert_snapshot!( format!("{plan}"), - @r#" - Inner Join: a.col_int32 = b.key - SubqueryAlias: a - Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32, col_uint32, col_utf8, col_date32, col_date64, col_ts_nano_none, col_ts_nano_utc] - SubqueryAlias: b - Projection: test.col_int32 AS key - Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32] - "# + @r" + Inner Join: a.col_int32 = b.key + SubqueryAlias: a + Filter: test.col_int32 IS NOT NULL + TableScan: test projection=[col_int32, col_uint32, col_utf8, col_date32, col_date64, col_ts_nano_none, col_ts_nano_utc] + SubqueryAlias: b + Projection: test.col_int32 AS key + Filter: test.col_int32 IS NOT NULL + TableScan: test projection=[col_int32] + " ); } @@ -359,20 +359,20 @@ fn join_keys_in_subquery_alias_1() { assert_snapshot!( format!("{plan}"), - @r#" - Inner Join: a.col_int32 = b.key - SubqueryAlias: a + @r" + Inner Join: a.col_int32 = b.key + SubqueryAlias: a + Filter: test.col_int32 IS NOT NULL + TableScan: test projection=[col_int32, col_uint32, col_utf8, col_date32, col_date64, col_ts_nano_none, col_ts_nano_utc] + SubqueryAlias: b + Projection: test.col_int32 AS key + Inner Join: test.col_int32 = c.col_int32 Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32, col_uint32, col_utf8, col_date32, col_date64, col_ts_nano_none, col_ts_nano_utc] - SubqueryAlias: b - Projection: test.col_int32 AS key - Inner Join: test.col_int32 = c.col_int32 - Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32] - SubqueryAlias: c - Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32] - "# + TableScan: test projection=[col_int32] + SubqueryAlias: c + Filter: test.col_int32 IS NOT NULL + TableScan: test projection=[col_int32] + " ); } @@ -383,12 +383,12 @@ fn push_down_filter_groupby_expr_contains_alias() { assert_snapshot!( format!("{plan}"), - @r#" - Projection: test.col_int32 + test.col_uint32 AS c, count(Int64(1)) AS count(*) - Aggregate: groupBy=[[CAST(test.col_int32 AS Int64) + CAST(test.col_uint32 AS Int64)]], aggr=[[count(Int64(1))]] - Filter: CAST(test.col_int32 AS Int64) + CAST(test.col_uint32 AS Int64) > Int64(3) - TableScan: test projection=[col_int32, col_uint32] - "# + @r" + Projection: test.col_int32 + test.col_uint32 AS c, count(Int64(1)) AS count(*) + Aggregate: groupBy=[[CAST(test.col_int32 AS Int64) + CAST(test.col_uint32 AS Int64)]], aggr=[[count(Int64(1))]] + Filter: CAST(test.col_int32 AS Int64) + CAST(test.col_uint32 AS Int64) > Int64(3) + TableScan: test projection=[col_int32, col_uint32] + " ); } @@ -400,14 +400,14 @@ fn test_same_name_but_not_ambiguous() { assert_snapshot!( format!("{plan}"), - @r#" - LeftSemi Join: t1.col_int32 = t2.col_int32 - Aggregate: groupBy=[[t1.col_int32]], aggr=[[]] - SubqueryAlias: t1 - TableScan: test projection=[col_int32] - SubqueryAlias: t2 - TableScan: test projection=[col_int32] - "# + @r" + LeftSemi Join: t1.col_int32 = t2.col_int32 + Aggregate: groupBy=[[t1.col_int32]], aggr=[[]] + SubqueryAlias: t1 + TableScan: test projection=[col_int32] + SubqueryAlias: t2 + TableScan: test projection=[col_int32] + " ); } @@ -422,10 +422,10 @@ fn eliminate_nested_filters() { assert_snapshot!( format!("{plan}"), - @r#" -Filter: test.col_int32 > Int32(0) - TableScan: test projection=[col_int32] - "# + @r" + Filter: test.col_int32 > Int32(0) + TableScan: test projection=[col_int32] + " ); } @@ -440,11 +440,11 @@ fn eliminate_redundant_null_check_on_count() { assert_snapshot!( format!("{plan}"), - @r#" - Projection: test.col_int32, count(Int64(1)) AS count(*) AS c - Aggregate: groupBy=[[test.col_int32]], aggr=[[count(Int64(1))]] - TableScan: test projection=[col_int32] - "# + @r" + Projection: test.col_int32, count(Int64(1)) AS count(*) AS c + Aggregate: groupBy=[[test.col_int32]], aggr=[[count(Int64(1))]] + TableScan: test projection=[col_int32] + " ); } @@ -468,13 +468,13 @@ fn test_propagate_empty_relation_inner_join_and_unions() { assert_snapshot!( format!("{plan}"), - @r#" -Union - TableScan: test projection=[col_int32] - TableScan: test projection=[col_int32] - Filter: test.col_int32 < Int32(0) - TableScan: test projection=[col_int32] - "#); + @r" + Union + TableScan: test projection=[col_int32] + TableScan: test projection=[col_int32] + Filter: test.col_int32 < Int32(0) + TableScan: test projection=[col_int32] + "); } #[test] @@ -485,10 +485,10 @@ fn select_wildcard_with_repeated_column_but_is_aliased() { assert_snapshot!( format!("{plan}"), - @r#" - Projection: test.col_int32, test.col_uint32, test.col_utf8, test.col_date32, test.col_date64, test.col_ts_nano_none, test.col_ts_nano_utc, test.col_int32 AS col_32 - TableScan: test projection=[col_int32, col_uint32, col_utf8, col_date32, col_date64, col_ts_nano_none, col_ts_nano_utc] - "# + @r" + Projection: test.col_int32, test.col_uint32, test.col_utf8, test.col_date32, test.col_date64, test.col_ts_nano_none, test.col_ts_nano_utc, test.col_int32 AS col_32 + TableScan: test projection=[col_int32, col_uint32, col_utf8, col_date32, col_date64, col_ts_nano_none, col_ts_nano_utc] + " ); } @@ -509,16 +509,16 @@ fn select_correlated_predicate_subquery_with_uppercase_ident() { assert_snapshot!( format!("{plan}"), - @r#" - LeftSemi Join: test.col_int32 = __correlated_sq_1.COL_INT32 - Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32, col_uint32, col_utf8, col_date32, col_date64, col_ts_nano_none, col_ts_nano_utc] - SubqueryAlias: __correlated_sq_1 - SubqueryAlias: T1 - Projection: test.col_int32 AS COL_INT32 - Filter: test.col_int32 IS NOT NULL - TableScan: test projection=[col_int32] - "# + @r" + LeftSemi Join: test.col_int32 = __correlated_sq_1.COL_INT32 + Filter: test.col_int32 IS NOT NULL + TableScan: test projection=[col_int32, col_uint32, col_utf8, col_date32, col_date64, col_ts_nano_none, col_ts_nano_utc] + SubqueryAlias: __correlated_sq_1 + SubqueryAlias: T1 + Projection: test.col_int32 AS COL_INT32 + Filter: test.col_int32 IS NOT NULL + TableScan: test projection=[col_int32] + " ); } @@ -591,15 +591,16 @@ fn recursive_cte_with_unused_columns() -> Result<()> { // even when they're defined in the CTE but not actually needed assert_snapshot!( format!("{plan}"), - @r#"SubqueryAlias: series - RecursiveQuery: is_distinct=false - Projection: Int64(1) AS n - Filter: test.col_int32 = Int32(1) - TableScan: test projection=[col_int32] - Projection: series.n + Int64(1) - Filter: series.n < Int64(3) - TableScan: series projection=[n] -"# + @r" + SubqueryAlias: series + RecursiveQuery: is_distinct=false + Projection: Int64(1) AS n + Filter: test.col_int32 = Int32(1) + TableScan: test projection=[col_int32] + Projection: series.n + Int64(1) + Filter: series.n < Int64(3) + TableScan: series projection=[n] + " ); Ok(()) } diff --git a/datafusion/physical-optimizer/src/ensure_coop.rs b/datafusion/physical-optimizer/src/ensure_coop.rs index 6f6edcb94ff8e..dfa97fc840333 100644 --- a/datafusion/physical-optimizer/src/ensure_coop.rs +++ b/datafusion/physical-optimizer/src/ensure_coop.rs @@ -110,9 +110,9 @@ mod tests { let display = displayable(optimized.as_ref()).indent(true).to_string(); // Use insta snapshot to ensure full plan structure - assert_snapshot!(display, @r###" - CooperativeExec - DataSourceExec: partitions=1, partition_sizes=[1] - "###); + assert_snapshot!(display, @r" + CooperativeExec + DataSourceExec: partitions=1, partition_sizes=[1] + "); } } diff --git a/datafusion/physical-plan/src/aggregates/mod.rs b/datafusion/physical-plan/src/aggregates/mod.rs index 447302d762f7f..b0d432a9deffe 100644 --- a/datafusion/physical-plan/src/aggregates/mod.rs +++ b/datafusion/physical-plan/src/aggregates/mod.rs @@ -2002,30 +2002,30 @@ mod tests { allow_duplicates! { assert_snapshot!(batches_to_sort_string(&result), @r" -+---+-----+---------------+-----------------+ -| a | b | __grouping_id | COUNT(1)[count] | -+---+-----+---------------+-----------------+ -| | 1.0 | 2 | 1 | -| | 1.0 | 2 | 1 | -| | 2.0 | 2 | 1 | -| | 2.0 | 2 | 1 | -| | 3.0 | 2 | 1 | -| | 3.0 | 2 | 1 | -| | 4.0 | 2 | 1 | -| | 4.0 | 2 | 1 | -| 2 | | 1 | 1 | -| 2 | | 1 | 1 | -| 2 | 1.0 | 0 | 1 | -| 2 | 1.0 | 0 | 1 | -| 3 | | 1 | 1 | -| 3 | | 1 | 2 | -| 3 | 2.0 | 0 | 2 | -| 3 | 3.0 | 0 | 1 | -| 4 | | 1 | 1 | -| 4 | | 1 | 2 | -| 4 | 3.0 | 0 | 1 | -| 4 | 4.0 | 0 | 2 | -+---+-----+---------------+-----------------+ + +---+-----+---------------+-----------------+ + | a | b | __grouping_id | COUNT(1)[count] | + +---+-----+---------------+-----------------+ + | | 1.0 | 2 | 1 | + | | 1.0 | 2 | 1 | + | | 2.0 | 2 | 1 | + | | 2.0 | 2 | 1 | + | | 3.0 | 2 | 1 | + | | 3.0 | 2 | 1 | + | | 4.0 | 2 | 1 | + | | 4.0 | 2 | 1 | + | 2 | | 1 | 1 | + | 2 | | 1 | 1 | + | 2 | 1.0 | 0 | 1 | + | 2 | 1.0 | 0 | 1 | + | 3 | | 1 | 1 | + | 3 | | 1 | 2 | + | 3 | 2.0 | 0 | 2 | + | 3 | 3.0 | 0 | 1 | + | 4 | | 1 | 1 | + | 4 | | 1 | 2 | + | 4 | 3.0 | 0 | 1 | + | 4 | 4.0 | 0 | 2 | + +---+-----+---------------+-----------------+ " ); } @@ -2033,22 +2033,22 @@ mod tests { allow_duplicates! { assert_snapshot!(batches_to_sort_string(&result), @r" -+---+-----+---------------+-----------------+ -| a | b | __grouping_id | COUNT(1)[count] | -+---+-----+---------------+-----------------+ -| | 1.0 | 2 | 2 | -| | 2.0 | 2 | 2 | -| | 3.0 | 2 | 2 | -| | 4.0 | 2 | 2 | -| 2 | | 1 | 2 | -| 2 | 1.0 | 0 | 2 | -| 3 | | 1 | 3 | -| 3 | 2.0 | 0 | 2 | -| 3 | 3.0 | 0 | 1 | -| 4 | | 1 | 3 | -| 4 | 3.0 | 0 | 1 | -| 4 | 4.0 | 0 | 2 | -+---+-----+---------------+-----------------+ + +---+-----+---------------+-----------------+ + | a | b | __grouping_id | COUNT(1)[count] | + +---+-----+---------------+-----------------+ + | | 1.0 | 2 | 2 | + | | 2.0 | 2 | 2 | + | | 3.0 | 2 | 2 | + | | 4.0 | 2 | 2 | + | 2 | | 1 | 2 | + | 2 | 1.0 | 0 | 2 | + | 3 | | 1 | 3 | + | 3 | 2.0 | 0 | 2 | + | 3 | 3.0 | 0 | 1 | + | 4 | | 1 | 3 | + | 4 | 3.0 | 0 | 1 | + | 4 | 4.0 | 0 | 2 | + +---+-----+---------------+-----------------+ " ); } @@ -2082,23 +2082,23 @@ mod tests { assert_snapshot!( batches_to_sort_string(&result), @r" - +---+-----+---------------+----------+ - | a | b | __grouping_id | COUNT(1) | - +---+-----+---------------+----------+ - | | 1.0 | 2 | 2 | - | | 2.0 | 2 | 2 | - | | 3.0 | 2 | 2 | - | | 4.0 | 2 | 2 | - | 2 | | 1 | 2 | - | 2 | 1.0 | 0 | 2 | - | 3 | | 1 | 3 | - | 3 | 2.0 | 0 | 2 | - | 3 | 3.0 | 0 | 1 | - | 4 | | 1 | 3 | - | 4 | 3.0 | 0 | 1 | - | 4 | 4.0 | 0 | 2 | - +---+-----+---------------+----------+ - " + +---+-----+---------------+----------+ + | a | b | __grouping_id | COUNT(1) | + +---+-----+---------------+----------+ + | | 1.0 | 2 | 2 | + | | 2.0 | 2 | 2 | + | | 3.0 | 2 | 2 | + | | 4.0 | 2 | 2 | + | 2 | | 1 | 2 | + | 2 | 1.0 | 0 | 2 | + | 3 | | 1 | 3 | + | 3 | 2.0 | 0 | 2 | + | 3 | 3.0 | 0 | 1 | + | 4 | | 1 | 3 | + | 4 | 3.0 | 0 | 1 | + | 4 | 4.0 | 0 | 2 | + +---+-----+---------------+----------+ + " ); } @@ -2149,27 +2149,27 @@ mod tests { if spill { allow_duplicates! { assert_snapshot!(batches_to_sort_string(&result), @r" - +---+---------------+-------------+ - | a | AVG(b)[count] | AVG(b)[sum] | - +---+---------------+-------------+ - | 2 | 1 | 1.0 | - | 2 | 1 | 1.0 | - | 3 | 1 | 2.0 | - | 3 | 2 | 5.0 | - | 4 | 3 | 11.0 | - +---+---------------+-------------+ + +---+---------------+-------------+ + | a | AVG(b)[count] | AVG(b)[sum] | + +---+---------------+-------------+ + | 2 | 1 | 1.0 | + | 2 | 1 | 1.0 | + | 3 | 1 | 2.0 | + | 3 | 2 | 5.0 | + | 4 | 3 | 11.0 | + +---+---------------+-------------+ "); } } else { allow_duplicates! { assert_snapshot!(batches_to_sort_string(&result), @r" - +---+---------------+-------------+ - | a | AVG(b)[count] | AVG(b)[sum] | - +---+---------------+-------------+ - | 2 | 2 | 2.0 | - | 3 | 3 | 7.0 | - | 4 | 3 | 11.0 | - +---+---------------+-------------+ + +---+---------------+-------------+ + | a | AVG(b)[count] | AVG(b)[sum] | + +---+---------------+-------------+ + | 2 | 2 | 2.0 | + | 3 | 3 | 7.0 | + | 4 | 3 | 11.0 | + +---+---------------+-------------+ "); } }; @@ -2204,14 +2204,14 @@ mod tests { allow_duplicates! { assert_snapshot!(batches_to_sort_string(&result), @r" - +---+--------------------+ - | a | AVG(b) | - +---+--------------------+ - | 2 | 1.0 | - | 3 | 2.3333333333333335 | - | 4 | 3.6666666666666665 | - +---+--------------------+ - "); + +---+--------------------+ + | a | AVG(b) | + +---+--------------------+ + | 2 | 1.0 | + | 3 | 2.3333333333333335 | + | 4 | 3.6666666666666665 | + +---+--------------------+ + "); // For row 2: 3, (2 + 3 + 2) / 3 // For row 3: 4, (3 + 4 + 4) / 3 } @@ -2738,26 +2738,26 @@ mod tests { if is_first_acc { allow_duplicates! { assert_snapshot!(batches_to_string(&result), @r" - +---+--------------------------------------------+ - | a | first_value(b) ORDER BY [b ASC NULLS LAST] | - +---+--------------------------------------------+ - | 2 | 0.0 | - | 3 | 1.0 | - | 4 | 3.0 | - +---+--------------------------------------------+ - "); + +---+--------------------------------------------+ + | a | first_value(b) ORDER BY [b ASC NULLS LAST] | + +---+--------------------------------------------+ + | 2 | 0.0 | + | 3 | 1.0 | + | 4 | 3.0 | + +---+--------------------------------------------+ + "); } } else { allow_duplicates! { assert_snapshot!(batches_to_string(&result), @r" - +---+-------------------------------------------+ - | a | last_value(b) ORDER BY [b ASC NULLS LAST] | - +---+-------------------------------------------+ - | 2 | 3.0 | - | 3 | 5.0 | - | 4 | 6.0 | - +---+-------------------------------------------+ - "); + +---+-------------------------------------------+ + | a | last_value(b) ORDER BY [b ASC NULLS LAST] | + +---+-------------------------------------------+ + | 2 | 3.0 | + | 3 | 5.0 | + | 4 | 6.0 | + +---+-------------------------------------------+ + "); } }; Ok(()) @@ -2946,13 +2946,13 @@ mod tests { allow_duplicates! { assert_snapshot!(batches_to_sort_string(&output), @r" - +-----+-----+-------+---------------+-------+ - | a | b | const | __grouping_id | 1 | - +-----+-----+-------+---------------+-------+ - | | | 1 | 6 | 32768 | - | | 0.0 | | 5 | 32768 | - | 0.0 | | | 3 | 32768 | - +-----+-----+-------+---------------+-------+ + +-----+-----+-------+---------------+-------+ + | a | b | const | __grouping_id | 1 | + +-----+-----+-------+---------------+-------+ + | | | 1 | 6 | 32768 | + | | 0.0 | | 5 | 32768 | + | 0.0 | | | 3 | 32768 | + +-----+-----+-------+---------------+-------+ "); } @@ -3061,13 +3061,13 @@ mod tests { allow_duplicates! { assert_snapshot!(batches_to_string(&output), @r" - +--------------+------------+ - | labels | SUM(value) | - +--------------+------------+ - | {a: a, b: b} | 2 | - | {a: , b: c} | 1 | - +--------------+------------+ - "); + +--------------+------------+ + | labels | SUM(value) | + +--------------+------------+ + | {a: a, b: b} | 2 | + | {a: , b: c} | 1 | + +--------------+------------+ + "); } Ok(()) @@ -3369,13 +3369,13 @@ mod tests { allow_duplicates! { assert_snapshot!(batches_to_string(&result), @r" - +---+--------+--------+ - | a | MIN(b) | AVG(b) | - +---+--------+--------+ - | 2 | 1.0 | 1.0 | - | 3 | 2.0 | 2.0 | - | 4 | 3.0 | 3.5 | - +---+--------+--------+ + +---+--------+--------+ + | a | MIN(b) | AVG(b) | + +---+--------+--------+ + | 2 | 1.0 | 1.0 | + | 3 | 2.0 | 2.0 | + | 4 | 3.0 | 3.5 | + +---+--------+--------+ "); } diff --git a/datafusion/physical-plan/src/aggregates/topk/heap.rs b/datafusion/physical-plan/src/aggregates/topk/heap.rs index 0e6bc18e2d4a2..abdf320ea39d8 100644 --- a/datafusion/physical-plan/src/aggregates/topk/heap.rs +++ b/datafusion/physical-plan/src/aggregates/topk/heap.rs @@ -483,9 +483,7 @@ mod tests { heap.append_or_replace(1, 1, &mut map); let actual = heap.to_string(); - assert_snapshot!(actual, @r#" -val=1 idx=0, bucket=1 - "#); + assert_snapshot!(actual, @"val=1 idx=0, bucket=1"); Ok(()) } @@ -502,10 +500,10 @@ val=1 idx=0, bucket=1 assert_eq!(map, vec![(2, 0), (1, 1)]); let actual = heap.to_string(); - assert_snapshot!(actual, @r#" -val=2 idx=0, bucket=2 -└── val=1 idx=1, bucket=1 - "#); + assert_snapshot!(actual, @r" + val=2 idx=0, bucket=2 + └── val=1 idx=1, bucket=1 + "); Ok(()) } @@ -519,20 +517,20 @@ val=2 idx=0, bucket=2 heap.append_or_replace(2, 2, &mut map); heap.append_or_replace(3, 3, &mut map); let actual = heap.to_string(); - assert_snapshot!(actual, @r#" -val=3 idx=0, bucket=3 -├── val=1 idx=1, bucket=1 -└── val=2 idx=2, bucket=2 - "#); + assert_snapshot!(actual, @r" + val=3 idx=0, bucket=3 + ├── val=1 idx=1, bucket=1 + └── val=2 idx=2, bucket=2 + "); let mut map = vec![]; heap.append_or_replace(0, 0, &mut map); let actual = heap.to_string(); - assert_snapshot!(actual, @r#" -val=2 idx=0, bucket=2 -├── val=1 idx=1, bucket=1 -└── val=0 idx=2, bucket=0 - "#); + assert_snapshot!(actual, @r" + val=2 idx=0, bucket=2 + ├── val=1 idx=1, bucket=1 + └── val=0 idx=2, bucket=0 + "); assert_eq!(map, vec![(2, 0), (0, 2)]); Ok(()) @@ -548,22 +546,22 @@ val=2 idx=0, bucket=2 heap.append_or_replace(3, 3, &mut map); heap.append_or_replace(4, 4, &mut map); let actual = heap.to_string(); - assert_snapshot!(actual, @r#" -val=4 idx=0, bucket=4 -├── val=3 idx=1, bucket=3 -│ └── val=1 idx=3, bucket=1 -└── val=2 idx=2, bucket=2 - "#); + assert_snapshot!(actual, @r" + val=4 idx=0, bucket=4 + ├── val=3 idx=1, bucket=3 + │ └── val=1 idx=3, bucket=1 + └── val=2 idx=2, bucket=2 + "); let mut map = vec![]; heap.replace_if_better(1, 0, &mut map); let actual = heap.to_string(); - assert_snapshot!(actual, @r#" -val=4 idx=0, bucket=4 -├── val=1 idx=1, bucket=1 -│ └── val=0 idx=3, bucket=3 -└── val=2 idx=2, bucket=2 - "#); + assert_snapshot!(actual, @r" + val=4 idx=0, bucket=4 + ├── val=1 idx=1, bucket=1 + │ └── val=0 idx=3, bucket=3 + └── val=2 idx=2, bucket=2 + "); assert_eq!(map, vec![(1, 1), (3, 3)]); Ok(()) @@ -578,10 +576,10 @@ val=4 idx=0, bucket=4 heap.append_or_replace(2, 2, &mut map); let actual = heap.to_string(); - assert_snapshot!(actual, @r#" -val=2 idx=0, bucket=2 -└── val=1 idx=1, bucket=1 - "#); + assert_snapshot!(actual, @r" + val=2 idx=0, bucket=2 + └── val=1 idx=1, bucket=1 + "); assert_eq!(heap.worst_val(), Some(&2)); assert_eq!(heap.worst_map_idx(), 2); @@ -598,10 +596,10 @@ val=2 idx=0, bucket=2 heap.append_or_replace(2, 2, &mut map); let actual = heap.to_string(); - assert_snapshot!(actual, @r#" -val=2 idx=0, bucket=2 -└── val=1 idx=1, bucket=1 - "#); + assert_snapshot!(actual, @r" + val=2 idx=0, bucket=2 + └── val=1 idx=1, bucket=1 + "); let (vals, map_idxs) = heap.drain(); assert_eq!(vals, vec![1, 2]); @@ -620,18 +618,18 @@ val=2 idx=0, bucket=2 heap.append_or_replace(2, 2, &mut map); let actual = heap.to_string(); - assert_snapshot!(actual, @r#" -val=2 idx=0, bucket=2 -└── val=1 idx=1, bucket=1 - "#); + assert_snapshot!(actual, @r" + val=2 idx=0, bucket=2 + └── val=1 idx=1, bucket=1 + "); let numbers = vec![(0, 1), (1, 2)]; heap.renumber(numbers.as_slice()); let actual = heap.to_string(); - assert_snapshot!(actual, @r#" -val=2 idx=0, bucket=1 -└── val=1 idx=1, bucket=2 - "#); + assert_snapshot!(actual, @r" + val=2 idx=0, bucket=1 + └── val=1 idx=1, bucket=2 + "); Ok(()) } diff --git a/datafusion/physical-plan/src/aggregates/topk/priority_map.rs b/datafusion/physical-plan/src/aggregates/topk/priority_map.rs index afed265345a5c..fdff6b3a1a51c 100644 --- a/datafusion/physical-plan/src/aggregates/topk/priority_map.rs +++ b/datafusion/physical-plan/src/aggregates/topk/priority_map.rs @@ -182,13 +182,13 @@ mod tests { let batch = RecordBatch::try_new(test_schema(), cols)?; let actual = format!("{}", pretty_format_batches(&[batch])?); - assert_snapshot!(actual, @r#" -+----------+--------------+ -| trace_id | timestamp_ms | -+----------+--------------+ -| 1 | 1 | -+----------+--------------+ - "# + assert_snapshot!(actual, @r" + +----------+--------------+ + | trace_id | timestamp_ms | + +----------+--------------+ + | 1 | 1 | + +----------+--------------+ + " ); Ok(()) @@ -207,13 +207,13 @@ mod tests { let batch = RecordBatch::try_new(test_schema(), cols)?; let actual = format!("{}", pretty_format_batches(&[batch])?); - assert_snapshot!(actual, @r#" -+----------+--------------+ -| trace_id | timestamp_ms | -+----------+--------------+ -| 1 | 1 | -+----------+--------------+ - "# + assert_snapshot!(actual, @r" + +----------+--------------+ + | trace_id | timestamp_ms | + +----------+--------------+ + | 1 | 1 | + +----------+--------------+ + " ); Ok(()) @@ -231,13 +231,13 @@ mod tests { let cols = agg.emit()?; let batch = RecordBatch::try_new(test_schema(), cols)?; let actual = format!("{}", pretty_format_batches(&[batch])?); - assert_snapshot!(actual, @r#" -+----------+--------------+ -| trace_id | timestamp_ms | -+----------+--------------+ -| 2 | 2 | -+----------+--------------+ - "# + assert_snapshot!(actual, @r" + +----------+--------------+ + | trace_id | timestamp_ms | + +----------+--------------+ + | 2 | 2 | + +----------+--------------+ + " ); Ok(()) @@ -255,13 +255,13 @@ mod tests { let cols = agg.emit()?; let batch = RecordBatch::try_new(test_schema(), cols)?; let actual = format!("{}", pretty_format_batches(&[batch])?); - assert_snapshot!(actual, @r#" -+----------+--------------+ -| trace_id | timestamp_ms | -+----------+--------------+ -| 1 | 1 | -+----------+--------------+ - "# + assert_snapshot!(actual, @r" + +----------+--------------+ + | trace_id | timestamp_ms | + +----------+--------------+ + | 1 | 1 | + +----------+--------------+ + " ); Ok(()) @@ -279,13 +279,13 @@ mod tests { let cols = agg.emit()?; let batch = RecordBatch::try_new(test_schema(), cols)?; let actual = format!("{}", pretty_format_batches(&[batch])?); - assert_snapshot!(actual, @r#" -+----------+--------------+ -| trace_id | timestamp_ms | -+----------+--------------+ -| 1 | 2 | -+----------+--------------+ - "# + assert_snapshot!(actual, @r" + +----------+--------------+ + | trace_id | timestamp_ms | + +----------+--------------+ + | 1 | 2 | + +----------+--------------+ + " ); Ok(()) @@ -303,13 +303,13 @@ mod tests { let cols = agg.emit()?; let batch = RecordBatch::try_new(test_schema(), cols)?; let actual = format!("{}", pretty_format_batches(&[batch])?); - assert_snapshot!(actual, @r#" -+----------+--------------+ -| trace_id | timestamp_ms | -+----------+--------------+ -| 1 | 1 | -+----------+--------------+ - "# + assert_snapshot!(actual, @r" + +----------+--------------+ + | trace_id | timestamp_ms | + +----------+--------------+ + | 1 | 1 | + +----------+--------------+ + " ); Ok(()) @@ -327,13 +327,13 @@ mod tests { let cols = agg.emit()?; let batch = RecordBatch::try_new(test_schema(), cols)?; let actual = format!("{}", pretty_format_batches(&[batch])?); - assert_snapshot!(actual, @r#" -+----------+--------------+ -| trace_id | timestamp_ms | -+----------+--------------+ -| 2 | 2 | -+----------+--------------+ - "# + assert_snapshot!(actual, @r" + +----------+--------------+ + | trace_id | timestamp_ms | + +----------+--------------+ + | 2 | 2 | + +----------+--------------+ + " ); Ok(()) @@ -351,13 +351,13 @@ mod tests { let cols = agg.emit()?; let batch = RecordBatch::try_new(test_schema(), cols)?; let actual = format!("{}", pretty_format_batches(&[batch])?); - assert_snapshot!(actual, @r#" -+----------+--------------+ -| trace_id | timestamp_ms | -+----------+--------------+ -| 1 | 1 | -+----------+--------------+ - "# + assert_snapshot!(actual, @r" + +----------+--------------+ + | trace_id | timestamp_ms | + +----------+--------------+ + | 1 | 1 | + +----------+--------------+ + " ); Ok(()) @@ -375,13 +375,13 @@ mod tests { let cols = agg.emit()?; let batch = RecordBatch::try_new(test_schema(), cols)?; let actual = format!("{}", pretty_format_batches(&[batch])?); - assert_snapshot!(actual, @r#" -+----------+--------------+ -| trace_id | timestamp_ms | -+----------+--------------+ -| 1 | 2 | -+----------+--------------+ - "# + assert_snapshot!(actual, @r" + +----------+--------------+ + | trace_id | timestamp_ms | + +----------+--------------+ + | 1 | 2 | + +----------+--------------+ + " ); Ok(()) @@ -400,14 +400,14 @@ mod tests { let cols = agg.emit()?; let batch = RecordBatch::try_new(test_schema(), cols)?; let actual = format!("{}", pretty_format_batches(&[batch])?); - assert_snapshot!(actual, @r#" -+----------+--------------+ -| trace_id | timestamp_ms | -+----------+--------------+ -| | 3 | -| 1 | 1 | -+----------+--------------+ - "# + assert_snapshot!(actual, @r" + +----------+--------------+ + | trace_id | timestamp_ms | + +----------+--------------+ + | | 3 | + | 1 | 1 | + +----------+--------------+ + " ); Ok(()) diff --git a/datafusion/physical-plan/src/joins/cross_join.rs b/datafusion/physical-plan/src/joins/cross_join.rs index 7e43deb9bfdf5..4f32b6176ec39 100644 --- a/datafusion/physical-plan/src/joins/cross_join.rs +++ b/datafusion/physical-plan/src/joins/cross_join.rs @@ -869,18 +869,18 @@ mod tests { assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b2", "c2"]); - assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+----+----+----+----+ - | 1 | 4 | 7 | 10 | 12 | 14 | - | 1 | 4 | 7 | 11 | 13 | 15 | - | 2 | 5 | 8 | 10 | 12 | 14 | - | 2 | 5 | 8 | 11 | 13 | 15 | - | 3 | 6 | 9 | 10 | 12 | 14 | - | 3 | 6 | 9 | 11 | 13 | 15 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+----+----+----+----+ + | 1 | 4 | 7 | 10 | 12 | 14 | + | 1 | 4 | 7 | 11 | 13 | 15 | + | 2 | 5 | 8 | 10 | 12 | 14 | + | 2 | 5 | 8 | 11 | 13 | 15 | + | 3 | 6 | 9 | 10 | 12 | 14 | + | 3 | 6 | 9 | 11 | 13 | 15 | + +----+----+----+----+----+----+ + "); assert_join_metrics!(metrics, 6); diff --git a/datafusion/physical-plan/src/joins/hash_join/exec.rs b/datafusion/physical-plan/src/joins/hash_join/exec.rs index 26447847631fa..13d1e0a982d9f 100644 --- a/datafusion/physical-plan/src/joins/hash_join/exec.rs +++ b/datafusion/physical-plan/src/joins/hash_join/exec.rs @@ -1779,15 +1779,15 @@ mod tests { allow_duplicates! { // Inner join output is expected to preserve both inputs order - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b1 | c2 | - +----+----+----+----+----+----+ - | 1 | 4 | 7 | 10 | 4 | 70 | - | 2 | 5 | 8 | 20 | 5 | 80 | - | 3 | 5 | 9 | 20 | 5 | 80 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b1 | c2 | + +----+----+----+----+----+----+ + | 1 | 4 | 7 | 10 | 4 | 70 | + | 2 | 5 | 8 | 20 | 5 | 80 | + | 3 | 5 | 9 | 20 | 5 | 80 | + +----+----+----+----+----+----+ + "); } assert_join_metrics!(metrics, 3); @@ -1827,15 +1827,15 @@ mod tests { assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b1", "c2"]); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b1 | c2 | - +----+----+----+----+----+----+ - | 1 | 4 | 7 | 10 | 4 | 70 | - | 2 | 5 | 8 | 20 | 5 | 80 | - | 3 | 5 | 9 | 20 | 5 | 80 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b1 | c2 | + +----+----+----+----+----+----+ + | 1 | 4 | 7 | 10 | 4 | 70 | + | 2 | 5 | 8 | 20 | 5 | 80 | + | 3 | 5 | 9 | 20 | 5 | 80 | + +----+----+----+----+----+----+ + "); } assert_join_metrics!(metrics, 3); @@ -1875,7 +1875,7 @@ mod tests { // Inner join output is expected to preserve both inputs order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b2 | c2 | +----+----+----+----+----+----+ @@ -1883,7 +1883,7 @@ mod tests { | 2 | 5 | 8 | 20 | 5 | 80 | | 3 | 5 | 9 | 20 | 5 | 80 | +----+----+----+----+----+----+ - "#); + "); } assert_join_metrics!(metrics, 3); @@ -1923,7 +1923,7 @@ mod tests { // Inner join output is expected to preserve both inputs order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b2 | c2 | +----+----+----+----+----+----+ @@ -1932,7 +1932,7 @@ mod tests { | 0 | 4 | 6 | 10 | 4 | 70 | | 1 | 4 | 7 | 10 | 4 | 70 | +----+----+----+----+----+----+ - "#); + "); } assert_join_metrics!(metrics, 4); @@ -2000,7 +2000,7 @@ mod tests { // Inner join output is expected to preserve both inputs order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b2 | c1 | a1 | b2 | c2 | +----+----+----+----+----+----+ @@ -2008,7 +2008,7 @@ mod tests { | 2 | 2 | 8 | 2 | 2 | 80 | | 2 | 2 | 9 | 2 | 2 | 80 | +----+----+----+----+----+----+ - "#); + "); } assert_join_metrics!(metrics, 3); @@ -2085,7 +2085,7 @@ mod tests { // Inner join output is expected to preserve both inputs order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b2 | c1 | a1 | b2 | c2 | +----+----+----+----+----+----+ @@ -2093,7 +2093,7 @@ mod tests { | 2 | 2 | 8 | 2 | 2 | 80 | | 2 | 2 | 9 | 2 | 2 | 80 | +----+----+----+----+----+----+ - "#); + "); } assert_join_metrics!(metrics, 3); @@ -2144,7 +2144,7 @@ mod tests { // Inner join output is expected to preserve both inputs order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b2 | c2 | +----+----+----+----+----+----+ @@ -2153,7 +2153,7 @@ mod tests { | 0 | 4 | 6 | 10 | 4 | 70 | | 1 | 4 | 7 | 10 | 4 | 70 | +----+----+----+----+----+----+ - "#); + "); } assert_join_metrics!(metrics, 4); @@ -2226,13 +2226,13 @@ mod tests { // Inner join output is expected to preserve both inputs order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ | 1 | 4 | 7 | 10 | 4 | 70 | +----+----+----+----+----+----+ - "#); + "); } // second part @@ -2256,14 +2256,14 @@ mod tests { // Inner join output is expected to preserve both inputs order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ | 2 | 5 | 8 | 30 | 5 | 90 | | 3 | 5 | 9 | 30 | 5 | 90 | +----+----+----+----+----+----+ - "#); + "); } Ok(()) @@ -2314,7 +2314,7 @@ mod tests { let batches = common::collect(stream).await.unwrap(); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -2324,7 +2324,7 @@ mod tests { | 2 | 5 | 8 | 20 | 5 | 80 | | 3 | 7 | 9 | | | | +----+----+----+----+----+----+ - "#); + "); } } @@ -2364,7 +2364,7 @@ mod tests { let batches = common::collect(stream).await.unwrap(); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b2 | c2 | +----+----+----+----+----+----+ @@ -2376,7 +2376,7 @@ mod tests { | 2 | 5 | 8 | 20 | 5 | 80 | | 3 | 7 | 9 | | | | +----+----+----+----+----+----+ - "#); + "); } } @@ -2412,7 +2412,7 @@ mod tests { let batches = common::collect(stream).await.unwrap(); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -2420,7 +2420,7 @@ mod tests { | 2 | 5 | 8 | | | | | 3 | 7 | 9 | | | | +----+----+----+----+----+----+ - "#); + "); } } @@ -2456,7 +2456,7 @@ mod tests { let batches = common::collect(stream).await.unwrap(); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b2 | c2 | +----+----+----+----+----+----+ @@ -2464,7 +2464,7 @@ mod tests { | 2 | 5 | 8 | | | | | 3 | 7 | 9 | | | | +----+----+----+----+----+----+ - "#); + "); } } @@ -2500,7 +2500,7 @@ mod tests { assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b1", "c2"]); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -2508,7 +2508,7 @@ mod tests { | 2 | 5 | 8 | 20 | 5 | 80 | | 3 | 7 | 9 | | | | +----+----+----+----+----+----+ - "#); + "); } assert_join_metrics!(metrics, 3); @@ -2548,7 +2548,7 @@ mod tests { assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b1", "c2"]); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -2556,7 +2556,7 @@ mod tests { | 2 | 5 | 8 | 20 | 5 | 80 | | 3 | 7 | 9 | | | | +----+----+----+----+----+----+ - "#); + "); } assert_join_metrics!(metrics, 3); @@ -2612,7 +2612,7 @@ mod tests { // ignore the order allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+-----+ | a1 | b1 | c1 | +----+----+-----+ @@ -2620,7 +2620,7 @@ mod tests { | 13 | 10 | 130 | | 9 | 8 | 90 | +----+----+-----+ - "#); + "); } Ok(()) @@ -2713,13 +2713,13 @@ mod tests { let batches = common::collect(stream).await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+-----+ | a1 | b1 | c1 | +----+----+-----+ | 13 | 10 | 130 | +----+----+-----+ - "#); + "); } Ok(()) @@ -2754,7 +2754,7 @@ mod tests { // RightSemi join output is expected to preserve right input order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+-----+ | a2 | b2 | c2 | +----+----+-----+ @@ -2762,7 +2762,7 @@ mod tests { | 12 | 10 | 40 | | 10 | 10 | 100 | +----+----+-----+ - "#); + "); } Ok(()) @@ -2817,7 +2817,7 @@ mod tests { // RightSemi join output is expected to preserve right input order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+-----+ | a2 | b2 | c2 | +----+----+-----+ @@ -2825,7 +2825,7 @@ mod tests { | 12 | 10 | 40 | | 10 | 10 | 100 | +----+----+-----+ - "#); + "); } // left_table right semi join right_table on left_table.b1 = right_table.b2 on left_table.a1!=9 @@ -2854,14 +2854,14 @@ mod tests { // RightSemi join output is expected to preserve right input order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+-----+ | a2 | b2 | c2 | +----+----+-----+ | 12 | 10 | 40 | | 10 | 10 | 100 | +----+----+-----+ - "#); + "); } Ok(()) @@ -2894,7 +2894,7 @@ mod tests { let batches = common::collect(stream).await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+ | a1 | b1 | c1 | +----+----+----+ @@ -2903,7 +2903,7 @@ mod tests { | 5 | 5 | 50 | | 7 | 7 | 70 | +----+----+----+ - "#); + "); } Ok(()) } @@ -2954,7 +2954,7 @@ mod tests { let batches = common::collect(stream).await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+-----+ | a1 | b1 | c1 | +----+----+-----+ @@ -2965,7 +2965,7 @@ mod tests { | 7 | 7 | 70 | | 9 | 8 | 90 | +----+----+-----+ - "#); + "); } // left_table left anti join right_table on left_table.b1 = right_table.b2 and right_table.a2 != 13 @@ -2997,7 +2997,7 @@ mod tests { let batches = common::collect(stream).await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+-----+ | a1 | b1 | c1 | +----+----+-----+ @@ -3008,7 +3008,7 @@ mod tests { | 7 | 7 | 70 | | 9 | 8 | 90 | +----+----+-----+ - "#); + "); } Ok(()) @@ -3041,7 +3041,7 @@ mod tests { // RightAnti join output is expected to preserve right input order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+-----+ | a2 | b2 | c2 | +----+----+-----+ @@ -3049,7 +3049,7 @@ mod tests { | 2 | 2 | 80 | | 4 | 4 | 120 | +----+----+-----+ - "#); + "); } Ok(()) } @@ -3102,7 +3102,7 @@ mod tests { // RightAnti join output is expected to preserve right input order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+-----+ | a2 | b2 | c2 | +----+----+-----+ @@ -3112,7 +3112,7 @@ mod tests { | 10 | 10 | 100 | | 4 | 4 | 120 | +----+----+-----+ - "#); + "); } // left_table right anti join right_table on left_table.b1 = right_table.b2 and right_table.b2!=8 @@ -3149,7 +3149,7 @@ mod tests { // RightAnti join output is expected to preserve right input order allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+-----+ | a2 | b2 | c2 | +----+----+-----+ @@ -3158,7 +3158,7 @@ mod tests { | 2 | 2 | 80 | | 4 | 4 | 120 | +----+----+-----+ - "#); + "); } Ok(()) @@ -3196,7 +3196,7 @@ mod tests { assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b1", "c2"]); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -3204,7 +3204,7 @@ mod tests { | 1 | 4 | 7 | 10 | 4 | 70 | | 2 | 5 | 8 | 20 | 5 | 80 | +----+----+----+----+----+----+ - "#); + "); } assert_join_metrics!(metrics, 3); @@ -3244,7 +3244,7 @@ mod tests { assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b1", "c2"]); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -3252,7 +3252,7 @@ mod tests { | 1 | 4 | 7 | 10 | 4 | 70 | | 2 | 5 | 8 | 20 | 5 | 80 | +----+----+----+----+----+----+ - "#); + "); } assert_join_metrics!(metrics, 3); @@ -3294,7 +3294,7 @@ mod tests { let batches = common::collect(stream).await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b2 | c2 | +----+----+----+----+----+----+ @@ -3303,7 +3303,7 @@ mod tests { | 2 | 5 | 8 | 20 | 5 | 80 | | 3 | 7 | 9 | | | | +----+----+----+----+----+----+ - "#); + "); } Ok(()) @@ -3341,7 +3341,7 @@ mod tests { assert_eq!(columns, vec!["a1", "b1", "c1", "mark"]); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+-------+ | a1 | b1 | c1 | mark | +----+----+----+-------+ @@ -3349,7 +3349,7 @@ mod tests { | 2 | 5 | 8 | true | | 3 | 7 | 9 | false | +----+----+----+-------+ - "#); + "); } assert_join_metrics!(metrics, 3); @@ -3389,7 +3389,7 @@ mod tests { assert_eq!(columns, vec!["a1", "b1", "c1", "mark"]); allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +----+----+----+-------+ | a1 | b1 | c1 | mark | +----+----+----+-------+ @@ -3397,7 +3397,7 @@ mod tests { | 2 | 5 | 8 | true | | 3 | 7 | 9 | false | +----+----+----+-------+ - "#); + "); } assert_join_metrics!(metrics, 3); @@ -3661,14 +3661,14 @@ mod tests { let batches = common::collect(stream).await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +---+---+---+----+---+----+ | a | b | c | a | b | c | +---+---+---+----+---+----+ | 1 | 4 | 7 | 10 | 1 | 70 | | 2 | 5 | 8 | 20 | 2 | 80 | +---+---+---+----+---+----+ - "#); + "); } Ok(()) @@ -3738,14 +3738,14 @@ mod tests { let batches = common::collect(stream).await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +---+---+---+----+---+---+ | a | b | c | a | b | c | +---+---+---+----+---+---+ | 2 | 7 | 9 | 10 | 2 | 7 | | 2 | 7 | 9 | 20 | 2 | 5 | +---+---+---+----+---+---+ - "#); + "); } Ok(()) @@ -3787,7 +3787,7 @@ mod tests { let batches = common::collect(stream).await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +---+---+---+----+---+---+ | a | b | c | a | b | c | +---+---+---+----+---+---+ @@ -3797,7 +3797,7 @@ mod tests { | 2 | 7 | 9 | 20 | 2 | 5 | | 2 | 8 | 1 | | | | +---+---+---+----+---+---+ - "#); + "); } Ok(()) @@ -3839,7 +3839,7 @@ mod tests { let batches = common::collect(stream).await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +---+---+---+----+---+---+ | a | b | c | a | b | c | +---+---+---+----+---+---+ @@ -3848,7 +3848,7 @@ mod tests { | 2 | 7 | 9 | 10 | 2 | 7 | | 2 | 7 | 9 | 20 | 2 | 5 | +---+---+---+----+---+---+ - "#); + "); } Ok(()) @@ -4094,7 +4094,7 @@ mod tests { let batches = common::collect(stream).await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches), @r#" + assert_snapshot!(batches_to_sort_string(&batches), @r" +------------+---+------------+---+ | date | n | date | n | +------------+---+------------+---+ @@ -4102,7 +4102,7 @@ mod tests { | 2022-04-26 | 2 | 2022-04-26 | 5 | | 2022-04-27 | 3 | 2022-04-27 | 6 | +------------+---+------------+---+ - "#); + "); } Ok(()) @@ -4504,7 +4504,7 @@ mod tests { assert_eq!(columns, vec!["n1", "n2"]); allow_duplicates! { - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +--------+--------+ | n1 | n2 | +--------+--------+ @@ -4512,7 +4512,7 @@ mod tests { | {a: 1} | {a: 1} | | {a: 2} | {a: 2} | +--------+--------+ - "#); + "); } assert_join_metrics!(metrics, 3); @@ -4543,13 +4543,13 @@ mod tests { .await?; allow_duplicates! { - assert_snapshot!(batches_to_sort_string(&batches_null_eq), @r#" + assert_snapshot!(batches_to_sort_string(&batches_null_eq), @r" +----+----+ | n1 | n2 | +----+----+ | | | +----+----+ - "#); + "); } assert_join_metrics!(metrics, 1); diff --git a/datafusion/physical-plan/src/joins/nested_loop_join.rs b/datafusion/physical-plan/src/joins/nested_loop_join.rs index c11ee0f378942..76dca7239114b 100644 --- a/datafusion/physical-plan/src/joins/nested_loop_join.rs +++ b/datafusion/physical-plan/src/joins/nested_loop_join.rs @@ -2405,13 +2405,13 @@ pub(crate) mod tests { .await?; assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b2", "c2"]); - allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+----+----+----+----+ - | 5 | 5 | 50 | 2 | 2 | 80 | - +----+----+----+----+----+----+ - "#)); + allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+----+----+----+----+ + | 5 | 5 | 50 | 2 | 2 | 80 | + +----+----+----+----+----+----+ + ")); assert_join_metrics!(metrics, 1); @@ -2435,15 +2435,15 @@ pub(crate) mod tests { ) .await?; assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b2", "c2"]); - allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+-----+----+----+----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+-----+----+----+----+ - | 11 | 8 | 110 | | | | - | 5 | 5 | 50 | 2 | 2 | 80 | - | 9 | 8 | 90 | | | | - +----+----+-----+----+----+----+ - "#)); + allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+-----+----+----+----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+-----+----+----+----+ + | 11 | 8 | 110 | | | | + | 5 | 5 | 50 | 2 | 2 | 80 | + | 9 | 8 | 90 | | | | + +----+----+-----+----+----+----+ + ")); assert_join_metrics!(metrics, 3); @@ -2467,15 +2467,15 @@ pub(crate) mod tests { ) .await?; assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b2", "c2"]); - allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+----+----+----+-----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+----+----+----+-----+ - | | | | 10 | 10 | 100 | - | | | | 12 | 10 | 40 | - | 5 | 5 | 50 | 2 | 2 | 80 | - +----+----+----+----+----+-----+ - "#)); + allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+----+----+----+-----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+----+----+----+-----+ + | | | | 10 | 10 | 100 | + | | | | 12 | 10 | 40 | + | 5 | 5 | 50 | 2 | 2 | 80 | + +----+----+----+----+----+-----+ + ")); assert_join_metrics!(metrics, 3); @@ -2499,17 +2499,17 @@ pub(crate) mod tests { ) .await?; assert_eq!(columns, vec!["a1", "b1", "c1", "a2", "b2", "c2"]); - allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+-----+----+----+-----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+-----+----+----+-----+ - | | | | 10 | 10 | 100 | - | | | | 12 | 10 | 40 | - | 11 | 8 | 110 | | | | - | 5 | 5 | 50 | 2 | 2 | 80 | - | 9 | 8 | 90 | | | | - +----+----+-----+----+----+-----+ - "#)); + allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+-----+----+----+-----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+-----+----+----+-----+ + | | | | 10 | 10 | 100 | + | | | | 12 | 10 | 40 | + | 11 | 8 | 110 | | | | + | 5 | 5 | 50 | 2 | 2 | 80 | + | 9 | 8 | 90 | | | | + +----+----+-----+----+----+-----+ + ")); assert_join_metrics!(metrics, 5); @@ -2535,13 +2535,13 @@ pub(crate) mod tests { ) .await?; assert_eq!(columns, vec!["a1", "b1", "c1"]); - allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+----+ - | a1 | b1 | c1 | - +----+----+----+ - | 5 | 5 | 50 | - +----+----+----+ - "#)); + allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+----+ + | a1 | b1 | c1 | + +----+----+----+ + | 5 | 5 | 50 | + +----+----+----+ + ")); assert_join_metrics!(metrics, 1); @@ -2567,14 +2567,14 @@ pub(crate) mod tests { ) .await?; assert_eq!(columns, vec!["a1", "b1", "c1"]); - allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+-----+ - | a1 | b1 | c1 | - +----+----+-----+ - | 11 | 8 | 110 | - | 9 | 8 | 90 | - +----+----+-----+ - "#)); + allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+-----+ + | a1 | b1 | c1 | + +----+----+-----+ + | 11 | 8 | 110 | + | 9 | 8 | 90 | + +----+----+-----+ + ")); assert_join_metrics!(metrics, 2); @@ -2620,13 +2620,13 @@ pub(crate) mod tests { ) .await?; assert_eq!(columns, vec!["a2", "b2", "c2"]); - allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+----+ - | a2 | b2 | c2 | - +----+----+----+ - | 2 | 2 | 80 | - +----+----+----+ - "#)); + allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+----+ + | a2 | b2 | c2 | + +----+----+----+ + | 2 | 2 | 80 | + +----+----+----+ + ")); assert_join_metrics!(metrics, 1); @@ -2652,14 +2652,14 @@ pub(crate) mod tests { ) .await?; assert_eq!(columns, vec!["a2", "b2", "c2"]); - allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+-----+ - | a2 | b2 | c2 | - +----+----+-----+ - | 10 | 10 | 100 | - | 12 | 10 | 40 | - +----+----+-----+ - "#)); + allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+-----+ + | a2 | b2 | c2 | + +----+----+-----+ + | 10 | 10 | 100 | + | 12 | 10 | 40 | + +----+----+-----+ + ")); assert_join_metrics!(metrics, 2); @@ -2685,15 +2685,15 @@ pub(crate) mod tests { ) .await?; assert_eq!(columns, vec!["a1", "b1", "c1", "mark"]); - allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+-----+-------+ - | a1 | b1 | c1 | mark | - +----+----+-----+-------+ - | 11 | 8 | 110 | false | - | 5 | 5 | 50 | true | - | 9 | 8 | 90 | false | - +----+----+-----+-------+ - "#)); + allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+-----+-------+ + | a1 | b1 | c1 | mark | + +----+----+-----+-------+ + | 11 | 8 | 110 | false | + | 5 | 5 | 50 | true | + | 9 | 8 | 90 | false | + +----+----+-----+-------+ + ")); assert_join_metrics!(metrics, 3); @@ -2720,15 +2720,15 @@ pub(crate) mod tests { .await?; assert_eq!(columns, vec!["a2", "b2", "c2", "mark"]); - allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+-----+-------+ - | a2 | b2 | c2 | mark | - +----+----+-----+-------+ - | 10 | 10 | 100 | false | - | 12 | 10 | 40 | false | - | 2 | 2 | 80 | true | - +----+----+-----+-------+ - "#)); + allow_duplicates!(assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+-----+-------+ + | a2 | b2 | c2 | mark | + +----+----+-----+-------+ + | 10 | 10 | 100 | false | + | 12 | 10 | 40 | false | + | 2 | 2 | 80 | true | + +----+----+-----+-------+ + ")); assert_join_metrics!(metrics, 3); diff --git a/datafusion/physical-plan/src/joins/piecewise_merge_join/classic_join.rs b/datafusion/physical-plan/src/joins/piecewise_merge_join/classic_join.rs index 7673fc084c467..04daa3698d920 100644 --- a/datafusion/physical-plan/src/joins/piecewise_merge_join/classic_join.rs +++ b/datafusion/physical-plan/src/joins/piecewise_merge_join/classic_join.rs @@ -803,7 +803,7 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::Lt, JoinType::Inner).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -814,7 +814,7 @@ mod tests { | 3 | 1 | 9 | 20 | 3 | 80 | | 3 | 1 | 9 | 10 | 2 | 70 | +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -854,18 +854,18 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::Lt, JoinType::Inner).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b1 | c2 | - +----+----+----+----+----+----+ - | 1 | 3 | 7 | 30 | 4 | 90 | - | 2 | 2 | 8 | 30 | 4 | 90 | - | 3 | 1 | 9 | 30 | 4 | 90 | - | 2 | 2 | 8 | 10 | 3 | 70 | - | 3 | 1 | 9 | 10 | 3 | 70 | - | 3 | 1 | 9 | 20 | 2 | 80 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b1 | c2 | + +----+----+----+----+----+----+ + | 1 | 3 | 7 | 30 | 4 | 90 | + | 2 | 2 | 8 | 30 | 4 | 90 | + | 3 | 1 | 9 | 30 | 4 | 90 | + | 2 | 2 | 8 | 10 | 3 | 70 | + | 3 | 1 | 9 | 10 | 3 | 70 | + | 3 | 1 | 9 | 20 | 2 | 80 | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -905,7 +905,7 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::GtEq, JoinType::Inner).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -918,7 +918,7 @@ mod tests { | 2 | 3 | 8 | 10 | 3 | 70 | | 3 | 4 | 9 | 10 | 3 | 70 | +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -953,12 +953,12 @@ mod tests { ); let (_, batches) = join_collect(left, right, on, Operator::LtEq, JoinType::Inner).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -996,7 +996,7 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::GtEq, JoinType::Full).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+-----+----+----+-----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+-----+----+----+-----+ @@ -1004,7 +1004,7 @@ mod tests { | | | | 10 | 3 | 300 | | 1 | 1 | 100 | | | | +----+----+-----+----+----+-----+ - "#); + "); Ok(()) } @@ -1045,7 +1045,7 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::Gt, JoinType::Left).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -1056,7 +1056,7 @@ mod tests { | 3 | 4 | 9 | 10 | 3 | 70 | | 1 | 1 | 7 | | | | +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -1096,7 +1096,7 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::Gt, JoinType::Right).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -1105,7 +1105,7 @@ mod tests { | 3 | 4 | 9 | 20 | 3 | 80 | | | | | 10 | 5 | 70 | +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -1145,7 +1145,7 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::Lt, JoinType::Right).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -1155,7 +1155,7 @@ mod tests { | 3 | 1 | 9 | 20 | 3 | 80 | | 3 | 1 | 9 | 10 | 2 | 70 | +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -1196,7 +1196,7 @@ mod tests { join_collect(left, right, on, Operator::LtEq, JoinType::Inner).await?; // Expected grouping follows right.b1 descending (4, 3, 2) - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -1206,7 +1206,7 @@ mod tests { | 3 | 2 | 9 | 20 | 3 | 80 | | 3 | 2 | 9 | 30 | 2 | 90 | +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -1247,7 +1247,7 @@ mod tests { join_collect(left, right, on, Operator::Gt, JoinType::Inner).await?; // Grouped by right in ascending evaluation for > (1,2,3) - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -1256,7 +1256,7 @@ mod tests { | 3 | 4 | 9 | 30 | 2 | 90 | | 3 | 4 | 9 | 10 | 3 | 70 | +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -1290,7 +1290,7 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::LtEq, JoinType::Left).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ @@ -1298,7 +1298,7 @@ mod tests { | 1 | 5 | 7 | | | | | 2 | 4 | 8 | | | | +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -1336,14 +1336,14 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::GtEq, JoinType::Right).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ | | | | 10 | 3 | 70 | | | | | 20 | 5 | 80 | +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -1365,13 +1365,13 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::Lt, JoinType::Inner).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+-----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+-----+----+----+----+ | 42 | 5 | 999 | 30 | 7 | 90 | +----+----+-----+----+----+----+ - "#); + "); Ok(()) } @@ -1397,12 +1397,12 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::Gt, JoinType::Inner).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +----+----+----+----+----+----+ | a1 | b1 | c1 | a2 | b1 | c2 | +----+----+----+----+----+----+ +----+----+----+----+----+----+ - "#); + "); Ok(()) } @@ -1442,13 +1442,13 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::Lt, JoinType::Inner).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +------------+------------+------------+------------+------------+------------+ - | a1 | b1 | c1 | a2 | b1 | c2 | - +------------+------------+------------+------------+------------+------------+ - | 1970-01-04 | 2022-04-23 | 1970-01-10 | 1970-01-31 | 2022-04-25 | 1970-04-01 | - +------------+------------+------------+------------+------------+------------+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +------------+------------+------------+------------+------------+------------+ + | a1 | b1 | c1 | a2 | b1 | c2 | + +------------+------------+------------+------------+------------+------------+ + | 1970-01-04 | 2022-04-23 | 1970-01-10 | 1970-01-31 | 2022-04-25 | 1970-04-01 | + +------------+------------+------------+------------+------------+------------+ + "); Ok(()) } @@ -1488,13 +1488,13 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::Lt, JoinType::Inner).await?; - assert_snapshot!(batches_to_string(&batches), @r#" + assert_snapshot!(batches_to_string(&batches), @r" +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ | a1 | b1 | c1 | a2 | b1 | c2 | +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ | 1970-01-01T00:00:00.003 | 2022-04-23T08:44:01 | 1970-01-01T00:00:00.009 | 1970-01-01T00:00:00.030 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.090 | +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ - "#); + "); Ok(()) } @@ -1532,14 +1532,14 @@ mod tests { let (_, batches) = join_collect(left, right, on, Operator::Lt, JoinType::Right).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ - | a1 | b1 | c1 | a2 | b1 | c2 | - +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ - | 1970-01-01T00:00:00.002 | 2022-04-23T08:44:01 | 1970-01-01T00:00:00.008 | 1970-01-01T00:00:00.020 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.090 | - | | | | 1970-01-01T00:00:00.010 | 2022-04-23T08:44:01 | 1970-01-01T00:00:00.080 | - +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ -"#); + assert_snapshot!(batches_to_string(&batches), @r" + +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ + | a1 | b1 | c1 | a2 | b1 | c2 | + +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ + | 1970-01-01T00:00:00.002 | 2022-04-23T08:44:01 | 1970-01-01T00:00:00.008 | 1970-01-01T00:00:00.020 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.090 | + | | | | 1970-01-01T00:00:00.010 | 2022-04-23T08:44:01 | 1970-01-01T00:00:00.080 | + +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ + "); Ok(()) } } diff --git a/datafusion/physical-plan/src/joins/sort_merge_join/tests.rs b/datafusion/physical-plan/src/joins/sort_merge_join/tests.rs index 46dfaac058aaa..171b6e5d682ad 100644 --- a/datafusion/physical-plan/src/joins/sort_merge_join/tests.rs +++ b/datafusion/physical-plan/src/joins/sort_merge_join/tests.rs @@ -365,15 +365,15 @@ async fn join_inner_one() -> Result<()> { let (_, batches) = join_collect(left, right, on, Inner).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b1 | c2 | - +----+----+----+----+----+----+ - | 1 | 4 | 7 | 10 | 4 | 70 | - | 2 | 5 | 8 | 20 | 5 | 80 | - | 3 | 5 | 9 | 20 | 5 | 80 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b1 | c2 | + +----+----+----+----+----+----+ + | 1 | 4 | 7 | 10 | 4 | 70 | + | 2 | 5 | 8 | 20 | 5 | 80 | + | 3 | 5 | 9 | 20 | 5 | 80 | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -403,15 +403,15 @@ async fn join_inner_two() -> Result<()> { let (_columns, batches) = join_collect(left, right, on, Inner).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b2 | c1 | a1 | b2 | c2 | - +----+----+----+----+----+----+ - | 1 | 1 | 7 | 1 | 1 | 70 | - | 2 | 2 | 8 | 2 | 2 | 80 | - | 2 | 2 | 9 | 2 | 2 | 80 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b2 | c1 | a1 | b2 | c2 | + +----+----+----+----+----+----+ + | 1 | 1 | 7 | 1 | 1 | 70 | + | 2 | 2 | 8 | 2 | 2 | 80 | + | 2 | 2 | 9 | 2 | 2 | 80 | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -441,16 +441,16 @@ async fn join_inner_two_two() -> Result<()> { let (_columns, batches) = join_collect(left, right, on, Inner).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b2 | c1 | a1 | b2 | c2 | - +----+----+----+----+----+----+ - | 1 | 1 | 7 | 1 | 1 | 70 | - | 1 | 1 | 7 | 1 | 1 | 80 | - | 1 | 1 | 8 | 1 | 1 | 70 | - | 1 | 1 | 8 | 1 | 1 | 80 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b2 | c1 | a1 | b2 | c2 | + +----+----+----+----+----+----+ + | 1 | 1 | 7 | 1 | 1 | 70 | + | 1 | 1 | 7 | 1 | 1 | 80 | + | 1 | 1 | 8 | 1 | 1 | 70 | + | 1 | 1 | 8 | 1 | 1 | 80 | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -479,15 +479,15 @@ async fn join_inner_with_nulls() -> Result<()> { let (_, batches) = join_collect(left, right, on, Inner).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b2 | c1 | a1 | b2 | c2 | - +----+----+----+----+----+----+ - | 1 | 1 | | 1 | 1 | 70 | - | 2 | 2 | 8 | 2 | 2 | 80 | - | 2 | 2 | 9 | 2 | 2 | 80 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b2 | c1 | a1 | b2 | c2 | + +----+----+----+----+----+----+ + | 1 | 1 | | 1 | 1 | 70 | + | 2 | 2 | 8 | 2 | 2 | 80 | + | 2 | 2 | 9 | 2 | 2 | 80 | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -529,16 +529,16 @@ async fn join_inner_with_nulls_with_options() -> Result<()> { ) .await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b2 | c1 | a1 | b2 | c2 | - +----+----+----+----+----+----+ - | 2 | 2 | 9 | 2 | 2 | 80 | - | 2 | 2 | 8 | 2 | 2 | 80 | - | 1 | 1 | | 1 | 1 | 70 | - | 1 | | 1 | 1 | | 10 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b2 | c1 | a1 | b2 | c2 | + +----+----+----+----+----+----+ + | 2 | 2 | 9 | 2 | 2 | 80 | + | 2 | 2 | 8 | 2 | 2 | 80 | + | 1 | 1 | | 1 | 1 | 70 | + | 1 | | 1 | 1 | | 10 | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -570,15 +570,15 @@ async fn join_inner_output_two_batches() -> Result<()> { assert_eq!(batches[0].num_rows(), 2); assert_eq!(batches[1].num_rows(), 1); // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b2 | c1 | a1 | b2 | c2 | - +----+----+----+----+----+----+ - | 1 | 1 | 7 | 1 | 1 | 70 | - | 2 | 2 | 8 | 2 | 2 | 80 | - | 2 | 2 | 9 | 2 | 2 | 80 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b2 | c1 | a1 | b2 | c2 | + +----+----+----+----+----+----+ + | 1 | 1 | 7 | 1 | 1 | 70 | + | 2 | 2 | 8 | 2 | 2 | 80 | + | 2 | 2 | 9 | 2 | 2 | 80 | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -601,15 +601,15 @@ async fn join_left_one() -> Result<()> { let (_, batches) = join_collect(left, right, on, Left).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b1 | c2 | - +----+----+----+----+----+----+ - | 1 | 4 | 7 | 10 | 4 | 70 | - | 2 | 5 | 8 | 20 | 5 | 80 | - | 3 | 7 | 9 | | | | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b1 | c2 | + +----+----+----+----+----+----+ + | 1 | 4 | 7 | 10 | 4 | 70 | + | 2 | 5 | 8 | 20 | 5 | 80 | + | 3 | 7 | 9 | | | | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -632,15 +632,15 @@ async fn join_right_one() -> Result<()> { let (_, batches) = join_collect(left, right, on, Right).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b1 | c2 | - +----+----+----+----+----+----+ - | 1 | 4 | 7 | 10 | 4 | 70 | - | 2 | 5 | 8 | 20 | 5 | 80 | - | | | | 30 | 6 | 90 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b1 | c2 | + +----+----+----+----+----+----+ + | 1 | 4 | 7 | 10 | 4 | 70 | + | 2 | 5 | 8 | 20 | 5 | 80 | + | | | | 30 | 6 | 90 | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -690,15 +690,15 @@ async fn join_right_different_columns_count_with_filter() -> Result<()> { let (_, batches) = join_collect_with_filter(left, right, on, filter, Right).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b1 | - +----+----+----+----+----+ - | | | | 10 | 4 | - | 21 | 5 | 8 | 20 | 5 | - | | | | 30 | 6 | - +----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b1 | + +----+----+----+----+----+ + | | | | 10 | 4 | + | 21 | 5 | 8 | 20 | 5 | + | | | | 30 | 6 | + +----+----+----+----+----+ + "); Ok(()) } @@ -748,15 +748,15 @@ async fn join_left_different_columns_count_with_filter() -> Result<()> { let (_, batches) = join_collect_with_filter(left, right, on, filter, Left).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+ - | a2 | b1 | a1 | b1 | c1 | - +----+----+----+----+----+ - | 10 | 4 | 1 | 4 | 7 | - | 20 | 5 | | | | - | 30 | 6 | | | | - +----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+ + | a2 | b1 | a1 | b1 | c1 | + +----+----+----+----+----+ + | 10 | 4 | 1 | 4 | 7 | + | 20 | 5 | | | | + | 30 | 6 | | | | + +----+----+----+----+----+ + "); Ok(()) } @@ -807,15 +807,15 @@ async fn join_left_mark_different_columns_count_with_filter() -> Result<()> { let (_, batches) = join_collect_with_filter(left, right, on, filter, LeftMark).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+-------+ - | a2 | b1 | mark | - +----+----+-------+ - | 10 | 4 | true | - | 20 | 5 | false | - | 30 | 6 | false | - +----+----+-------+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+-------+ + | a2 | b1 | mark | + +----+----+-------+ + | 10 | 4 | true | + | 20 | 5 | false | + | 30 | 6 | false | + +----+----+-------+ + "); Ok(()) } @@ -866,15 +866,15 @@ async fn join_right_mark_different_columns_count_with_filter() -> Result<()> { let (_, batches) = join_collect_with_filter(left, right, on, filter, RightMark).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+-------+ - | a2 | b1 | mark | - +----+----+-------+ - | 10 | 4 | false | - | 20 | 5 | true | - | 30 | 6 | false | - +----+----+-------+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+-------+ + | a2 | b1 | mark | + +----+----+-------+ + | 10 | 4 | false | + | 20 | 5 | true | + | 30 | 6 | false | + +----+----+-------+ + "); Ok(()) } @@ -897,16 +897,16 @@ async fn join_full_one() -> Result<()> { let (_, batches) = join_collect(left, right, on, Full).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+----+----+----+----+ - | | | | 30 | 6 | 90 | - | 1 | 4 | 7 | 10 | 4 | 70 | - | 2 | 5 | 8 | 20 | 5 | 80 | - | 3 | 7 | 9 | | | | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+----+----+----+----+ + | | | | 30 | 6 | 90 | + | 1 | 4 | 7 | 10 | 4 | 70 | + | 2 | 5 | 8 | 20 | 5 | 80 | + | 3 | 7 | 9 | | | | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -930,14 +930,14 @@ async fn join_left_anti() -> Result<()> { let (_, batches) = join_collect(left, right, on, LeftAnti).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+ - | a1 | b1 | c1 | - +----+----+----+ - | 3 | 7 | 9 | - | 5 | 7 | 11 | - +----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+ + | a1 | b1 | c1 | + +----+----+----+ + | 3 | 7 | 9 | + | 5 | 7 | 11 | + +----+----+----+ + "); Ok(()) } @@ -956,13 +956,13 @@ async fn join_right_anti_one_one() -> Result<()> { let (_, batches) = join_collect(left, right, on, RightAnti).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+ - | a2 | b1 | - +----+----+ - | 30 | 6 | - +----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+ + | a2 | b1 | + +----+----+ + | 30 | 6 | + +----+----+ + "); let left2 = build_table( ("a1", &vec![1, 2, 2]), @@ -982,13 +982,13 @@ async fn join_right_anti_one_one() -> Result<()> { let (_, batches2) = join_collect(left2, right2, on, RightAnti).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches2), @r#" - +----+----+----+ - | a2 | b1 | c2 | - +----+----+----+ - | 30 | 6 | 90 | - +----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches2), @r" + +----+----+----+ + | a2 | b1 | c2 | + +----+----+----+ + | 30 | 6 | 90 | + +----+----+----+ + "); Ok(()) } @@ -1014,15 +1014,15 @@ async fn join_right_anti_two_two() -> Result<()> { let (_, batches) = join_collect(left, right, on, RightAnti).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+ - | a2 | b1 | - +----+----+ - | 10 | 4 | - | 20 | 5 | - | 30 | 6 | - +----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+ + | a2 | b1 | + +----+----+ + | 10 | 4 | + | 20 | 5 | + | 30 | 6 | + +----+----+ + "); let left = build_table( ("a1", &vec![1, 2, 2]), @@ -1099,13 +1099,13 @@ async fn join_right_anti_two_with_filter() -> Result<()> { ); let (_, batches) = join_collect_with_filter(left, right, on, filter, RightAnti).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+ - | a1 | b1 | c2 | - +----+----+----+ - | 1 | 10 | 20 | - +----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+ + | a1 | b1 | c2 | + +----+----+----+ + | 1 | 10 | 20 | + +----+----+----+ + "); Ok(()) } @@ -1189,13 +1189,13 @@ async fn join_right_anti_with_nulls() -> Result<()> { let (_, batches) = join_collect(left, right, on, RightAnti).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+ - | a1 | b1 | c2 | - +----+----+----+ - | 2 | | 8 | - +----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+ + | a1 | b1 | c2 | + +----+----+----+ + | 2 | | 8 | + +----+----+----+ + "); Ok(()) } @@ -1239,15 +1239,15 @@ async fn join_right_anti_with_nulls_with_options() -> Result<()> { .await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+ - | a1 | b1 | c2 | - +----+----+----+ - | 3 | | 9 | - | 2 | 5 | | - | 2 | 5 | 8 | - +----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+ + | a1 | b1 | c2 | + +----+----+----+ + | 3 | | 9 | + | 2 | 5 | | + | 2 | 5 | 8 | + +----+----+----+ + "); Ok(()) } @@ -1279,15 +1279,15 @@ async fn join_right_anti_output_two_batches() -> Result<()> { assert_eq!(batches.len(), 2); assert_eq!(batches[0].num_rows(), 2); assert_eq!(batches[1].num_rows(), 1); - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+ - | a1 | b1 | c1 | - +----+----+----+ - | 1 | 4 | 7 | - | 2 | 5 | 8 | - | 2 | 5 | 8 | - +----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+ + | a1 | b1 | c1 | + +----+----+----+ + | 1 | 4 | 7 | + | 2 | 5 | 8 | + | 2 | 5 | 8 | + +----+----+----+ + "); Ok(()) } @@ -1310,15 +1310,15 @@ async fn join_left_semi() -> Result<()> { let (_, batches) = join_collect(left, right, on, LeftSemi).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+ - | a1 | b1 | c1 | - +----+----+----+ - | 1 | 4 | 7 | - | 2 | 5 | 8 | - | 2 | 5 | 8 | - +----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+ + | a1 | b1 | c1 | + +----+----+----+ + | 1 | 4 | 7 | + | 2 | 5 | 8 | + | 2 | 5 | 8 | + +----+----+----+ + "); Ok(()) } @@ -1590,16 +1590,16 @@ async fn join_left_mark() -> Result<()> { let (_, batches) = join_collect(left, right, on, LeftMark).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+-------+ - | a1 | b1 | c1 | mark | - +----+----+----+-------+ - | 1 | 4 | 7 | true | - | 2 | 5 | 8 | true | - | 2 | 5 | 8 | true | - | 3 | 7 | 9 | false | - +----+----+----+-------+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+-------+ + | a1 | b1 | c1 | mark | + +----+----+----+-------+ + | 1 | 4 | 7 | true | + | 2 | 5 | 8 | true | + | 2 | 5 | 8 | true | + | 3 | 7 | 9 | false | + +----+----+----+-------+ + "); Ok(()) } @@ -1622,16 +1622,16 @@ async fn join_right_mark() -> Result<()> { let (_, batches) = join_collect(left, right, on, RightMark).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+-------+ - | a2 | b1 | c2 | mark | - +----+----+----+-------+ - | 10 | 4 | 60 | true | - | 20 | 4 | 70 | true | - | 30 | 5 | 80 | true | - | 40 | 6 | 90 | false | - +----+----+----+-------+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+-------+ + | a2 | b1 | c2 | mark | + +----+----+----+-------+ + | 10 | 4 | 60 | true | + | 20 | 4 | 70 | true | + | 30 | 5 | 80 | true | + | 40 | 6 | 90 | false | + +----+----+----+-------+ + "); Ok(()) } @@ -1655,14 +1655,14 @@ async fn join_with_duplicated_column_names() -> Result<()> { let (_, batches) = join_collect(left, right, on, Inner).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +---+---+---+----+---+----+ - | a | b | c | a | b | c | - +---+---+---+----+---+----+ - | 1 | 4 | 7 | 10 | 1 | 70 | - | 2 | 5 | 8 | 20 | 2 | 80 | - +---+---+---+----+---+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +---+---+---+----+---+----+ + | a | b | c | a | b | c | + +---+---+---+----+---+----+ + | 1 | 4 | 7 | 10 | 1 | 70 | + | 2 | 5 | 8 | 20 | 2 | 80 | + +---+---+---+----+---+----+ + "); Ok(()) } @@ -1687,15 +1687,15 @@ async fn join_date32() -> Result<()> { let (_, batches) = join_collect(left, right, on, Inner).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +------------+------------+------------+------------+------------+------------+ - | a1 | b1 | c1 | a2 | b1 | c2 | - +------------+------------+------------+------------+------------+------------+ - | 1970-01-02 | 2022-04-25 | 1970-01-08 | 1970-01-11 | 2022-04-25 | 1970-03-12 | - | 1970-01-03 | 2022-04-26 | 1970-01-09 | 1970-01-21 | 2022-04-26 | 1970-03-22 | - | 1970-01-04 | 2022-04-26 | 1970-01-10 | 1970-01-21 | 2022-04-26 | 1970-03-22 | - +------------+------------+------------+------------+------------+------------+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +------------+------------+------------+------------+------------+------------+ + | a1 | b1 | c1 | a2 | b1 | c2 | + +------------+------------+------------+------------+------------+------------+ + | 1970-01-02 | 2022-04-25 | 1970-01-08 | 1970-01-11 | 2022-04-25 | 1970-03-12 | + | 1970-01-03 | 2022-04-26 | 1970-01-09 | 1970-01-21 | 2022-04-26 | 1970-03-22 | + | 1970-01-04 | 2022-04-26 | 1970-01-10 | 1970-01-21 | 2022-04-26 | 1970-03-22 | + +------------+------------+------------+------------+------------+------------+ + "); Ok(()) } @@ -1720,15 +1720,15 @@ async fn join_date64() -> Result<()> { let (_, batches) = join_collect(left, right, on, Inner).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ - | a1 | b1 | c1 | a2 | b1 | c2 | - +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ - | 1970-01-01T00:00:00.001 | 2022-04-23T08:44:01 | 1970-01-01T00:00:00.007 | 1970-01-01T00:00:00.010 | 2022-04-23T08:44:01 | 1970-01-01T00:00:00.070 | - | 1970-01-01T00:00:00.002 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.008 | 1970-01-01T00:00:00.030 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.090 | - | 1970-01-01T00:00:00.003 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.009 | 1970-01-01T00:00:00.030 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.090 | - +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ + | a1 | b1 | c1 | a2 | b1 | c2 | + +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ + | 1970-01-01T00:00:00.001 | 2022-04-23T08:44:01 | 1970-01-01T00:00:00.007 | 1970-01-01T00:00:00.010 | 2022-04-23T08:44:01 | 1970-01-01T00:00:00.070 | + | 1970-01-01T00:00:00.002 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.008 | 1970-01-01T00:00:00.030 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.090 | + | 1970-01-01T00:00:00.003 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.009 | 1970-01-01T00:00:00.030 | 2022-04-25T16:17:21 | 1970-01-01T00:00:00.090 | + +-------------------------+---------------------+-------------------------+-------------------------+---------------------+-------------------------+ + "); Ok(()) } @@ -1767,15 +1767,15 @@ async fn join_binary() -> Result<()> { let (_, batches) = join_collect(left, right, on, Inner).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +--------+----+----+--------+-----+----+ - | a1 | b1 | c1 | a1 | b2 | c2 | - +--------+----+----+--------+-----+----+ - | c0ffee | 5 | 7 | c0ffee | 105 | 70 | - | decade | 10 | 8 | decade | 110 | 80 | - | facade | 15 | 9 | facade | 115 | 90 | - +--------+----+----+--------+-----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +--------+----+----+--------+-----+----+ + | a1 | b1 | c1 | a1 | b2 | c2 | + +--------+----+----+--------+-----+----+ + | c0ffee | 5 | 7 | c0ffee | 105 | 70 | + | decade | 10 | 8 | decade | 110 | 80 | + | facade | 15 | 9 | facade | 115 | 90 | + +--------+----+----+--------+-----+----+ + "); Ok(()) } @@ -1814,15 +1814,15 @@ async fn join_fixed_size_binary() -> Result<()> { let (_, batches) = join_collect(left, right, on, Inner).await?; // The output order is important as SMJ preserves sortedness - assert_snapshot!(batches_to_string(&batches), @r#" - +--------+----+----+--------+-----+----+ - | a1 | b1 | c1 | a1 | b2 | c2 | - +--------+----+----+--------+-----+----+ - | c0ffee | 5 | 7 | c0ffee | 105 | 70 | - | decade | 10 | 8 | decade | 110 | 80 | - | facade | 15 | 9 | facade | 115 | 90 | - +--------+----+----+--------+-----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +--------+----+----+--------+-----+----+ + | a1 | b1 | c1 | a1 | b2 | c2 | + +--------+----+----+--------+-----+----+ + | c0ffee | 5 | 7 | c0ffee | 105 | 70 | + | decade | 10 | 8 | decade | 110 | 80 | + | facade | 15 | 9 | facade | 115 | 90 | + +--------+----+----+--------+-----+----+ + "); Ok(()) } @@ -1844,20 +1844,20 @@ async fn join_left_sort_order() -> Result<()> { )]; let (_, batches) = join_collect(left, right, on, Left).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+----+----+----+----+ - | 0 | 3 | 4 | | | | - | 1 | 4 | 5 | 10 | 4 | 60 | - | 2 | 5 | 6 | | | | - | 3 | 6 | 7 | 20 | 6 | 70 | - | 3 | 6 | 7 | 30 | 6 | 80 | - | 4 | 6 | 8 | 20 | 6 | 70 | - | 4 | 6 | 8 | 30 | 6 | 80 | - | 5 | 7 | 9 | | | | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+----+----+----+----+ + | 0 | 3 | 4 | | | | + | 1 | 4 | 5 | 10 | 4 | 60 | + | 2 | 5 | 6 | | | | + | 3 | 6 | 7 | 20 | 6 | 70 | + | 3 | 6 | 7 | 30 | 6 | 80 | + | 4 | 6 | 8 | 20 | 6 | 70 | + | 4 | 6 | 8 | 30 | 6 | 80 | + | 5 | 7 | 9 | | | | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -1879,16 +1879,16 @@ async fn join_right_sort_order() -> Result<()> { )]; let (_, batches) = join_collect(left, right, on, Right).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+----+----+----+----+ - | | | | 0 | 2 | 60 | - | 1 | 4 | 7 | 10 | 4 | 70 | - | 2 | 5 | 8 | 20 | 5 | 80 | - | | | | 30 | 6 | 90 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+----+----+----+----+ + | | | | 0 | 2 | 60 | + | 1 | 4 | 7 | 10 | 4 | 70 | + | 2 | 5 | 8 | 20 | 5 | 80 | + | | | | 30 | 6 | 90 | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -1922,21 +1922,21 @@ async fn join_left_multiple_batches() -> Result<()> { )]; let (_, batches) = join_collect(left, right, on, Left).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+----+----+----+----+ - | 0 | 3 | 4 | | | | - | 1 | 4 | 5 | 10 | 4 | 60 | - | 2 | 5 | 6 | | | | - | 3 | 6 | 7 | 20 | 6 | 70 | - | 3 | 6 | 7 | 30 | 6 | 80 | - | 4 | 6 | 8 | 20 | 6 | 70 | - | 4 | 6 | 8 | 30 | 6 | 80 | - | 5 | 7 | 9 | | | | - | 6 | 9 | 9 | | | | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+----+----+----+----+ + | 0 | 3 | 4 | | | | + | 1 | 4 | 5 | 10 | 4 | 60 | + | 2 | 5 | 6 | | | | + | 3 | 6 | 7 | 20 | 6 | 70 | + | 3 | 6 | 7 | 30 | 6 | 80 | + | 4 | 6 | 8 | 20 | 6 | 70 | + | 4 | 6 | 8 | 30 | 6 | 80 | + | 5 | 7 | 9 | | | | + | 6 | 9 | 9 | | | | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -1970,21 +1970,21 @@ async fn join_right_multiple_batches() -> Result<()> { )]; let (_, batches) = join_collect(left, right, on, Right).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+----+----+----+----+ - | | | | 0 | 3 | 4 | - | 10 | 4 | 60 | 1 | 4 | 5 | - | | | | 2 | 5 | 6 | - | 20 | 6 | 70 | 3 | 6 | 7 | - | 30 | 6 | 80 | 3 | 6 | 7 | - | 20 | 6 | 70 | 4 | 6 | 8 | - | 30 | 6 | 80 | 4 | 6 | 8 | - | | | | 5 | 7 | 9 | - | | | | 6 | 9 | 9 | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+----+----+----+----+ + | | | | 0 | 3 | 4 | + | 10 | 4 | 60 | 1 | 4 | 5 | + | | | | 2 | 5 | 6 | + | 20 | 6 | 70 | 3 | 6 | 7 | + | 30 | 6 | 80 | 3 | 6 | 7 | + | 20 | 6 | 70 | 4 | 6 | 8 | + | 30 | 6 | 80 | 4 | 6 | 8 | + | | | | 5 | 7 | 9 | + | | | | 6 | 9 | 9 | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -2018,23 +2018,23 @@ async fn join_full_multiple_batches() -> Result<()> { )]; let (_, batches) = join_collect(left, right, on, Full).await?; - assert_snapshot!(batches_to_sort_string(&batches), @r#" - +----+----+----+----+----+----+ - | a1 | b1 | c1 | a2 | b2 | c2 | - +----+----+----+----+----+----+ - | | | | 0 | 2 | 50 | - | | | | 40 | 8 | 90 | - | 0 | 3 | 4 | | | | - | 1 | 4 | 5 | 10 | 4 | 60 | - | 2 | 5 | 6 | | | | - | 3 | 6 | 7 | 20 | 6 | 70 | - | 3 | 6 | 7 | 30 | 6 | 80 | - | 4 | 6 | 8 | 20 | 6 | 70 | - | 4 | 6 | 8 | 30 | 6 | 80 | - | 5 | 7 | 9 | | | | - | 6 | 9 | 9 | | | | - +----+----+----+----+----+----+ - "#); + assert_snapshot!(batches_to_sort_string(&batches), @r" + +----+----+----+----+----+----+ + | a1 | b1 | c1 | a2 | b2 | c2 | + +----+----+----+----+----+----+ + | | | | 0 | 2 | 50 | + | | | | 40 | 8 | 90 | + | 0 | 3 | 4 | | | | + | 1 | 4 | 5 | 10 | 4 | 60 | + | 2 | 5 | 6 | | | | + | 3 | 6 | 7 | 20 | 6 | 70 | + | 3 | 6 | 7 | 30 | 6 | 80 | + | 4 | 6 | 8 | 20 | 6 | 70 | + | 4 | 6 | 8 | 30 | 6 | 80 | + | 5 | 7 | 9 | | | | + | 6 | 9 | 9 | | | | + +----+----+----+----+----+----+ + "); Ok(()) } @@ -2642,15 +2642,15 @@ async fn test_left_outer_join_filtered_mask() -> Result<()> { let filtered_rb = filter_record_batch(&output, &corrected_mask)?; - assert_snapshot!(batches_to_string(&[filtered_rb]), @r#" - +---+----+---+----+ - | a | b | x | y | - +---+----+---+----+ - | 1 | 10 | 1 | 11 | - | 1 | 11 | 1 | 12 | - | 1 | 12 | 1 | 13 | - +---+----+---+----+ - "#); + assert_snapshot!(batches_to_string(&[filtered_rb]), @r" + +---+----+---+----+ + | a | b | x | y | + +---+----+---+----+ + | 1 | 10 | 1 | 11 | + | 1 | 11 | 1 | 12 | + | 1 | 12 | 1 | 13 | + +---+----+---+----+ + "); // output null rows @@ -2671,14 +2671,14 @@ async fn test_left_outer_join_filtered_mask() -> Result<()> { let null_joined_batch = filter_record_batch(&output, &null_mask)?; - assert_snapshot!(batches_to_string(&[null_joined_batch]), @r#" - +---+----+---+----+ - | a | b | x | y | - +---+----+---+----+ - | 1 | 13 | 1 | 12 | - | 1 | 14 | 1 | 11 | - +---+----+---+----+ - "#); + assert_snapshot!(batches_to_string(&[null_joined_batch]), @r" + +---+----+---+----+ + | a | b | x | y | + +---+----+---+----+ + | 1 | 13 | 1 | 12 | + | 1 | 14 | 1 | 11 | + +---+----+---+----+ + "); Ok(()) } @@ -2989,14 +2989,14 @@ async fn test_anti_join_filtered_mask() -> Result<()> { let filtered_rb = filter_record_batch(&output, &corrected_mask)?; allow_duplicates! { - assert_snapshot!(batches_to_string(&[filtered_rb]), @r#" - +---+----+---+----+ - | a | b | x | y | - +---+----+---+----+ - | 1 | 13 | 1 | 12 | - | 1 | 14 | 1 | 11 | - +---+----+---+----+ - "#); + assert_snapshot!(batches_to_string(&[filtered_rb]), @r" + +---+----+---+----+ + | a | b | x | y | + +---+----+---+----+ + | 1 | 13 | 1 | 12 | + | 1 | 14 | 1 | 11 | + +---+----+---+----+ + "); } // output null rows @@ -3018,12 +3018,12 @@ async fn test_anti_join_filtered_mask() -> Result<()> { let null_joined_batch = filter_record_batch(&output, &null_mask)?; allow_duplicates! { - assert_snapshot!(batches_to_string(&[null_joined_batch]), @r#" - +---+---+---+---+ - | a | b | x | y | - +---+---+---+---+ - +---+---+---+---+ - "#); + assert_snapshot!(batches_to_string(&[null_joined_batch]), @r" + +---+---+---+---+ + | a | b | x | y | + +---+---+---+---+ + +---+---+---+---+ + "); } } diff --git a/datafusion/physical-plan/src/sorts/partial_sort.rs b/datafusion/physical-plan/src/sorts/partial_sort.rs index c474a1a9ea4c7..73ba889c9e40b 100644 --- a/datafusion/physical-plan/src/sorts/partial_sort.rs +++ b/datafusion/physical-plan/src/sorts/partial_sort.rs @@ -549,18 +549,18 @@ mod tests { assert_eq!(2, result.len()); allow_duplicates! { - assert_snapshot!(batches_to_string(&result), @r#" - +---+---+---+ - | a | b | c | - +---+---+---+ - | 0 | 1 | 0 | - | 0 | 1 | 1 | - | 0 | 2 | 5 | - | 1 | 2 | 4 | - | 1 | 3 | 2 | - | 1 | 3 | 3 | - +---+---+---+ - "#); + assert_snapshot!(batches_to_string(&result), @r" + +---+---+---+ + | a | b | c | + +---+---+---+ + | 0 | 1 | 0 | + | 0 | 1 | 1 | + | 0 | 2 | 5 | + | 1 | 2 | 4 | + | 1 | 3 | 2 | + | 1 | 3 | 3 | + +---+---+---+ + "); } assert_eq!( task_ctx.runtime_env().memory_pool.reserved(), @@ -617,16 +617,16 @@ mod tests { assert_eq!(2, result.len()); allow_duplicates! { - assert_snapshot!(batches_to_string(&result), @r#" - +---+---+---+ - | a | b | c | - +---+---+---+ - | 0 | 1 | 4 | - | 0 | 2 | 3 | - | 1 | 2 | 2 | - | 1 | 3 | 0 | - +---+---+---+ - "#); + assert_snapshot!(batches_to_string(&result), @r" + +---+---+---+ + | a | b | c | + +---+---+---+ + | 0 | 1 | 4 | + | 0 | 2 | 3 | + | 1 | 2 | 2 | + | 1 | 3 | 0 | + +---+---+---+ + "); } assert_eq!( task_ctx.runtime_env().memory_pool.reserved(), @@ -693,20 +693,20 @@ mod tests { "The sort should have returned all memory used back to the memory manager" ); allow_duplicates! { - assert_snapshot!(batches_to_string(&result), @r#" - +---+---+---+ - | a | b | c | - +---+---+---+ - | 0 | 1 | 6 | - | 0 | 1 | 7 | - | 0 | 3 | 4 | - | 0 | 3 | 5 | - | 1 | 2 | 0 | - | 1 | 2 | 1 | - | 1 | 4 | 2 | - | 1 | 4 | 3 | - +---+---+---+ - "#); + assert_snapshot!(batches_to_string(&result), @r" + +---+---+---+ + | a | b | c | + +---+---+---+ + | 0 | 1 | 6 | + | 0 | 1 | 7 | + | 0 | 3 | 4 | + | 0 | 3 | 5 | + | 1 | 2 | 0 | + | 1 | 2 | 1 | + | 1 | 4 | 2 | + | 1 | 4 | 3 | + +---+---+---+ + "); } } Ok(()) @@ -1051,20 +1051,20 @@ mod tests { task_ctx, ) .await?; - assert_snapshot!(batches_to_string(&result), @r#" - +-----+------+-------+ - | a | b | c | - +-----+------+-------+ - | 1.0 | 20.0 | 20.0 | - | 1.0 | 20.0 | 10.0 | - | 1.0 | 40.0 | 10.0 | - | 2.0 | 40.0 | 100.0 | - | 2.0 | NaN | NaN | - | 3.0 | | | - | 3.0 | | 100.0 | - | 3.0 | NaN | NaN | - +-----+------+-------+ - "#); + assert_snapshot!(batches_to_string(&result), @r" + +-----+------+-------+ + | a | b | c | + +-----+------+-------+ + | 1.0 | 20.0 | 20.0 | + | 1.0 | 20.0 | 10.0 | + | 1.0 | 40.0 | 10.0 | + | 2.0 | 40.0 | 100.0 | + | 2.0 | NaN | NaN | + | 3.0 | | | + | 3.0 | | 100.0 | + | 3.0 | NaN | NaN | + +-----+------+-------+ + "); assert_eq!(result.len(), 2); let metrics = partial_sort_exec.metrics().unwrap(); assert!(metrics.elapsed_compute().unwrap() > 0); @@ -1177,21 +1177,21 @@ mod tests { assert_eq!(result.len(), 3,); allow_duplicates! { - assert_snapshot!(batches_to_string(&result), @r#" - +---+---+---+ - | a | b | c | - +---+---+---+ - | 1 | 1 | 1 | - | 1 | 1 | 2 | - | 1 | 1 | 3 | - | 2 | 2 | 4 | - | 2 | 2 | 4 | - | 2 | 2 | 6 | - | 3 | 3 | 7 | - | 3 | 3 | 8 | - | 3 | 3 | 9 | - +---+---+---+ - "#); + assert_snapshot!(batches_to_string(&result), @r" + +---+---+---+ + | a | b | c | + +---+---+---+ + | 1 | 1 | 1 | + | 1 | 1 | 2 | + | 1 | 1 | 3 | + | 2 | 2 | 4 | + | 2 | 2 | 4 | + | 2 | 2 | 6 | + | 3 | 3 | 7 | + | 3 | 3 | 8 | + | 3 | 3 | 9 | + +---+---+---+ + "); } assert_eq!(task_ctx.runtime_env().memory_pool.reserved(), 0,); diff --git a/datafusion/physical-plan/src/sorts/sort.rs b/datafusion/physical-plan/src/sorts/sort.rs index 9c92082d68779..18cdcbe9debcc 100644 --- a/datafusion/physical-plan/src/sorts/sort.rs +++ b/datafusion/physical-plan/src/sorts/sort.rs @@ -2119,21 +2119,21 @@ mod tests { plan = plan.with_fetch(Some(9)); let batches = collect(Arc::new(plan), task_ctx).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+ - | c1 | - +----+ - | 0 | - | 1 | - | 2 | - | 3 | - | 4 | - | 5 | - | 6 | - | 7 | - | 8 | - +----+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+ + | c1 | + +----+ + | 0 | + | 1 | + | 2 | + | 3 | + | 4 | + | 5 | + | 6 | + | 7 | + | 8 | + +----+ + "); Ok(()) } diff --git a/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs b/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs index e826f2f4aabbd..4b26f84099505 100644 --- a/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs +++ b/datafusion/physical-plan/src/sorts/sort_preserving_merge.rs @@ -983,22 +983,22 @@ mod tests { let collected = collect(merge, task_ctx).await.unwrap(); assert_eq!(collected.len(), 1); - assert_snapshot!(batches_to_string(collected.as_slice()), @r#" - +---+---+-------------------------------+ - | a | b | c | - +---+---+-------------------------------+ - | 1 | | 1970-01-01T00:00:00.000000008 | - | 1 | | 1970-01-01T00:00:00.000000008 | - | 2 | a | | - | 7 | b | 1970-01-01T00:00:00.000000006 | - | 2 | b | | - | 9 | d | | - | 3 | e | 1970-01-01T00:00:00.000000004 | - | 3 | g | 1970-01-01T00:00:00.000000005 | - | 4 | h | | - | 5 | i | 1970-01-01T00:00:00.000000004 | - +---+---+-------------------------------+ - "#); + assert_snapshot!(batches_to_string(collected.as_slice()), @r" + +---+---+-------------------------------+ + | a | b | c | + +---+---+-------------------------------+ + | 1 | | 1970-01-01T00:00:00.000000008 | + | 1 | | 1970-01-01T00:00:00.000000008 | + | 2 | a | | + | 7 | b | 1970-01-01T00:00:00.000000006 | + | 2 | b | | + | 9 | d | | + | 3 | e | 1970-01-01T00:00:00.000000004 | + | 3 | g | 1970-01-01T00:00:00.000000005 | + | 4 | h | | + | 5 | i | 1970-01-01T00:00:00.000000004 | + +---+---+-------------------------------+ + "); } #[tokio::test] @@ -1024,14 +1024,14 @@ mod tests { let collected = collect(merge, task_ctx).await.unwrap(); assert_eq!(collected.len(), 1); - assert_snapshot!(batches_to_string(collected.as_slice()), @r#" - +---+---+ - | a | b | - +---+---+ - | 1 | a | - | 2 | b | - +---+---+ - "#); + assert_snapshot!(batches_to_string(collected.as_slice()), @r" + +---+---+ + | a | b | + +---+---+ + | 1 | a | + | 2 | b | + +---+---+ + "); } #[tokio::test] @@ -1056,17 +1056,17 @@ mod tests { let collected = collect(merge, task_ctx).await.unwrap(); assert_eq!(collected.len(), 1); - assert_snapshot!(batches_to_string(collected.as_slice()), @r#" - +---+---+ - | a | b | - +---+---+ - | 1 | a | - | 2 | b | - | 7 | c | - | 9 | d | - | 3 | e | - +---+---+ - "#); + assert_snapshot!(batches_to_string(collected.as_slice()), @r" + +---+---+ + | a | b | + +---+---+ + | 1 | a | + | 2 | b | + | 7 | c | + | 9 | d | + | 3 | e | + +---+---+ + "); } #[tokio::test] @@ -1165,16 +1165,16 @@ mod tests { let collected = collect(Arc::clone(&merge) as Arc, task_ctx) .await .unwrap(); - assert_snapshot!(batches_to_string(collected.as_slice()), @r#" - +----+---+ - | a | b | - +----+---+ - | 1 | a | - | 10 | b | - | 2 | c | - | 20 | d | - +----+---+ - "#); + assert_snapshot!(batches_to_string(collected.as_slice()), @r" + +----+---+ + | a | b | + +----+---+ + | 1 | a | + | 10 | b | + | 2 | c | + | 20 | d | + +----+---+ + "); // Now, validate metrics let metrics = merge.metrics().unwrap(); @@ -1280,32 +1280,32 @@ mod tests { // Expect the data to be sorted first by "batch_number" (because // that was the order it was fed in, even though only "value" // is in the sort key) - assert_snapshot!(batches_to_string(collected.as_slice()), @r#" - +--------------+-------+ - | batch_number | value | - +--------------+-------+ - | 0 | A | - | 1 | A | - | 2 | A | - | 3 | A | - | 4 | A | - | 5 | A | - | 6 | A | - | 7 | A | - | 8 | A | - | 9 | A | - | 0 | B | - | 1 | B | - | 2 | B | - | 3 | B | - | 4 | B | - | 5 | B | - | 6 | B | - | 7 | B | - | 8 | B | - | 9 | B | - +--------------+-------+ - "#); + assert_snapshot!(batches_to_string(collected.as_slice()), @r" + +--------------+-------+ + | batch_number | value | + +--------------+-------+ + | 0 | A | + | 1 | A | + | 2 | A | + | 3 | A | + | 4 | A | + | 5 | A | + | 6 | A | + | 7 | A | + | 8 | A | + | 9 | A | + | 0 | B | + | 1 | B | + | 2 | B | + | 3 | B | + | 4 | B | + | 5 | B | + | 6 | B | + | 7 | B | + | 8 | B | + | 9 | B | + +--------------+-------+ + "); } #[derive(Debug)] diff --git a/datafusion/physical-plan/src/unnest.rs b/datafusion/physical-plan/src/unnest.rs index 8184c9d2c520c..5fef754e80780 100644 --- a/datafusion/physical-plan/src/unnest.rs +++ b/datafusion/physical-plan/src/unnest.rs @@ -1199,32 +1199,32 @@ mod tests { .unwrap(); assert_snapshot!(batches_to_string(&[ret]), - @r###" -+---------------------------------+---------------------------------+---------------------------------+ -| col1_unnest_placeholder_depth_1 | col1_unnest_placeholder_depth_2 | col2_unnest_placeholder_depth_1 | -+---------------------------------+---------------------------------+---------------------------------+ -| [1, 2, 3] | 1 | a | -| | 2 | b | -| [4, 5] | 3 | | -| [1, 2, 3] | | a | -| | | b | -| [4, 5] | | | -| [1, 2, 3] | 4 | a | -| | 5 | b | -| [4, 5] | | | -| [7, 8, 9, 10] | 7 | c | -| | 8 | d | -| [11, 12, 13] | 9 | | -| | 10 | | -| [7, 8, 9, 10] | | c | -| | | d | -| [11, 12, 13] | | | -| [7, 8, 9, 10] | 11 | c | -| | 12 | d | -| [11, 12, 13] | 13 | | -| | | e | -+---------------------------------+---------------------------------+---------------------------------+ - "###); + @r" + +---------------------------------+---------------------------------+---------------------------------+ + | col1_unnest_placeholder_depth_1 | col1_unnest_placeholder_depth_2 | col2_unnest_placeholder_depth_1 | + +---------------------------------+---------------------------------+---------------------------------+ + | [1, 2, 3] | 1 | a | + | | 2 | b | + | [4, 5] | 3 | | + | [1, 2, 3] | | a | + | | | b | + | [4, 5] | | | + | [1, 2, 3] | 4 | a | + | | 5 | b | + | [4, 5] | | | + | [7, 8, 9, 10] | 7 | c | + | | 8 | d | + | [11, 12, 13] | 9 | | + | | 10 | | + | [7, 8, 9, 10] | | c | + | | | d | + | [11, 12, 13] | | | + | [7, 8, 9, 10] | 11 | c | + | | 12 | d | + | [11, 12, 13] | 13 | | + | | | e | + +---------------------------------+---------------------------------+---------------------------------+ + "); Ok(()) } diff --git a/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs b/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs index 302dd38380e1e..987a400ec369e 100644 --- a/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs +++ b/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs @@ -1690,21 +1690,21 @@ mod tests { DataSourceExec: partitions=1, partition_sizes=[3] "#); - assert_snapshot!(batches_to_string(&batches), @r#" - +---+------+---------------+---------------+ - | a | last | nth_value(-1) | nth_value(-2) | - +---+------+---------------+---------------+ - | 1 | 1 | 1 | | - | 2 | 2 | 2 | 1 | - | 3 | 3 | 3 | 2 | - | 1 | 1 | 1 | 3 | - | 2 | 2 | 2 | 1 | - | 3 | 3 | 3 | 2 | - | 1 | 1 | 1 | 3 | - | 2 | 2 | 2 | 1 | - | 3 | 3 | 3 | 2 | - +---+------+---------------+---------------+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +---+------+---------------+---------------+ + | a | last | nth_value(-1) | nth_value(-2) | + +---+------+---------------+---------------+ + | 1 | 1 | 1 | | + | 2 | 2 | 2 | 1 | + | 3 | 3 | 3 | 2 | + | 1 | 1 | 1 | 3 | + | 2 | 2 | 2 | 1 | + | 3 | 3 | 3 | 2 | + | 1 | 1 | 1 | 3 | + | 2 | 2 | 2 | 1 | + | 3 | 3 | 3 | 2 | + +---+------+---------------+---------------+ + "); Ok(()) } @@ -1811,20 +1811,20 @@ mod tests { let task_ctx = task_context(); let batches = collect_with_timeout(plan, task_ctx, timeout_duration).await?; - assert_snapshot!(batches_to_string(&batches), @r#" - +----+------+-------+ - | sn | hash | col_2 | - +----+------+-------+ - | 0 | 2 | 2 | - | 1 | 2 | 2 | - | 2 | 2 | 2 | - | 3 | 2 | 1 | - | 4 | 1 | 2 | - | 5 | 1 | 2 | - | 6 | 1 | 2 | - | 7 | 1 | 1 | - +----+------+-------+ - "#); + assert_snapshot!(batches_to_string(&batches), @r" + +----+------+-------+ + | sn | hash | col_2 | + +----+------+-------+ + | 0 | 2 | 2 | + | 1 | 2 | 2 | + | 2 | 2 | 2 | + | 3 | 2 | 1 | + | 4 | 1 | 2 | + | 5 | 1 | 2 | + | 6 | 1 | 2 | + | 7 | 1 | 1 | + +----+------+-------+ + "); Ok(()) } diff --git a/datafusion/sql/tests/cases/params.rs b/datafusion/sql/tests/cases/params.rs index 0d5f09142e6e5..396f619400c74 100644 --- a/datafusion/sql/tests/cases/params.rs +++ b/datafusion/sql/tests/cases/params.rs @@ -103,9 +103,7 @@ fn test_prepare_statement_to_plan_panic_param_format() { assert_snapshot!( logical_plan(sql).unwrap_err().strip_backtrace(), - @r###" - Error during planning: Unknown placeholder: $foo - "### + @"Error during planning: Unknown placeholder: $foo" ); } @@ -117,9 +115,7 @@ fn test_prepare_statement_to_plan_panic_param_zero() { assert_snapshot!( logical_plan(sql).unwrap_err().strip_backtrace(), - @r###" - Error during planning: Invalid placeholder, zero is not a valid index: $0 - "### + @"Error during planning: Invalid placeholder, zero is not a valid index: $0" ); } @@ -143,7 +139,7 @@ fn test_prepare_statement_to_plan_panic_no_relation_and_constant_param() { let plan = logical_plan(sql).unwrap_err().strip_backtrace(); assert_snapshot!( plan, - @r"Schema error: No field named id." + @"Schema error: No field named id." ); } @@ -196,7 +192,7 @@ fn test_prepare_statement_to_plan_no_param() { TableScan: person "# ); - assert_snapshot!(dt, @r#"Int32"#); + assert_snapshot!(dt, @"Int32"); /////////////////// // replace params with values @@ -224,7 +220,7 @@ fn test_prepare_statement_to_plan_no_param() { TableScan: person "# ); - assert_snapshot!(dt, @r#""#); + assert_snapshot!(dt, @""); /////////////////// // replace params with values @@ -252,9 +248,7 @@ fn test_prepare_statement_to_plan_one_param_no_value_panic() { plan.with_param_values(param_values) .unwrap_err() .strip_backtrace(), - @r###" - Error during planning: Expected 1 parameters, got 0 - "###); + @"Error during planning: Expected 1 parameters, got 0"); } #[test] @@ -269,9 +263,7 @@ fn test_prepare_statement_to_plan_one_param_one_value_different_type_panic() { plan.with_param_values(param_values) .unwrap_err() .strip_backtrace(), - @r###" - Error during planning: Expected parameter of type Int32, got Float64 at index 0 - "### + @"Error during planning: Expected parameter of type Int32, got Float64 at index 0" ); } @@ -287,9 +279,7 @@ fn test_prepare_statement_to_plan_no_param_on_value_panic() { plan.with_param_values(param_values) .unwrap_err() .strip_backtrace(), - @r###" - Error during planning: Expected 0 parameters, got 1 - "### + @"Error during planning: Expected 0 parameters, got 1" ); } @@ -305,7 +295,7 @@ fn test_prepare_statement_to_plan_params_as_constants() { EmptyRelation: rows=1 "# ); - assert_snapshot!(dt, @r#"Int32"#); + assert_snapshot!(dt, @"Int32"); /////////////////// // replace params with values @@ -330,7 +320,7 @@ fn test_prepare_statement_to_plan_params_as_constants() { EmptyRelation: rows=1 "# ); - assert_snapshot!(dt, @r#"Int32"#); + assert_snapshot!(dt, @"Int32"); /////////////////// // replace params with values @@ -355,7 +345,7 @@ fn test_prepare_statement_to_plan_params_as_constants() { EmptyRelation: rows=1 "# ); - assert_snapshot!(dt, @r#"Int32, Float64"#); + assert_snapshot!(dt, @"Int32, Float64"); /////////////////// // replace params with values @@ -721,7 +711,7 @@ fn test_prepare_statement_to_plan_one_param() { TableScan: person "# ); - assert_snapshot!(dt, @r#"Int32"#); + assert_snapshot!(dt, @"Int32"); /////////////////// // replace params with values @@ -895,7 +885,7 @@ fn test_prepare_statement_to_plan_data_type() { TableScan: person "# ); - assert_snapshot!(dt, @r#"Float64"#); + assert_snapshot!(dt, @"Float64"); /////////////////// // replace params with values still succeed and use Float64 @@ -928,7 +918,7 @@ fn test_prepare_statement_to_plan_multi_params() { TableScan: person "# ); - assert_snapshot!(dt, @r#"Int32, Utf8View, Float64, Int32, Float64, Utf8View"#); + assert_snapshot!(dt, @"Int32, Utf8View, Float64, Int32, Float64, Utf8View"); /////////////////// // replace params with values @@ -973,7 +963,7 @@ fn test_prepare_statement_to_plan_having() { TableScan: person "# ); - assert_snapshot!(dt, @r#"Int32, Float64, Float64, Float64"#); + assert_snapshot!(dt, @"Int32, Float64, Float64, Float64"); /////////////////// // replace params with values @@ -987,13 +977,13 @@ fn test_prepare_statement_to_plan_having() { let plan_with_params = plan.with_param_values(param_values).unwrap(); assert_snapshot!( plan_with_params, - @r#" + @r" Projection: person.id, sum(person.age) Filter: sum(person.age) < Int32(10) AND sum(person.age) > Int64(10) OR sum(person.age) IN ([Float64(200), Float64(300)]) Aggregate: groupBy=[[person.id]], aggr=[[sum(person.age)]] Filter: person.salary > Float64(100) TableScan: person - "# + " ); } @@ -1012,18 +1002,18 @@ fn test_prepare_statement_to_plan_limit() { TableScan: person "# ); - assert_snapshot!(dt, @r#"Int64, Int64"#); + assert_snapshot!(dt, @"Int64, Int64"); // replace params with values let param_values = vec![ScalarValue::Int64(Some(10)), ScalarValue::Int64(Some(200))]; let plan_with_params = plan.with_param_values(param_values).unwrap(); assert_snapshot!( plan_with_params, - @r#" + @r" Limit: skip=10, fetch=200 Projection: person.id TableScan: person - "# + " ); } diff --git a/datafusion/sql/tests/cases/plan_to_sql.rs b/datafusion/sql/tests/cases/plan_to_sql.rs index 725a7554fbe5a..39d2cb241b701 100644 --- a/datafusion/sql/tests/cases/plan_to_sql.rs +++ b/datafusion/sql/tests/cases/plan_to_sql.rs @@ -70,26 +70,26 @@ use sqlparser::parser::Parser; #[test] fn test_roundtrip_expr_1() { let expr = roundtrip_expr(TableReference::bare("person"), "age > 35").unwrap(); - assert_snapshot!(expr, @r#"(age > 35)"#); + assert_snapshot!(expr, @"(age > 35)"); } #[test] fn test_roundtrip_expr_2() { let expr = roundtrip_expr(TableReference::bare("person"), "id = '10'").unwrap(); - assert_snapshot!(expr, @r#"(id = '10')"#); + assert_snapshot!(expr, @"(id = '10')"); } #[test] fn test_roundtrip_expr_3() { let expr = roundtrip_expr(TableReference::bare("person"), "CAST(id AS VARCHAR)").unwrap(); - assert_snapshot!(expr, @r#"CAST(id AS VARCHAR)"#); + assert_snapshot!(expr, @"CAST(id AS VARCHAR)"); } #[test] fn test_roundtrip_expr_4() { let expr = roundtrip_expr(TableReference::bare("person"), "sum((age * 2))").unwrap(); - assert_snapshot!(expr, @r#"sum((age * 2))"#); + assert_snapshot!(expr, @"sum((age * 2))"); } fn roundtrip_expr(table: TableReference, sql: &str) -> Result { @@ -400,7 +400,7 @@ fn roundtrip_statement_with_dialect_7() -> Result<(), DataFusionError> { sql: "select ta.j1_id from j1 ta order by j1_id limit 10;", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT ta.j1_id FROM j1 AS ta ORDER BY ta.j1_id ASC NULLS LAST LIMIT 10"#, + expected: @"SELECT ta.j1_id FROM j1 AS ta ORDER BY ta.j1_id ASC NULLS LAST LIMIT 10", ); Ok(()) } @@ -415,7 +415,7 @@ fn roundtrip_statement_with_dialect_8() -> Result<(), DataFusionError> { LIMIT 10;", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT j1.j1_id FROM j1 UNION ALL SELECT tb.j2_id AS j1_id FROM j2 AS tb ORDER BY j1_id ASC NULLS LAST LIMIT 10"#, + expected: @"SELECT j1.j1_id FROM j1 UNION ALL SELECT tb.j2_id AS j1_id FROM j2 AS tb ORDER BY j1_id ASC NULLS LAST LIMIT 10", ); Ok(()) } @@ -427,7 +427,7 @@ fn roundtrip_statement_with_dialect_9() -> Result<(), DataFusionError> { sql: "SELECT j1_string from j1 order by j1_id", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT j1.j1_string FROM j1 ORDER BY j1.j1_id ASC NULLS LAST"#, + expected: @"SELECT j1.j1_string FROM j1 ORDER BY j1.j1_id ASC NULLS LAST", ); Ok(()) } @@ -438,7 +438,7 @@ fn roundtrip_statement_with_dialect_10() -> Result<(), DataFusionError> { sql: "SELECT j1_string AS a from j1 order by j1_id", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT j1.j1_string AS a FROM j1 ORDER BY j1.j1_id ASC NULLS LAST"#, + expected: @"SELECT j1.j1_string AS a FROM j1 ORDER BY j1.j1_id ASC NULLS LAST", ); Ok(()) } @@ -449,7 +449,7 @@ fn roundtrip_statement_with_dialect_11() -> Result<(), DataFusionError> { sql: "SELECT j1_string from j1 join j2 on j1.j1_id = j2.j2_id order by j1_id", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT j1.j1_string FROM j1 INNER JOIN j2 ON (j1.j1_id = j2.j2_id) ORDER BY j1.j1_id ASC NULLS LAST"#, + expected: @"SELECT j1.j1_string FROM j1 INNER JOIN j2 ON (j1.j1_id = j2.j2_id) ORDER BY j1.j1_id ASC NULLS LAST", ); Ok(()) } @@ -479,7 +479,7 @@ fn roundtrip_statement_with_dialect_12() -> Result<(), DataFusionError> { abc.j2_string", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT abc.j1_string, abc.j2_string FROM (SELECT DISTINCT j1.j1_id, j1.j1_string, j2.j2_string FROM j1 INNER JOIN j2 ON (j1.j1_id = j2.j2_id) ORDER BY j1.j1_id DESC NULLS FIRST LIMIT 10) AS abc ORDER BY abc.j2_string ASC NULLS LAST"#, + expected: @"SELECT abc.j1_string, abc.j2_string FROM (SELECT DISTINCT j1.j1_id, j1.j1_string, j2.j2_string FROM j1 INNER JOIN j2 ON (j1.j1_id = j2.j2_id) ORDER BY j1.j1_id DESC NULLS FIRST LIMIT 10) AS abc ORDER BY abc.j2_string ASC NULLS LAST", ); Ok(()) } @@ -501,7 +501,7 @@ fn roundtrip_statement_with_dialect_13() -> Result<(), DataFusionError> { ", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT agg.string_count FROM (SELECT j1.j1_id, min(j2.j2_string) FROM j1 LEFT OUTER JOIN j2 ON (j1.j1_id = j2.j2_id) GROUP BY j1.j1_id) AS agg (id, string_count)"#, + expected: @"SELECT agg.string_count FROM (SELECT j1.j1_id, min(j2.j2_string) FROM j1 LEFT OUTER JOIN j2 ON (j1.j1_id = j2.j2_id) GROUP BY j1.j1_id) AS agg (id, string_count)", ); Ok(()) } @@ -535,7 +535,7 @@ fn roundtrip_statement_with_dialect_14() -> Result<(), DataFusionError> { abc.j2_string", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT abc.j1_string, abc.j2_string FROM (SELECT j1.j1_id, j1.j1_string, j2.j2_string FROM j1 INNER JOIN j2 ON (j1.j1_id = j2.j2_id) GROUP BY j1.j1_id, j1.j1_string, j2.j2_string ORDER BY j1.j1_id DESC NULLS FIRST LIMIT 10) AS abc ORDER BY abc.j2_string ASC NULLS LAST"#, + expected: @"SELECT abc.j1_string, abc.j2_string FROM (SELECT j1.j1_id, j1.j1_string, j2.j2_string FROM j1 INNER JOIN j2 ON (j1.j1_id = j2.j2_id) GROUP BY j1.j1_id, j1.j1_string, j2.j2_string ORDER BY j1.j1_id DESC NULLS FIRST LIMIT 10) AS abc ORDER BY abc.j2_string ASC NULLS LAST", ); Ok(()) } @@ -565,7 +565,7 @@ fn roundtrip_statement_with_dialect_15() -> Result<(), DataFusionError> { j2_string", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT abc.j1_string FROM (SELECT j1.j1_string, j2.j2_string FROM j1 INNER JOIN j2 ON (j1.j1_id = j2.j2_id) ORDER BY j1.j1_id DESC NULLS FIRST, j2.j2_id DESC NULLS FIRST LIMIT 10) AS abc ORDER BY abc.j2_string ASC NULLS LAST"#, + expected: @"SELECT abc.j1_string FROM (SELECT j1.j1_string, j2.j2_string FROM j1 INNER JOIN j2 ON (j1.j1_id = j2.j2_id) ORDER BY j1.j1_id DESC NULLS FIRST, j2.j2_id DESC NULLS FIRST LIMIT 10) AS abc ORDER BY abc.j2_string ASC NULLS LAST", ); Ok(()) } @@ -576,7 +576,7 @@ fn roundtrip_statement_with_dialect_16() -> Result<(), DataFusionError> { sql: "SELECT id FROM (SELECT j1_id from j1) AS c (id)", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT c.id FROM (SELECT j1.j1_id FROM j1) AS c (id)"#, + expected: @"SELECT c.id FROM (SELECT j1.j1_id FROM j1) AS c (id)", ); Ok(()) } @@ -587,7 +587,7 @@ fn roundtrip_statement_with_dialect_17() -> Result<(), DataFusionError> { sql: "SELECT id FROM (SELECT j1_id as id from j1) AS c", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT c.id FROM (SELECT j1.j1_id AS id FROM j1) AS c"#, + expected: @"SELECT c.id FROM (SELECT j1.j1_id AS id FROM j1) AS c", ); Ok(()) } @@ -599,7 +599,7 @@ fn roundtrip_statement_with_dialect_18() -> Result<(), DataFusionError> { sql: "SELECT id FROM (SELECT j1_id + 1 * 3 from j1) AS c (id)", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT c.id FROM (SELECT (j1.j1_id + (1 * 3)) FROM j1) AS c (id)"#, + expected: @"SELECT c.id FROM (SELECT (j1.j1_id + (1 * 3)) FROM j1) AS c (id)", ); Ok(()) } @@ -611,7 +611,7 @@ fn roundtrip_statement_with_dialect_19() -> Result<(), DataFusionError> { sql: "SELECT id FROM (SELECT distinct (j1_id + 1 * 3) FROM j1 LIMIT 1) AS c (id)", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT c.id FROM (SELECT DISTINCT (j1.j1_id + (1 * 3)) FROM j1 LIMIT 1) AS c (id)"#, + expected: @"SELECT c.id FROM (SELECT DISTINCT (j1.j1_id + (1 * 3)) FROM j1 LIMIT 1) AS c (id)", ); Ok(()) } @@ -622,7 +622,7 @@ fn roundtrip_statement_with_dialect_20() -> Result<(), DataFusionError> { sql: "SELECT id FROM (SELECT j1_id + 1 FROM j1 ORDER BY j1_id DESC LIMIT 1) AS c (id)", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT c.id FROM (SELECT (j1.j1_id + 1) FROM j1 ORDER BY j1.j1_id DESC NULLS FIRST LIMIT 1) AS c (id)"#, + expected: @"SELECT c.id FROM (SELECT (j1.j1_id + 1) FROM j1 ORDER BY j1.j1_id DESC NULLS FIRST LIMIT 1) AS c (id)", ); Ok(()) } @@ -633,7 +633,7 @@ fn roundtrip_statement_with_dialect_21() -> Result<(), DataFusionError> { sql: "SELECT id FROM (SELECT CAST((CAST(j1_id as BIGINT) + 1) as int) * 10 FROM j1 LIMIT 1) AS c (id)", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT c.id FROM (SELECT (CAST((CAST(j1.j1_id AS BIGINT) + 1) AS INTEGER) * 10) FROM j1 LIMIT 1) AS c (id)"#, + expected: @"SELECT c.id FROM (SELECT (CAST((CAST(j1.j1_id AS BIGINT) + 1) AS INTEGER) * 10) FROM j1 LIMIT 1) AS c (id)", ); Ok(()) } @@ -644,7 +644,7 @@ fn roundtrip_statement_with_dialect_22() -> Result<(), DataFusionError> { sql: "SELECT id FROM (SELECT CAST(j1_id as BIGINT) + 1 FROM j1 ORDER BY j1_id LIMIT 1) AS c (id)", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT c.id FROM (SELECT (CAST(j1.j1_id AS BIGINT) + 1) FROM j1 ORDER BY j1.j1_id ASC NULLS LAST LIMIT 1) AS c (id)"#, + expected: @"SELECT c.id FROM (SELECT (CAST(j1.j1_id AS BIGINT) + 1) FROM j1 ORDER BY j1.j1_id ASC NULLS LAST LIMIT 1) AS c (id)", ); Ok(()) } @@ -655,7 +655,7 @@ fn roundtrip_statement_with_dialect_23() -> Result<(), DataFusionError> { sql: "SELECT temp_j.id2 FROM (SELECT j1_id, j1_string FROM j1) AS temp_j(id2, string2)", parser_dialect: GenericDialect {}, unparser_dialect: UnparserDefaultDialect {}, - expected: @r#"SELECT temp_j.id2 FROM (SELECT j1.j1_id, j1.j1_string FROM j1) AS temp_j (id2, string2)"#, + expected: @"SELECT temp_j.id2 FROM (SELECT j1.j1_id, j1.j1_string FROM j1) AS temp_j (id2, string2)", ); Ok(()) } @@ -666,7 +666,7 @@ fn roundtrip_statement_with_dialect_24() -> Result<(), DataFusionError> { sql: "SELECT temp_j.id2 FROM (SELECT j1_id, j1_string FROM j1) AS temp_j(id2, string2)", parser_dialect: GenericDialect {}, unparser_dialect: SqliteDialect {}, - expected: @r#"SELECT `temp_j`.`id2` FROM (SELECT `j1`.`j1_id` AS `id2`, `j1`.`j1_string` AS `string2` FROM `j1`) AS `temp_j`"#, + expected: @"SELECT `temp_j`.`id2` FROM (SELECT `j1`.`j1_id` AS `id2`, `j1`.`j1_string` AS `string2` FROM `j1`) AS `temp_j`", ); Ok(()) } @@ -677,7 +677,7 @@ fn roundtrip_statement_with_dialect_25() -> Result<(), DataFusionError> { sql: "SELECT * FROM (SELECT j1_id + 1 FROM j1) AS temp_j(id2)", parser_dialect: GenericDialect {}, unparser_dialect: SqliteDialect {}, - expected: @r#"SELECT `temp_j`.`id2` FROM (SELECT (`j1`.`j1_id` + 1) AS `id2` FROM `j1`) AS `temp_j`"#, + expected: @"SELECT `temp_j`.`id2` FROM (SELECT (`j1`.`j1_id` + 1) AS `id2` FROM `j1`) AS `temp_j`", ); Ok(()) } @@ -688,7 +688,7 @@ fn roundtrip_statement_with_dialect_26() -> Result<(), DataFusionError> { sql: "SELECT * FROM (SELECT j1_id FROM j1 LIMIT 1) AS temp_j(id2)", parser_dialect: GenericDialect {}, unparser_dialect: SqliteDialect {}, - expected: @r#"SELECT `temp_j`.`id2` FROM (SELECT `j1`.`j1_id` AS `id2` FROM `j1` LIMIT 1) AS `temp_j`"#, + expected: @"SELECT `temp_j`.`id2` FROM (SELECT `j1`.`j1_id` AS `id2` FROM `j1` LIMIT 1) AS `temp_j`", ); Ok(()) } @@ -757,7 +757,7 @@ fn roundtrip_statement_with_dialect_32() -> Result<(), DataFusionError> { sql: "SELECT * FROM UNNEST([1,2,3])", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT UNNEST(make_array(Int64(1),Int64(2),Int64(3))) FROM UNNEST([1, 2, 3])"#, + expected: @"SELECT UNNEST(make_array(Int64(1),Int64(2),Int64(3))) FROM UNNEST([1, 2, 3])", ); Ok(()) } @@ -782,7 +782,7 @@ fn roundtrip_statement_with_dialect_34() -> Result<(), DataFusionError> { sql: "SELECT * FROM UNNEST([1,2,3]) AS t1 (c1)", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT t1.c1 FROM UNNEST([1, 2, 3]) AS t1 (c1)"#, + expected: @"SELECT t1.c1 FROM UNNEST([1, 2, 3]) AS t1 (c1)", ); Ok(()) } @@ -796,7 +796,7 @@ fn roundtrip_statement_with_dialect_35() -> Result<(), DataFusionError> { sql: "SELECT * FROM UNNEST([1,2,3]), j1", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT UNNEST(make_array(Int64(1),Int64(2),Int64(3))), j1.j1_id, j1.j1_string FROM UNNEST([1, 2, 3]) CROSS JOIN j1"#, + expected: @"SELECT UNNEST(make_array(Int64(1),Int64(2),Int64(3))), j1.j1_id, j1.j1_string FROM UNNEST([1, 2, 3]) CROSS JOIN j1", ); Ok(()) } @@ -810,7 +810,7 @@ fn roundtrip_statement_with_dialect_36() -> Result<(), DataFusionError> { sql: "SELECT * FROM UNNEST([1,2,3]) u(c1) JOIN j1 ON u.c1 = j1.j1_id", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT u.c1, j1.j1_id, j1.j1_string FROM UNNEST([1, 2, 3]) AS u (c1) INNER JOIN j1 ON (u.c1 = j1.j1_id)"#, + expected: @"SELECT u.c1, j1.j1_id, j1.j1_string FROM UNNEST([1, 2, 3]) AS u (c1) INNER JOIN j1 ON (u.c1 = j1.j1_id)", ); Ok(()) } @@ -824,7 +824,7 @@ fn roundtrip_statement_with_dialect_37() -> Result<(), DataFusionError> { sql: "SELECT * FROM UNNEST([1,2,3]) u(c1) UNION ALL SELECT * FROM UNNEST([4,5,6]) u(c1)", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT u.c1 FROM UNNEST([1, 2, 3]) AS u (c1) UNION ALL SELECT u.c1 FROM UNNEST([4, 5, 6]) AS u (c1)"#, + expected: @"SELECT u.c1 FROM UNNEST([1, 2, 3]) AS u (c1) UNION ALL SELECT u.c1 FROM UNNEST([4, 5, 6]) AS u (c1)", ); Ok(()) } @@ -838,7 +838,7 @@ fn roundtrip_statement_with_dialect_38() -> Result<(), DataFusionError> { sql: "SELECT UNNEST([1,2,3])", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT * FROM UNNEST([1, 2, 3])"#, + expected: @"SELECT * FROM UNNEST([1, 2, 3])", ); Ok(()) } @@ -852,7 +852,7 @@ fn roundtrip_statement_with_dialect_39() -> Result<(), DataFusionError> { sql: "SELECT UNNEST([1,2,3]) as c1", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT UNNEST([1, 2, 3]) AS c1"#, + expected: @"SELECT UNNEST([1, 2, 3]) AS c1", ); Ok(()) } @@ -866,7 +866,7 @@ fn roundtrip_statement_with_dialect_40() -> Result<(), DataFusionError> { sql: "SELECT UNNEST([1,2,3]), 1", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT UNNEST([1, 2, 3]) AS UNNEST(make_array(Int64(1),Int64(2),Int64(3))), Int64(1)"#, + expected: @"SELECT UNNEST([1, 2, 3]) AS UNNEST(make_array(Int64(1),Int64(2),Int64(3))), Int64(1)", ); Ok(()) } @@ -880,7 +880,7 @@ fn roundtrip_statement_with_dialect_41() -> Result<(), DataFusionError> { sql: "SELECT * FROM unnest_table u, UNNEST(u.array_col)", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT u.array_col, u.struct_col, UNNEST(outer_ref(u.array_col)) FROM unnest_table AS u CROSS JOIN UNNEST(u.array_col)"#, + expected: @"SELECT u.array_col, u.struct_col, UNNEST(outer_ref(u.array_col)) FROM unnest_table AS u CROSS JOIN UNNEST(u.array_col)", ); Ok(()) } @@ -894,7 +894,7 @@ fn roundtrip_statement_with_dialect_42() -> Result<(), DataFusionError> { sql: "SELECT * FROM unnest_table u, UNNEST(u.array_col) AS t1 (c1)", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT u.array_col, u.struct_col, t1.c1 FROM unnest_table AS u CROSS JOIN UNNEST(u.array_col) AS t1 (c1)"#, + expected: @"SELECT u.array_col, u.struct_col, t1.c1 FROM unnest_table AS u CROSS JOIN UNNEST(u.array_col) AS t1 (c1)", ); Ok(()) } @@ -908,7 +908,7 @@ fn roundtrip_statement_with_dialect_43() -> Result<(), DataFusionError> { sql: "SELECT unnest([1, 2, 3, 4]) from unnest([1, 2, 3]);", parser_dialect: GenericDialect {}, unparser_dialect: unparser, - expected: @r#"SELECT UNNEST([1, 2, 3, 4]) AS UNNEST(make_array(Int64(1),Int64(2),Int64(3),Int64(4))) FROM UNNEST([1, 2, 3])"#, + expected: @"SELECT UNNEST([1, 2, 3, 4]) AS UNNEST(make_array(Int64(1),Int64(2),Int64(3),Int64(4))) FROM UNNEST([1, 2, 3])", ); Ok(()) } @@ -930,25 +930,25 @@ fn roundtrip_statement_with_dialect_special_char_alias() -> Result<(), DataFusio sql: "select min(a) as \"min(a)\" from (select 1 as a)", parser_dialect: GenericDialect {}, unparser_dialect: BigQueryDialect {}, - expected: @r#"SELECT min(`a`) AS `min_40a_41` FROM (SELECT 1 AS `a`)"#, + expected: @"SELECT min(`a`) AS `min_40a_41` FROM (SELECT 1 AS `a`)", ); roundtrip_statement_with_dialect_helper!( sql: "select a as \"a*\", b as \"b@\" from (select 1 as a , 2 as b)", parser_dialect: GenericDialect {}, unparser_dialect: BigQueryDialect {}, - expected: @r#"SELECT `a` AS `a_42`, `b` AS `b_64` FROM (SELECT 1 AS `a`, 2 AS `b`)"#, + expected: @"SELECT `a` AS `a_42`, `b` AS `b_64` FROM (SELECT 1 AS `a`, 2 AS `b`)", ); roundtrip_statement_with_dialect_helper!( sql: "select a as \"a*\", b , c as \"c@\" from (select 1 as a , 2 as b, 3 as c)", parser_dialect: GenericDialect {}, unparser_dialect: BigQueryDialect {}, - expected: @r#"SELECT `a` AS `a_42`, `b`, `c` AS `c_64` FROM (SELECT 1 AS `a`, 2 AS `b`, 3 AS `c`)"#, + expected: @"SELECT `a` AS `a_42`, `b`, `c` AS `c_64` FROM (SELECT 1 AS `a`, 2 AS `b`, 3 AS `c`)", ); roundtrip_statement_with_dialect_helper!( sql: "select * from (select a as \"a*\", b as \"b@\" from (select 1 as a , 2 as b)) where \"a*\" = 1", parser_dialect: GenericDialect {}, unparser_dialect: BigQueryDialect {}, - expected: @r#"SELECT `a_42`, `b_64` FROM (SELECT `a` AS `a_42`, `b` AS `b_64` FROM (SELECT 1 AS `a`, 2 AS `b`)) WHERE (`a_42` = 1)"#, + expected: @"SELECT `a_42`, `b_64` FROM (SELECT `a` AS `a_42`, `b` AS `b_64` FROM (SELECT 1 AS `a`, 2 AS `b`)) WHERE (`a_42` = 1)", ); roundtrip_statement_with_dialect_helper!( sql: "select * from (select a as \"a*\", b as \"b@\" from (select 1 as a , 2 as b)) where \"a*\" = 1", @@ -975,11 +975,12 @@ fn test_unnest_logical_plan() -> Result<()> { let plan = sql_to_rel.sql_statement_to_plan(statement).unwrap(); assert_snapshot!( plan, - @r#" -Projection: __unnest_placeholder(unnest_table.struct_col).field1, __unnest_placeholder(unnest_table.struct_col).field2, __unnest_placeholder(unnest_table.array_col,depth=1) AS UNNEST(unnest_table.array_col), unnest_table.struct_col, unnest_table.array_col - Unnest: lists[__unnest_placeholder(unnest_table.array_col)|depth=1] structs[__unnest_placeholder(unnest_table.struct_col)] - Projection: unnest_table.struct_col AS __unnest_placeholder(unnest_table.struct_col), unnest_table.array_col AS __unnest_placeholder(unnest_table.array_col), unnest_table.struct_col, unnest_table.array_col - TableScan: unnest_table"# + @r" + Projection: __unnest_placeholder(unnest_table.struct_col).field1, __unnest_placeholder(unnest_table.struct_col).field2, __unnest_placeholder(unnest_table.array_col,depth=1) AS UNNEST(unnest_table.array_col), unnest_table.struct_col, unnest_table.array_col + Unnest: lists[__unnest_placeholder(unnest_table.array_col)|depth=1] structs[__unnest_placeholder(unnest_table.struct_col)] + Projection: unnest_table.struct_col AS __unnest_placeholder(unnest_table.struct_col), unnest_table.array_col AS __unnest_placeholder(unnest_table.array_col), unnest_table.struct_col, unnest_table.array_col + TableScan: unnest_table + " ); Ok(()) @@ -1386,7 +1387,7 @@ fn test_table_scan_alias() -> Result<()> { let sql = plan_to_sql(&plan)?; assert_snapshot!( sql, - @r#"SELECT * FROM (SELECT t1.id FROM t1 WHERE (t1.id > 5)) AS a"# + @"SELECT * FROM (SELECT t1.id FROM t1 WHERE (t1.id > 5)) AS a" ); let table_scan_with_two_filter = table_scan_with_filters( @@ -1401,7 +1402,7 @@ fn test_table_scan_alias() -> Result<()> { let table_scan_with_two_filter = plan_to_sql(&table_scan_with_two_filter)?; assert_snapshot!( table_scan_with_two_filter, - @r#"SELECT a.id FROM t1 AS a WHERE ((a.id > 1) AND (a.age < 2))"# + @"SELECT a.id FROM t1 AS a WHERE ((a.id > 1) AND (a.age < 2))" ); let table_scan_with_fetch = @@ -1412,7 +1413,7 @@ fn test_table_scan_alias() -> Result<()> { let table_scan_with_fetch = plan_to_sql(&table_scan_with_fetch)?; assert_snapshot!( table_scan_with_fetch, - @r#"SELECT a.id FROM (SELECT * FROM t1 LIMIT 10) AS a"# + @"SELECT a.id FROM (SELECT * FROM t1 LIMIT 10) AS a" ); let table_scan_with_pushdown_all = table_scan_with_filter_and_fetch( @@ -1428,7 +1429,7 @@ fn test_table_scan_alias() -> Result<()> { let table_scan_with_pushdown_all = plan_to_sql(&table_scan_with_pushdown_all)?; assert_snapshot!( table_scan_with_pushdown_all, - @r#"SELECT a.id FROM (SELECT a.id, a.age FROM t1 AS a WHERE (a.id > 1) LIMIT 10) AS a"# + @"SELECT a.id FROM (SELECT a.id, a.age FROM t1 AS a WHERE (a.id > 1) LIMIT 10) AS a" ); Ok(()) } @@ -1444,21 +1445,21 @@ fn test_table_scan_pushdown() -> Result<()> { let scan_with_projection = plan_to_sql(&scan_with_projection)?; assert_snapshot!( scan_with_projection, - @r#"SELECT t1.id, t1.age FROM t1"# + @"SELECT t1.id, t1.age FROM t1" ); let scan_with_projection = table_scan(Some("t1"), &schema, Some(vec![1]))?.build()?; let scan_with_projection = plan_to_sql(&scan_with_projection)?; assert_snapshot!( scan_with_projection, - @r#"SELECT t1.age FROM t1"# + @"SELECT t1.age FROM t1" ); let scan_with_no_projection = table_scan(Some("t1"), &schema, None)?.build()?; let scan_with_no_projection = plan_to_sql(&scan_with_no_projection)?; assert_snapshot!( scan_with_no_projection, - @r#"SELECT * FROM t1"# + @"SELECT * FROM t1" ); let table_scan_with_projection_alias = @@ -1469,7 +1470,7 @@ fn test_table_scan_pushdown() -> Result<()> { plan_to_sql(&table_scan_with_projection_alias)?; assert_snapshot!( table_scan_with_projection_alias, - @r#"SELECT ta.id, ta.age FROM t1 AS ta"# + @"SELECT ta.id, ta.age FROM t1 AS ta" ); let table_scan_with_projection_alias = @@ -1480,7 +1481,7 @@ fn test_table_scan_pushdown() -> Result<()> { plan_to_sql(&table_scan_with_projection_alias)?; assert_snapshot!( table_scan_with_projection_alias, - @r#"SELECT ta.age FROM t1 AS ta"# + @"SELECT ta.age FROM t1 AS ta" ); let table_scan_with_no_projection_alias = table_scan(Some("t1"), &schema, None)? @@ -1490,7 +1491,7 @@ fn test_table_scan_pushdown() -> Result<()> { plan_to_sql(&table_scan_with_no_projection_alias)?; assert_snapshot!( table_scan_with_no_projection_alias, - @r#"SELECT * FROM t1 AS ta"# + @"SELECT * FROM t1 AS ta" ); let query_from_table_scan_with_projection = LogicalPlanBuilder::from( @@ -1502,7 +1503,7 @@ fn test_table_scan_pushdown() -> Result<()> { plan_to_sql(&query_from_table_scan_with_projection)?; assert_snapshot!( query_from_table_scan_with_projection, - @r#"SELECT t1.id, t1.age FROM t1"# + @"SELECT t1.id, t1.age FROM t1" ); let query_from_table_scan_with_two_projections = LogicalPlanBuilder::from( @@ -1515,7 +1516,7 @@ fn test_table_scan_pushdown() -> Result<()> { plan_to_sql(&query_from_table_scan_with_two_projections)?; assert_snapshot!( query_from_table_scan_with_two_projections, - @r#"SELECT t1.id, t1.age FROM (SELECT t1.id, t1.age FROM t1)"# + @"SELECT t1.id, t1.age FROM (SELECT t1.id, t1.age FROM t1)" ); let table_scan_with_filter = table_scan_with_filters( @@ -1528,7 +1529,7 @@ fn test_table_scan_pushdown() -> Result<()> { let table_scan_with_filter = plan_to_sql(&table_scan_with_filter)?; assert_snapshot!( table_scan_with_filter, - @r#"SELECT * FROM t1 WHERE (t1.id > t1.age)"# + @"SELECT * FROM t1 WHERE (t1.id > t1.age)" ); let table_scan_with_two_filter = table_scan_with_filters( @@ -1541,7 +1542,7 @@ fn test_table_scan_pushdown() -> Result<()> { let table_scan_with_two_filter = plan_to_sql(&table_scan_with_two_filter)?; assert_snapshot!( table_scan_with_two_filter, - @r#"SELECT * FROM t1 WHERE ((t1.id > 1) AND (t1.age < 2))"# + @"SELECT * FROM t1 WHERE ((t1.id > 1) AND (t1.age < 2))" ); let table_scan_with_filter_alias = table_scan_with_filters( @@ -1555,7 +1556,7 @@ fn test_table_scan_pushdown() -> Result<()> { let table_scan_with_filter_alias = plan_to_sql(&table_scan_with_filter_alias)?; assert_snapshot!( table_scan_with_filter_alias, - @r#"SELECT * FROM t1 AS ta WHERE (ta.id > ta.age)"# + @"SELECT * FROM t1 AS ta WHERE (ta.id > ta.age)" ); let table_scan_with_projection_and_filter = table_scan_with_filters( @@ -1569,7 +1570,7 @@ fn test_table_scan_pushdown() -> Result<()> { plan_to_sql(&table_scan_with_projection_and_filter)?; assert_snapshot!( table_scan_with_projection_and_filter, - @r#"SELECT t1.id, t1.age FROM t1 WHERE (t1.id > t1.age)"# + @"SELECT t1.id, t1.age FROM t1 WHERE (t1.id > t1.age)" ); let table_scan_with_projection_and_filter = table_scan_with_filters( @@ -1583,7 +1584,7 @@ fn test_table_scan_pushdown() -> Result<()> { plan_to_sql(&table_scan_with_projection_and_filter)?; assert_snapshot!( table_scan_with_projection_and_filter, - @r#"SELECT t1.age FROM t1 WHERE (t1.id > t1.age)"# + @"SELECT t1.age FROM t1 WHERE (t1.id > t1.age)" ); let table_scan_with_inline_fetch = @@ -1592,7 +1593,7 @@ fn test_table_scan_pushdown() -> Result<()> { let table_scan_with_inline_fetch = plan_to_sql(&table_scan_with_inline_fetch)?; assert_snapshot!( table_scan_with_inline_fetch, - @r#"SELECT * FROM t1 LIMIT 10"# + @"SELECT * FROM t1 LIMIT 10" ); let table_scan_with_projection_and_inline_fetch = table_scan_with_filter_and_fetch( @@ -1607,7 +1608,7 @@ fn test_table_scan_pushdown() -> Result<()> { plan_to_sql(&table_scan_with_projection_and_inline_fetch)?; assert_snapshot!( table_scan_with_projection_and_inline_fetch, - @r#"SELECT t1.id, t1.age FROM t1 LIMIT 10"# + @"SELECT t1.id, t1.age FROM t1 LIMIT 10" ); let table_scan_with_all = table_scan_with_filter_and_fetch( @@ -1621,7 +1622,7 @@ fn test_table_scan_pushdown() -> Result<()> { let table_scan_with_all = plan_to_sql(&table_scan_with_all)?; assert_snapshot!( table_scan_with_all, - @r#"SELECT t1.id, t1.age FROM t1 WHERE (t1.id > t1.age) LIMIT 10"# + @"SELECT t1.id, t1.age FROM t1 WHERE (t1.id > t1.age) LIMIT 10" ); let table_scan_with_additional_filter = table_scan_with_filters( @@ -1635,7 +1636,7 @@ fn test_table_scan_pushdown() -> Result<()> { let table_scan_with_filter = plan_to_sql(&table_scan_with_additional_filter)?; assert_snapshot!( table_scan_with_filter, - @r#"SELECT * FROM t1 WHERE (t1.id = 5) AND (t1.id > t1.age)"# + @"SELECT * FROM t1 WHERE (t1.id = 5) AND (t1.id > t1.age)" ); Ok(()) @@ -1656,7 +1657,7 @@ fn test_sort_with_push_down_fetch() -> Result<()> { let sql = plan_to_sql(&plan)?; assert_snapshot!( sql, - @r#"SELECT t1.id, t1.age FROM t1 ORDER BY t1.age ASC NULLS FIRST LIMIT 10"# + @"SELECT t1.id, t1.age FROM t1 ORDER BY t1.age ASC NULLS FIRST LIMIT 10" ); Ok(()) } @@ -1786,7 +1787,7 @@ fn test_interval_lhs_eq() { ); assert_snapshot!( statement, - @r#"SELECT (INTERVAL '2.000000000 SECS' = INTERVAL '2.000000000 SECS')"# + @"SELECT (INTERVAL '2.000000000 SECS' = INTERVAL '2.000000000 SECS')" ) } @@ -1798,7 +1799,7 @@ fn test_interval_lhs_lt() { ); assert_snapshot!( statement, - @r#"SELECT (INTERVAL '2.000000000 SECS' < INTERVAL '2.000000000 SECS')"# + @"SELECT (INTERVAL '2.000000000 SECS' < INTERVAL '2.000000000 SECS')" ) } @@ -1807,7 +1808,7 @@ fn test_without_offset() { let statement = generate_round_trip_statement(MySqlDialect {}, "select 1"); assert_snapshot!( statement, - @r#"SELECT 1"# + @"SELECT 1" ) } @@ -1816,7 +1817,7 @@ fn test_with_offset0() { let statement = generate_round_trip_statement(MySqlDialect {}, "select 1 offset 0"); assert_snapshot!( statement, - @r#"SELECT 1 OFFSET 0"# + @"SELECT 1 OFFSET 0" ) } @@ -1825,7 +1826,7 @@ fn test_with_offset95() { let statement = generate_round_trip_statement(MySqlDialect {}, "select 1 offset 95"); assert_snapshot!( statement, - @r#"SELECT 1 OFFSET 95"# + @"SELECT 1 OFFSET 95" ) } @@ -1838,7 +1839,7 @@ fn test_order_by_to_sql_1() { ); assert_snapshot!( statement, - @r#"SELECT person.id, person.first_name, sum(person.id) FROM person GROUP BY person.id, person.first_name ORDER BY sum(person.id) ASC NULLS LAST, person.first_name DESC NULLS FIRST, person.id ASC NULLS LAST, person.first_name ASC NULLS LAST LIMIT 10"# + @"SELECT person.id, person.first_name, sum(person.id) FROM person GROUP BY person.id, person.first_name ORDER BY sum(person.id) ASC NULLS LAST, person.first_name DESC NULLS FIRST, person.id ASC NULLS LAST, person.first_name ASC NULLS LAST LIMIT 10" ); } @@ -1851,7 +1852,7 @@ fn test_order_by_to_sql_2() { ); assert_snapshot!( statement, - @r#"SELECT person.id, person.first_name, sum(person.id) AS total_sum FROM person GROUP BY person.id, person.first_name ORDER BY total_sum ASC NULLS LAST, person.first_name DESC NULLS FIRST, person.id ASC NULLS LAST, person.first_name ASC NULLS LAST LIMIT 10"# + @"SELECT person.id, person.first_name, sum(person.id) AS total_sum FROM person GROUP BY person.id, person.first_name ORDER BY total_sum ASC NULLS LAST, person.first_name DESC NULLS FIRST, person.id ASC NULLS LAST, person.first_name ASC NULLS LAST LIMIT 10" ); } @@ -1863,7 +1864,7 @@ fn test_order_by_to_sql_3() { ); assert_snapshot!( statement, - @r#"SELECT person.id, person.first_name, substr(person.first_name, 0, 5) FROM person ORDER BY person.id ASC NULLS LAST, substr(person.first_name, 0, 5) ASC NULLS LAST"# + @"SELECT person.id, person.first_name, substr(person.first_name, 0, 5) FROM person ORDER BY person.id ASC NULLS LAST, substr(person.first_name, 0, 5) ASC NULLS LAST" ); } @@ -1905,7 +1906,7 @@ fn test_complex_order_by_with_grouping() -> Result<()> { }, { assert_snapshot!( sql, - @r#"SELECT j1.j1_id, j1.j1_string, lochierarchy FROM (SELECT j1.j1_id, j1.j1_string, (grouping(j1.j1_id) + grouping(j1.j1_string)) AS lochierarchy, grouping(j1.j1_string), grouping(j1.j1_id) FROM j1 GROUP BY ROLLUP (j1.j1_id, j1.j1_string) ORDER BY lochierarchy DESC NULLS FIRST, CASE WHEN ((grouping(j1.j1_id) + grouping(j1.j1_string)) = 0) THEN j1.j1_id END ASC NULLS LAST) LIMIT 100"# + @"SELECT j1.j1_id, j1.j1_string, lochierarchy FROM (SELECT j1.j1_id, j1.j1_string, (grouping(j1.j1_id) + grouping(j1.j1_string)) AS lochierarchy, grouping(j1.j1_string), grouping(j1.j1_id) FROM j1 GROUP BY ROLLUP (j1.j1_id, j1.j1_string) ORDER BY lochierarchy DESC NULLS FIRST, CASE WHEN ((grouping(j1.j1_id) + grouping(j1.j1_string)) = 0) THEN j1.j1_id END ASC NULLS LAST) LIMIT 100" ); }); @@ -1938,7 +1939,7 @@ fn test_unnest_to_sql_1() { ); assert_snapshot!( statement, - @r#"SELECT UNNEST(unnest_table.array_col) AS u1, unnest_table.struct_col, unnest_table.array_col FROM unnest_table WHERE (unnest_table.array_col <> NULL) ORDER BY unnest_table.struct_col ASC NULLS LAST, unnest_table.array_col ASC NULLS LAST"# + @"SELECT UNNEST(unnest_table.array_col) AS u1, unnest_table.struct_col, unnest_table.array_col FROM unnest_table WHERE (unnest_table.array_col <> NULL) ORDER BY unnest_table.struct_col ASC NULLS LAST, unnest_table.array_col ASC NULLS LAST" ); } @@ -1950,7 +1951,7 @@ fn test_unnest_to_sql_2() { ); assert_snapshot!( statement, - @r#"SELECT UNNEST([1, 2, 2, 5, NULL]) AS u1"# + @"SELECT UNNEST([1, 2, 2, 5, NULL]) AS u1" ); } @@ -1962,7 +1963,7 @@ fn test_join_with_no_conditions() { ); assert_snapshot!( statement, - @r#"SELECT j1.j1_id, j1.j1_string FROM j1 CROSS JOIN j2"# + @"SELECT j1.j1_id, j1.j1_string FROM j1 CROSS JOIN j2" ); } @@ -2065,7 +2066,7 @@ fn test_unparse_extension_to_statement() -> Result<()> { let sql = unparser.plan_to_sql(&extension)?; assert_snapshot!( sql, - @r#"SELECT j1.j1_id, j1.j1_string FROM j1"# + @"SELECT j1.j1_id, j1.j1_string FROM j1" ); if let Some(err) = plan_to_sql(&extension).err() { @@ -2131,7 +2132,7 @@ fn test_unparse_extension_to_sql() -> Result<()> { let sql = unparser.plan_to_sql(&plan)?; assert_snapshot!( sql, - @r#"SELECT j1.j1_id AS user_id FROM (SELECT j1.j1_id, j1.j1_string FROM j1)"# + @"SELECT j1.j1_id AS user_id FROM (SELECT j1.j1_id, j1.j1_string FROM j1)" ); if let Some(err) = plan_to_sql(&plan).err() { @@ -2172,7 +2173,7 @@ fn test_unparse_optimized_multi_union() -> Result<()> { }); assert_snapshot!( unparser.plan_to_sql(&plan)?, - @r#"SELECT 1 AS x, 'a' AS y UNION ALL SELECT 1 AS x, 'b' AS y UNION ALL SELECT 2 AS x, 'a' AS y UNION ALL SELECT 2 AS x, 'c' AS y"# + @"SELECT 1 AS x, 'a' AS y UNION ALL SELECT 1 AS x, 'b' AS y UNION ALL SELECT 2 AS x, 'a' AS y UNION ALL SELECT 2 AS x, 'c' AS y" ); let plan = LogicalPlan::Union(Union { @@ -2251,7 +2252,7 @@ fn test_unparse_subquery_alias_with_table_pushdown() -> Result<()> { let sql = unparser.plan_to_sql(&plan)?; assert_snapshot!( sql, - @r#"SELECT customer_view.c_custkey, customer_view.c_name, customer_view.custkey_plus FROM (SELECT customer.c_custkey, (CAST(customer.c_custkey AS BIGINT) + 1) AS custkey_plus, customer.c_name FROM (SELECT customer.c_custkey, customer.c_name FROM customer AS customer) AS customer) AS customer_view"# + @"SELECT customer_view.c_custkey, customer_view.c_name, customer_view.custkey_plus FROM (SELECT customer.c_custkey, (CAST(customer.c_custkey AS BIGINT) + 1) AS custkey_plus, customer.c_name FROM (SELECT customer.c_custkey, customer.c_name FROM customer AS customer) AS customer) AS customer_view" ); Ok(()) } @@ -2562,21 +2563,21 @@ fn test_unparse_window() -> Result<()> { let sql = unparser.plan_to_sql(&plan)?; assert_snapshot!( sql, - @r#"SELECT `test`.`k`, `test`.`v`, `rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` FROM (SELECT `test`.`k` AS `k`, `test`.`v` AS `v`, rank() OVER (PARTITION BY `test`.`k` ORDER BY `test`.`v` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS `rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` FROM `test`) AS `test` WHERE (`rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` = 1)"# + @"SELECT `test`.`k`, `test`.`v`, `rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` FROM (SELECT `test`.`k` AS `k`, `test`.`v` AS `v`, rank() OVER (PARTITION BY `test`.`k` ORDER BY `test`.`v` ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS `rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` FROM `test`) AS `test` WHERE (`rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` = 1)" ); let unparser = Unparser::new(&SqliteDialect {}); let sql = unparser.plan_to_sql(&plan)?; assert_snapshot!( sql, - @r#"SELECT `test`.`k`, `test`.`v`, `rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` FROM (SELECT `test`.`k` AS `k`, `test`.`v` AS `v`, rank() OVER (PARTITION BY `test`.`k` ORDER BY `test`.`v` ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS `rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` FROM `test`) AS `test` WHERE (`rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` = 1)"# + @"SELECT `test`.`k`, `test`.`v`, `rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` FROM (SELECT `test`.`k` AS `k`, `test`.`v` AS `v`, rank() OVER (PARTITION BY `test`.`k` ORDER BY `test`.`v` ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS `rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` FROM `test`) AS `test` WHERE (`rank() PARTITION BY [test.k] ORDER BY [test.v ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING` = 1)" ); let unparser = Unparser::new(&DefaultDialect {}); let sql = unparser.plan_to_sql(&plan)?; assert_snapshot!( sql, - @r#"SELECT test.k, test.v, rank() OVER (PARTITION BY test.k ORDER BY test.v ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM test QUALIFY (rank() OVER (PARTITION BY test.k ORDER BY test.v ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) = 1)"# + @"SELECT test.k, test.v, rank() OVER (PARTITION BY test.k ORDER BY test.v ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM test QUALIFY (rank() OVER (PARTITION BY test.k ORDER BY test.v ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) = 1)" ); // without table qualifier diff --git a/datafusion/sql/tests/sql_integration.rs b/datafusion/sql/tests/sql_integration.rs index c19049df3ef8d..5ca1d770b77bb 100644 --- a/datafusion/sql/tests/sql_integration.rs +++ b/datafusion/sql/tests/sql_integration.rs @@ -218,10 +218,10 @@ fn parse_ident_normalization_3() { let plan = logical_plan_with_options(sql, parser_option).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.age - TableScan: person - "# + @r" + Projection: person.age + TableScan: person + " ); } @@ -232,10 +232,10 @@ fn parse_ident_normalization_4() { let plan = logical_plan_with_options(sql, parser_option).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.age - TableScan: person - "# + @r" + Projection: person.age + TableScan: person + " ); } @@ -264,9 +264,7 @@ fn parse_ident_normalization_5() { .strip_backtrace(); assert_snapshot!( plan, - @r#" - Error during planning: No table named: PERSON found - "# + @"Error during planning: No table named: PERSON found" ); } @@ -277,10 +275,10 @@ fn parse_ident_normalization_6() { let plan = logical_plan_with_options(sql, parser_option).unwrap(); assert_snapshot!( plan, - @r#" - Projection: UPPERCASE_test.Id - TableScan: UPPERCASE_test - "# + @r" + Projection: UPPERCASE_test.Id + TableScan: UPPERCASE_test + " ); } @@ -291,10 +289,10 @@ fn parse_ident_normalization_7() { let plan = logical_plan_with_options(sql, parser_option).unwrap(); assert_snapshot!( plan, - @r#" - Projection: UPPERCASE_test.Id, UPPERCASE_test.lower - TableScan: UPPERCASE_test - "# + @r" + Projection: UPPERCASE_test.Id, UPPERCASE_test.lower + TableScan: UPPERCASE_test + " ); } @@ -376,11 +374,11 @@ fn try_cast_from_aggregation() { let plan = logical_plan("SELECT TRY_CAST(sum(age) AS FLOAT) FROM person").unwrap(); assert_snapshot!( plan, - @r#" - Projection: TRY_CAST(sum(person.age) AS Float32) - Aggregate: groupBy=[[]], aggr=[[sum(person.age)]] - TableScan: person - "# + @r" + Projection: TRY_CAST(sum(person.age) AS Float32) + Aggregate: groupBy=[[]], aggr=[[sum(person.age)]] + TableScan: person + " ); } @@ -392,7 +390,7 @@ fn cast_to_invalid_decimal_type_precision_0() { assert_snapshot!( err.strip_backtrace(), - @r"Error during planning: Decimal(precision = 0, scale = 0) should satisfy `0 < precision <= 76`, and `scale <= precision`." + @"Error during planning: Decimal(precision = 0, scale = 0) should satisfy `0 < precision <= 76`, and `scale <= precision`." ); } @@ -418,7 +416,7 @@ fn cast_to_invalid_decimal_type_precision_gt_76() { assert_snapshot!( err.strip_backtrace(), - @r"Error during planning: Decimal(precision = 79, scale = 0) should satisfy `0 < precision <= 76`, and `scale <= precision`." + @"Error during planning: Decimal(precision = 79, scale = 0) should satisfy `0 < precision <= 76`, and `scale <= precision`." ); } @@ -430,7 +428,7 @@ fn cast_to_invalid_decimal_type_precision_lt_scale() { assert_snapshot!( err.strip_backtrace(), - @r"Error during planning: Decimal(precision = 5, scale = 10) should satisfy `0 < precision <= 76`, and `scale <= precision`." + @"Error during planning: Decimal(precision = 5, scale = 10) should satisfy `0 < precision <= 76`, and `scale <= precision`." ); } @@ -536,9 +534,7 @@ fn plan_start_transaction() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - TransactionStart: ReadWrite Serializable - "# + @"TransactionStart: ReadWrite Serializable" ); } @@ -548,9 +544,7 @@ fn plan_start_transaction_isolation() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - TransactionStart: ReadWrite ReadCommitted - "# + @"TransactionStart: ReadWrite ReadCommitted" ); } @@ -560,9 +554,7 @@ fn plan_start_transaction_read_only() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - TransactionStart: ReadOnly Serializable - "# + @"TransactionStart: ReadOnly Serializable" ); } @@ -572,9 +564,7 @@ fn plan_start_transaction_fully_qualified() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - TransactionStart: ReadOnly ReadCommitted - "# + @"TransactionStart: ReadOnly ReadCommitted" ); } @@ -588,9 +578,7 @@ isolation level repeatable read let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - TransactionStart: ReadOnly RepeatableRead - "# + @"TransactionStart: ReadOnly RepeatableRead" ); } @@ -600,9 +588,7 @@ fn plan_commit_transaction() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - TransactionEnd: Commit chain:=false - "# + @"TransactionEnd: Commit chain:=false" ); } @@ -612,9 +598,7 @@ fn plan_commit_transaction_chained() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - TransactionEnd: Commit chain:=true - "# + @"TransactionEnd: Commit chain:=true" ); } @@ -624,9 +608,7 @@ fn plan_rollback_transaction() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - TransactionEnd: Rollback chain:=false - "# + @"TransactionEnd: Rollback chain:=false" ); } @@ -636,9 +618,7 @@ fn plan_rollback_transaction_chained() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - TransactionEnd: Rollback chain:=true - "# + @"TransactionEnd: Rollback chain:=true" ); } @@ -648,10 +628,10 @@ fn plan_copy_to() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - CopyTo: format=csv output_url=output.csv options: () - TableScan: test_decimal - "# + @r" + CopyTo: format=csv output_url=output.csv options: () + TableScan: test_decimal + " ); } @@ -661,11 +641,11 @@ fn plan_explain_copy_to() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Explain - CopyTo: format=csv output_url=output.csv options: () - TableScan: test_decimal - "# + @r" + Explain + CopyTo: format=csv output_url=output.csv options: () + TableScan: test_decimal + " ); } @@ -675,11 +655,11 @@ fn plan_explain_copy_to_format() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Explain - CopyTo: format=csv output_url=output.tbl options: () - TableScan: test_decimal - "# + @r" + Explain + CopyTo: format=csv output_url=output.tbl options: () + TableScan: test_decimal + " ); } @@ -704,11 +684,11 @@ fn plan_insert_no_target_columns() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Dml: op=[Insert Into] table=[test_decimal] - Projection: column1 AS id, column2 AS price - Values: (CAST(Int64(1) AS Int32), CAST(Int64(2) AS Decimal128(10, 2))), (CAST(Int64(3) AS Int32), CAST(Int64(4) AS Decimal128(10, 2))) - "# + @r" + Dml: op=[Insert Into] table=[test_decimal] + Projection: column1 AS id, column2 AS price + Values: (CAST(Int64(1) AS Int32), CAST(Int64(2) AS Decimal128(10, 2))), (CAST(Int64(3) AS Int32), CAST(Int64(4) AS Decimal128(10, 2))) + " ); } @@ -751,11 +731,11 @@ fn plan_update() { assert_snapshot!( plan, @r#" - Dml: op=[Update] table=[person] - Projection: person.id AS id, person.first_name AS first_name, Utf8("Kay") AS last_name, person.age AS age, person.state AS state, person.salary AS salary, person.birth_date AS birth_date, person.😀 AS 😀 - Filter: person.id = Int64(1) - TableScan: person - "# + Dml: op=[Update] table=[person] + Projection: person.id AS id, person.first_name AS first_name, Utf8("Kay") AS last_name, person.age AS age, person.state AS state, person.salary AS salary, person.birth_date AS birth_date, person.😀 AS 😀 + Filter: person.id = Int64(1) + TableScan: person + "# ); } @@ -777,11 +757,11 @@ fn plan_delete() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Dml: op=[Delete] table=[person] - Filter: person.id = Int64(1) - TableScan: person - "# + @r" + Dml: op=[Delete] table=[person] + Filter: person.id = Int64(1) + TableScan: person + " ); } @@ -792,11 +772,11 @@ fn plan_delete_quoted_identifier_case_sensitive() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Dml: op=[Delete] table=[SomeCatalog.SomeSchema.UPPERCASE_test] - Filter: SomeCatalog.SomeSchema.UPPERCASE_test.Id = Int64(1) - TableScan: SomeCatalog.SomeSchema.UPPERCASE_test - "# + @r" + Dml: op=[Delete] table=[SomeCatalog.SomeSchema.UPPERCASE_test] + Filter: SomeCatalog.SomeSchema.UPPERCASE_test.Id = Int64(1) + TableScan: SomeCatalog.SomeSchema.UPPERCASE_test + " ); } @@ -814,9 +794,7 @@ fn select_repeated_column() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Projections require unique expression names but the expression "person.age" at position 0 and "person.age" at position 1 have the same name. Consider aliasing ("AS") one of them. - "# + @r#"Error during planning: Projections require unique expression names but the expression "person.age" at position 0 and "person.age" at position 1 have the same name. Consider aliasing ("AS") one of them."# ); } @@ -840,10 +818,10 @@ fn select_simple_filter() { assert_snapshot!( plan, @r#" - Projection: person.id, person.first_name, person.last_name - Filter: person.state = Utf8("CO") - TableScan: person - "# + Projection: person.id, person.first_name, person.last_name + Filter: person.state = Utf8("CO") + TableScan: person + "# ); } @@ -868,11 +846,11 @@ fn select_neg_filter() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.id, person.first_name, person.last_name - Filter: NOT person.state - TableScan: person - "# + @r" + Projection: person.id, person.first_name, person.last_name + Filter: NOT person.state + TableScan: person + " ); } @@ -884,10 +862,10 @@ fn select_compound_filter() { assert_snapshot!( plan, @r#" - Projection: person.id, person.first_name, person.last_name - Filter: person.state = Utf8("CO") AND person.age >= Int64(21) AND person.age <= Int64(65) - TableScan: person - "# + Projection: person.id, person.first_name, person.last_name + Filter: person.state = Utf8("CO") AND person.age >= Int64(21) AND person.age <= Int64(65) + TableScan: person + "# ); } @@ -912,10 +890,10 @@ fn test_date_filter() { assert_snapshot!( plan, @r#" - Projection: person.state - Filter: person.birth_date < CAST(Utf8("2020-01-01") AS Date32) - TableScan: person - "# + Projection: person.state + Filter: person.birth_date < CAST(Utf8("2020-01-01") AS Date32) + TableScan: person + "# ); } @@ -932,11 +910,11 @@ fn select_all_boolean_operators() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.age, person.first_name, person.last_name - Filter: person.age = Int64(21) AND person.age != Int64(21) AND person.age > Int64(21) AND person.age >= Int64(21) AND person.age < Int64(65) AND person.age <= Int64(65) - TableScan: person - "# + @r" + Projection: person.age, person.first_name, person.last_name + Filter: person.age = Int64(21) AND person.age != Int64(21) AND person.age > Int64(21) AND person.age >= Int64(21) AND person.age < Int64(65) AND person.age <= Int64(65) + TableScan: person + " ); } @@ -946,11 +924,11 @@ fn select_between() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.state - Filter: person.age BETWEEN Int64(21) AND Int64(65) - TableScan: person - "# + @r" + Projection: person.state + Filter: person.age BETWEEN Int64(21) AND Int64(65) + TableScan: person + " ); } @@ -960,11 +938,11 @@ fn select_between_negated() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.state - Filter: person.age NOT BETWEEN Int64(21) AND Int64(65) - TableScan: person - "# + @r" + Projection: person.state + Filter: person.age NOT BETWEEN Int64(21) AND Int64(65) + TableScan: person + " ); } @@ -981,14 +959,14 @@ fn select_nested() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: b.fn2, b.last_name - SubqueryAlias: b - Projection: a.fn1 AS fn2, a.last_name, a.birth_date - SubqueryAlias: a - Projection: person.first_name AS fn1, person.last_name, person.birth_date, person.age - TableScan: person - "# + @r" + Projection: b.fn2, b.last_name + SubqueryAlias: b + Projection: a.fn1 AS fn2, a.last_name, a.birth_date + SubqueryAlias: a + Projection: person.first_name AS fn1, person.last_name, person.birth_date, person.age + TableScan: person + " ); } @@ -1005,13 +983,13 @@ fn select_nested_with_filters() { assert_snapshot!( plan, @r#" - Projection: a.fn1, a.age - Filter: a.fn1 = Utf8("X") AND a.age < Int64(30) - SubqueryAlias: a - Projection: person.first_name AS fn1, person.age - Filter: person.age > Int64(20) - TableScan: person - "# + Projection: a.fn1, a.age + Filter: a.fn1 = Utf8("X") AND a.age < Int64(30) + SubqueryAlias: a + Projection: person.first_name AS fn1, person.age + Filter: person.age > Int64(20) + TableScan: person + "# ); } @@ -1022,12 +1000,12 @@ fn table_with_column_alias() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: l.a, l.b, l.c - SubqueryAlias: l - Projection: lineitem.l_item_id AS a, lineitem.l_description AS b, lineitem.price AS c - TableScan: lineitem - "# + @r" + Projection: l.a, l.b, l.c + SubqueryAlias: l + Projection: lineitem.l_item_id AS a, lineitem.l_description AS b, lineitem.price AS c + TableScan: lineitem + " ); } @@ -1039,7 +1017,7 @@ fn table_with_column_alias_number_cols() { assert_snapshot!( err.strip_backtrace(), - @r"Error during planning: Source table contains 3 columns but only 2 names given as column alias" + @"Error during planning: Source table contains 3 columns but only 2 names given as column alias" ); } @@ -1050,7 +1028,7 @@ fn select_with_ambiguous_column() { assert_snapshot!( err.strip_backtrace(), - @r"Schema error: Ambiguous reference to unqualified field id" + @"Schema error: Ambiguous reference to unqualified field id" ); } @@ -1061,14 +1039,14 @@ fn join_with_ambiguous_column() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: a.id - Inner Join: Using a.id = b.id - SubqueryAlias: a - TableScan: person - SubqueryAlias: b - TableScan: person - "# + @r" + Projection: a.id + Inner Join: Using a.id = b.id + SubqueryAlias: a + TableScan: person + SubqueryAlias: b + TableScan: person + " ); } @@ -1078,14 +1056,14 @@ fn natural_left_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: a.l_item_id - Left Join: Using a.l_item_id = b.l_item_id, a.l_description = b.l_description, a.price = b.price - SubqueryAlias: a - TableScan: lineitem - SubqueryAlias: b - TableScan: lineitem - "# + @r" + Projection: a.l_item_id + Left Join: Using a.l_item_id = b.l_item_id, a.l_description = b.l_description, a.price = b.price + SubqueryAlias: a + TableScan: lineitem + SubqueryAlias: b + TableScan: lineitem + " ); } @@ -1095,14 +1073,14 @@ fn natural_right_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: a.l_item_id - Right Join: Using a.l_item_id = b.l_item_id, a.l_description = b.l_description, a.price = b.price - SubqueryAlias: a - TableScan: lineitem - SubqueryAlias: b - TableScan: lineitem - "# + @r" + Projection: a.l_item_id + Right Join: Using a.l_item_id = b.l_item_id, a.l_description = b.l_description, a.price = b.price + SubqueryAlias: a + TableScan: lineitem + SubqueryAlias: b + TableScan: lineitem + " ); } @@ -1115,7 +1093,7 @@ fn select_with_having() { assert_snapshot!( err.strip_backtrace(), - @r"Error during planning: HAVING clause references: person.age > Int64(100) AND person.age < Int64(200) must appear in the GROUP BY clause or be used in an aggregate function" + @"Error during planning: HAVING clause references: person.age > Int64(100) AND person.age < Int64(200) must appear in the GROUP BY clause or be used in an aggregate function" ); } @@ -1128,9 +1106,7 @@ fn select_with_having_referencing_column_not_in_select() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: HAVING clause references: person.first_name = Utf8("M") must appear in the GROUP BY clause or be used in an aggregate function - "# + @r#"Error during planning: HAVING clause references: person.first_name = Utf8("M") must appear in the GROUP BY clause or be used in an aggregate function"# ); } @@ -1144,9 +1120,7 @@ fn select_with_having_refers_to_invalid_column() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Column in HAVING must be in GROUP BY or an aggregate function: While expanding wildcard, column "person.first_name" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "person.id, max(person.age)" appears in the SELECT clause satisfies this requirement - "# + @r#"Error during planning: Column in HAVING must be in GROUP BY or an aggregate function: While expanding wildcard, column "person.first_name" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "person.id, max(person.age)" appears in the SELECT clause satisfies this requirement"# ); } @@ -1159,9 +1133,7 @@ fn select_with_having_referencing_column_nested_in_select_expression() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: HAVING clause references: person.age > Int64(100) must appear in the GROUP BY clause or be used in an aggregate function - "# + @"Error during planning: HAVING clause references: person.age > Int64(100) must appear in the GROUP BY clause or be used in an aggregate function" ); } @@ -1186,12 +1158,12 @@ fn select_aggregate_with_having_that_reuses_aggregate() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: max(person.age) - Filter: max(person.age) < Int64(30) - Aggregate: groupBy=[[]], aggr=[[max(person.age)]] - TableScan: person - "# + @r" + Projection: max(person.age) + Filter: max(person.age) < Int64(30) + Aggregate: groupBy=[[]], aggr=[[max(person.age)]] + TableScan: person + " ); } @@ -1204,11 +1176,11 @@ fn select_aggregate_with_having_with_aggregate_not_in_select() { assert_snapshot!( plan, @r#" - Projection: max(person.age) - Filter: max(person.first_name) > Utf8("M") - Aggregate: groupBy=[[]], aggr=[[max(person.age), max(person.first_name)]] - TableScan: person - "# + Projection: max(person.age) + Filter: max(person.first_name) > Utf8("M") + Aggregate: groupBy=[[]], aggr=[[max(person.age), max(person.first_name)]] + TableScan: person + "# ); } @@ -1221,9 +1193,7 @@ fn select_aggregate_with_having_referencing_column_not_in_select() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Column in HAVING must be in GROUP BY or an aggregate function: While expanding wildcard, column "person.first_name" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "count(*)" appears in the SELECT clause satisfies this requirement - "# + @r#"Error during planning: Column in HAVING must be in GROUP BY or an aggregate function: While expanding wildcard, column "person.first_name" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "count(*)" appears in the SELECT clause satisfies this requirement"# ); } @@ -1236,12 +1206,12 @@ fn select_aggregate_aliased_with_having_referencing_aggregate_by_its_alias() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: max(person.age) AS max_age - Filter: max(person.age) < Int64(30) - Aggregate: groupBy=[[]], aggr=[[max(person.age)]] - TableScan: person - "# + @r" + Projection: max(person.age) AS max_age + Filter: max(person.age) < Int64(30) + Aggregate: groupBy=[[]], aggr=[[max(person.age)]] + TableScan: person + " ); } @@ -1253,12 +1223,12 @@ fn select_aggregate_aliased_with_having_that_reuses_aggregate_but_not_by_its_ali let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: max(person.age) AS max_age - Filter: max(person.age) < Int64(30) - Aggregate: groupBy=[[]], aggr=[[max(person.age)]] - TableScan: person - "# + @r" + Projection: max(person.age) AS max_age + Filter: max(person.age) < Int64(30) + Aggregate: groupBy=[[]], aggr=[[max(person.age)]] + TableScan: person + " ); } @@ -1272,11 +1242,11 @@ fn select_aggregate_with_group_by_with_having() { assert_snapshot!( plan, @r#" - Projection: person.first_name, max(person.age) - Filter: person.first_name = Utf8("M") - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] - TableScan: person - "# + Projection: person.first_name, max(person.age) + Filter: person.first_name = Utf8("M") + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] + TableScan: person + "# ); } @@ -1290,13 +1260,13 @@ fn select_aggregate_with_group_by_with_having_and_where() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.first_name, max(person.age) - Filter: max(person.age) < Int64(100) - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] - Filter: person.id > Int64(5) - TableScan: person - "# + @r" + Projection: person.first_name, max(person.age) + Filter: max(person.age) < Int64(100) + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] + Filter: person.id > Int64(5) + TableScan: person + " ); } @@ -1310,13 +1280,13 @@ fn select_aggregate_with_group_by_with_having_and_where_filtering_on_aggregate_c let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.first_name, max(person.age) - Filter: max(person.age) < Int64(100) - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] - Filter: person.id > Int64(5) AND person.age > Int64(18) - TableScan: person - "# + @r" + Projection: person.first_name, max(person.age) + Filter: max(person.age) < Int64(100) + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] + Filter: person.id > Int64(5) AND person.age > Int64(18) + TableScan: person + " ); } @@ -1330,11 +1300,11 @@ fn select_aggregate_with_group_by_with_having_using_column_by_alias() { assert_snapshot!( plan, @r#" - Projection: person.first_name AS fn, max(person.age) - Filter: max(person.age) > Int64(2) AND person.first_name = Utf8("M") - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] - TableScan: person - "# + Projection: person.first_name AS fn, max(person.age) + Filter: max(person.age) > Int64(2) AND person.first_name = Utf8("M") + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] + TableScan: person + "# ); } @@ -1349,11 +1319,11 @@ fn select_aggregate_with_group_by_with_having_using_columns_with_and_without_the assert_snapshot!( plan, @r#" - Projection: person.first_name AS fn, max(person.age) AS max_age - Filter: max(person.age) > Int64(2) AND max(person.age) < Int64(5) AND person.first_name = Utf8("M") AND person.first_name = Utf8("N") - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] - TableScan: person - "# + Projection: person.first_name AS fn, max(person.age) AS max_age + Filter: max(person.age) > Int64(2) AND max(person.age) < Int64(5) AND person.first_name = Utf8("M") AND person.first_name = Utf8("N") + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] + TableScan: person + "# ); } @@ -1366,12 +1336,12 @@ fn select_aggregate_with_group_by_with_having_that_reuses_aggregate() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.first_name, max(person.age) - Filter: max(person.age) > Int64(100) - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] - TableScan: person - "# + @r" + Projection: person.first_name, max(person.age) + Filter: max(person.age) > Int64(100) + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] + TableScan: person + " ); } @@ -1385,9 +1355,7 @@ fn select_aggregate_with_group_by_with_having_referencing_column_not_in_group_by assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Column in HAVING must be in GROUP BY or an aggregate function: While expanding wildcard, column "person.last_name" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "person.first_name, max(person.age)" appears in the SELECT clause satisfies this requirement - "# + @r#"Error during planning: Column in HAVING must be in GROUP BY or an aggregate function: While expanding wildcard, column "person.last_name" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "person.first_name, max(person.age)" appears in the SELECT clause satisfies this requirement"# ); } @@ -1400,12 +1368,12 @@ fn select_aggregate_with_group_by_with_having_that_reuses_aggregate_multiple_tim let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.first_name, max(person.age) - Filter: max(person.age) > Int64(100) AND max(person.age) < Int64(200) - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] - TableScan: person - "# + @r" + Projection: person.first_name, max(person.age) + Filter: max(person.age) > Int64(100) AND max(person.age) < Int64(200) + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] + TableScan: person + " ); } @@ -1418,12 +1386,12 @@ fn select_aggregate_with_group_by_with_having_using_aggregate_not_in_select() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.first_name, max(person.age) - Filter: max(person.age) > Int64(100) AND min(person.id) < Int64(50) - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age), min(person.id)]] - TableScan: person - "# + @r" + Projection: person.first_name, max(person.age) + Filter: max(person.age) > Int64(100) AND min(person.id) < Int64(50) + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age), min(person.id)]] + TableScan: person + " ); } @@ -1437,12 +1405,12 @@ fn select_aggregate_aliased_with_group_by_with_having_referencing_aggregate_by_i let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.first_name, max(person.age) AS max_age - Filter: max(person.age) > Int64(100) - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] - TableScan: person - "# + @r" + Projection: person.first_name, max(person.age) AS max_age + Filter: max(person.age) > Int64(100) + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] + TableScan: person + " ); } @@ -1456,12 +1424,12 @@ fn select_aggregate_compound_aliased_with_group_by_with_having_referencing_compo let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.first_name, max(person.age) + Int64(1) AS max_age_plus_one - Filter: max(person.age) + Int64(1) > Int64(100) - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] - TableScan: person - "# + @r" + Projection: person.first_name, max(person.age) + Int64(1) AS max_age_plus_one + Filter: max(person.age) + Int64(1) > Int64(100) + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age)]] + TableScan: person + " ); } @@ -1475,12 +1443,12 @@ fn select_aggregate_with_group_by_with_having_using_derived_column_aggregate_not let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.first_name, max(person.age) - Filter: max(person.age) > Int64(100) AND min(person.id - Int64(2)) < Int64(50) - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age), min(person.id - Int64(2))]] - TableScan: person - "# + @r" + Projection: person.first_name, max(person.age) + Filter: max(person.age) > Int64(100) AND min(person.id - Int64(2)) < Int64(50) + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age), min(person.id - Int64(2))]] + TableScan: person + " ); } @@ -1493,12 +1461,12 @@ fn select_aggregate_with_group_by_with_having_using_count_star_not_in_select() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.first_name, max(person.age) - Filter: max(person.age) > Int64(100) AND count(*) < Int64(50) - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age), count(*)]] - TableScan: person - "# + @r" + Projection: person.first_name, max(person.age) + Filter: max(person.age) > Int64(100) AND count(*) < Int64(50) + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.age), count(*)]] + TableScan: person + " ); } @@ -1508,10 +1476,10 @@ fn select_binary_expr() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.age + person.salary - TableScan: person - "# + @r" + Projection: person.age + person.salary + TableScan: person + " ); } @@ -1521,10 +1489,10 @@ fn select_binary_expr_nested() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: (person.age + person.salary) / Int64(2) - TableScan: person - "# + @r" + Projection: (person.age + person.salary) / Int64(2) + TableScan: person + " ); } @@ -1533,11 +1501,11 @@ fn select_simple_aggregate() { let plan = logical_plan("SELECT MIN(age) FROM person").unwrap(); assert_snapshot!( plan, - @r#" - Projection: min(person.age) - Aggregate: groupBy=[[]], aggr=[[min(person.age)]] - TableScan: person - "# + @r" + Projection: min(person.age) + Aggregate: groupBy=[[]], aggr=[[min(person.age)]] + TableScan: person + " ); } @@ -1546,11 +1514,11 @@ fn test_sum_aggregate() { let plan = logical_plan("SELECT sum(age) from person").unwrap(); assert_snapshot!( plan, - @r#" - Projection: sum(person.age) - Aggregate: groupBy=[[]], aggr=[[sum(person.age)]] - TableScan: person - "# + @r" + Projection: sum(person.age) + Aggregate: groupBy=[[]], aggr=[[sum(person.age)]] + TableScan: person + " ); } @@ -1568,9 +1536,7 @@ fn select_simple_aggregate_repeated_aggregate() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Projections require unique expression names but the expression "min(person.age)" at position 0 and "min(person.age)" at position 1 have the same name. Consider aliasing ("AS") one of them. - "# + @r#"Error during planning: Projections require unique expression names but the expression "min(person.age)" at position 0 and "min(person.age)" at position 1 have the same name. Consider aliasing ("AS") one of them."# ); } @@ -1579,11 +1545,11 @@ fn select_simple_aggregate_repeated_aggregate_with_single_alias() { let plan = logical_plan("SELECT MIN(age), MIN(age) AS a FROM person").unwrap(); assert_snapshot!( plan, - @r#" - Projection: min(person.age), min(person.age) AS a - Aggregate: groupBy=[[]], aggr=[[min(person.age)]] - TableScan: person - "# + @r" + Projection: min(person.age), min(person.age) AS a + Aggregate: groupBy=[[]], aggr=[[min(person.age)]] + TableScan: person + " ); } @@ -1592,11 +1558,11 @@ fn select_simple_aggregate_repeated_aggregate_with_unique_aliases() { let plan = logical_plan("SELECT MIN(age) AS a, MIN(age) AS b FROM person").unwrap(); assert_snapshot!( plan, - @r#" - Projection: min(person.age) AS a, min(person.age) AS b - Aggregate: groupBy=[[]], aggr=[[min(person.age)]] - TableScan: person - "# + @r" + Projection: min(person.age) AS a, min(person.age) AS b + Aggregate: groupBy=[[]], aggr=[[min(person.age)]] + TableScan: person + " ); } @@ -1623,9 +1589,7 @@ fn select_simple_aggregate_repeated_aggregate_with_repeated_aliases() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Projections require unique expression names but the expression "min(person.age) AS a" at position 0 and "min(person.age) AS a" at position 1 have the same name. Consider aliasing ("AS") one of them. - "# + @r#"Error during planning: Projections require unique expression names but the expression "min(person.age) AS a" at position 0 and "min(person.age) AS a" at position 1 have the same name. Consider aliasing ("AS") one of them."# ); } @@ -1636,11 +1600,11 @@ fn select_simple_aggregate_with_groupby() { .unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.state, min(person.age), max(person.age) - Aggregate: groupBy=[[person.state]], aggr=[[min(person.age), max(person.age)]] - TableScan: person - "# + @r" + Projection: person.state, min(person.age), max(person.age) + Aggregate: groupBy=[[person.state]], aggr=[[min(person.age), max(person.age)]] + TableScan: person + " ); } @@ -1651,11 +1615,11 @@ fn select_simple_aggregate_with_groupby_with_aliases() { .unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.state AS a, min(person.age) AS b - Aggregate: groupBy=[[person.state]], aggr=[[min(person.age)]] - TableScan: person - "# + @r" + Projection: person.state AS a, min(person.age) AS b + Aggregate: groupBy=[[person.state]], aggr=[[min(person.age)]] + TableScan: person + " ); } @@ -1666,9 +1630,7 @@ fn select_simple_aggregate_with_groupby_with_aliases_repeated() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Projections require unique expression names but the expression "person.state AS a" at position 0 and "min(person.age) AS a" at position 1 have the same name. Consider aliasing ("AS") one of them. - "# + @r#"Error during planning: Projections require unique expression names but the expression "person.state AS a" at position 0 and "min(person.age) AS a" at position 1 have the same name. Consider aliasing ("AS") one of them."# ); } @@ -1678,11 +1640,11 @@ fn select_simple_aggregate_with_groupby_column_unselected() { logical_plan("SELECT MIN(age), MAX(age) FROM person GROUP BY state").unwrap(); assert_snapshot!( plan, - @r#" - Projection: min(person.age), max(person.age) - Aggregate: groupBy=[[person.state]], aggr=[[min(person.age), max(person.age)]] - TableScan: person - "# + @r" + Projection: min(person.age), max(person.age) + Aggregate: groupBy=[[person.state]], aggr=[[min(person.age), max(person.age)]] + TableScan: person + " ); } @@ -1693,9 +1655,7 @@ fn select_simple_aggregate_with_groupby_and_column_in_group_by_does_not_exist() assert_snapshot!( err.strip_backtrace(), - @r#" - Schema error: No field named doesnotexist. Valid fields are "sum(person.age)", person.id, person.first_name, person.last_name, person.age, person.state, person.salary, person.birth_date, person."😀". - "# + @r#"Schema error: No field named doesnotexist. Valid fields are "sum(person.age)", person.id, person.first_name, person.last_name, person.age, person.state, person.salary, person.birth_date, person."😀"."# ); } @@ -1713,9 +1673,7 @@ fn select_interval_out_of_range() { assert_snapshot!( err.strip_backtrace(), - @r#" - Arrow error: Invalid argument error: Unable to represent 100000000000000000 days in a signed 32-bit integer - "# + @"Arrow error: Invalid argument error: Unable to represent 100000000000000000 days in a signed 32-bit integer" ); } @@ -1725,11 +1683,11 @@ fn select_simple_aggregate_with_groupby_and_column_is_in_aggregate_and_groupby() logical_plan("SELECT MAX(first_name) FROM person GROUP BY first_name").unwrap(); assert_snapshot!( plan, - @r#" - Projection: max(person.first_name) - Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.first_name)]] - TableScan: person - "# + @r" + Projection: max(person.first_name) + Aggregate: groupBy=[[person.first_name]], aggr=[[max(person.first_name)]] + TableScan: person + " ); } @@ -1739,21 +1697,21 @@ fn select_simple_aggregate_with_groupby_can_use_positions() { .unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.state, person.age AS b, count(Int64(1)) - Aggregate: groupBy=[[person.state, person.age]], aggr=[[count(Int64(1))]] - TableScan: person - "# + @r" + Projection: person.state, person.age AS b, count(Int64(1)) + Aggregate: groupBy=[[person.state, person.age]], aggr=[[count(Int64(1))]] + TableScan: person + " ); let plan = logical_plan("SELECT state, age AS b, count(1) FROM person GROUP BY 2, 1") .unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.state, person.age AS b, count(Int64(1)) - Aggregate: groupBy=[[person.age, person.state]], aggr=[[count(Int64(1))]] - TableScan: person - "# + @r" + Projection: person.state, person.age AS b, count(Int64(1)) + Aggregate: groupBy=[[person.age, person.state]], aggr=[[count(Int64(1))]] + TableScan: person + " ); } @@ -1764,9 +1722,7 @@ fn select_simple_aggregate_with_groupby_position_out_of_range() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Cannot find column with position 0 in SELECT clause. Valid columns: 1 to 2 - "# + @"Error during planning: Cannot find column with position 0 in SELECT clause. Valid columns: 1 to 2" ); let sql2 = "SELECT state, MIN(age) FROM person GROUP BY 5"; @@ -1774,9 +1730,7 @@ fn select_simple_aggregate_with_groupby_position_out_of_range() { assert_snapshot!( err2.strip_backtrace(), - @r#" - Error during planning: Cannot find column with position 5 in SELECT clause. Valid columns: 1 to 2 - "# + @"Error during planning: Cannot find column with position 5 in SELECT clause. Valid columns: 1 to 2" ); } @@ -1786,11 +1740,11 @@ fn select_simple_aggregate_with_groupby_can_use_alias() { logical_plan("SELECT state AS a, MIN(age) AS b FROM person GROUP BY a").unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.state AS a, min(person.age) AS b - Aggregate: groupBy=[[person.state]], aggr=[[min(person.age)]] - TableScan: person - "# + @r" + Projection: person.state AS a, min(person.age) AS b + Aggregate: groupBy=[[person.state]], aggr=[[min(person.age)]] + TableScan: person + " ); } @@ -1801,9 +1755,7 @@ fn select_simple_aggregate_with_groupby_aggregate_repeated() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Projections require unique expression names but the expression "min(person.age)" at position 1 and "min(person.age)" at position 2 have the same name. Consider aliasing ("AS") one of them. - "# + @r#"Error during planning: Projections require unique expression names but the expression "min(person.age)" at position 1 and "min(person.age)" at position 2 have the same name. Consider aliasing ("AS") one of them."# ); } @@ -1814,11 +1766,11 @@ fn select_simple_aggregate_with_groupby_aggregate_repeated_and_one_has_alias() { .unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.state, min(person.age), min(person.age) AS ma - Aggregate: groupBy=[[person.state]], aggr=[[min(person.age)]] - TableScan: person - "# + @r" + Projection: person.state, min(person.age), min(person.age) AS ma + Aggregate: groupBy=[[person.state]], aggr=[[min(person.age)]] + TableScan: person + " ); } @@ -1828,11 +1780,11 @@ fn select_simple_aggregate_with_groupby_non_column_expression_unselected() { logical_plan("SELECT MIN(first_name) FROM person GROUP BY age + 1").unwrap(); assert_snapshot!( plan, - @r#" - Projection: min(person.first_name) - Aggregate: groupBy=[[person.age + Int64(1)]], aggr=[[min(person.first_name)]] - TableScan: person - "# + @r" + Projection: min(person.first_name) + Aggregate: groupBy=[[person.age + Int64(1)]], aggr=[[min(person.first_name)]] + TableScan: person + " ); } @@ -1843,22 +1795,22 @@ fn select_simple_aggregate_with_groupby_non_column_expression_selected_and_resol .unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.age + Int64(1), min(person.first_name) - Aggregate: groupBy=[[person.age + Int64(1)]], aggr=[[min(person.first_name)]] - TableScan: person - "# + @r" + Projection: person.age + Int64(1), min(person.first_name) + Aggregate: groupBy=[[person.age + Int64(1)]], aggr=[[min(person.first_name)]] + TableScan: person + " ); let plan = logical_plan("SELECT MIN(first_name), age + 1 FROM person GROUP BY age + 1") .unwrap(); assert_snapshot!( plan, - @r#" - Projection: min(person.first_name), person.age + Int64(1) - Aggregate: groupBy=[[person.age + Int64(1)]], aggr=[[min(person.first_name)]] - TableScan: person - "# + @r" + Projection: min(person.first_name), person.age + Int64(1) + Aggregate: groupBy=[[person.age + Int64(1)]], aggr=[[min(person.first_name)]] + TableScan: person + " ); } @@ -1869,11 +1821,11 @@ fn select_simple_aggregate_with_groupby_non_column_expression_nested_and_resolva ).unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.age + Int64(1) / Int64(2) * person.age + Int64(1), min(person.first_name) - Aggregate: groupBy=[[person.age + Int64(1)]], aggr=[[min(person.first_name)]] - TableScan: person - "# + @r" + Projection: person.age + Int64(1) / Int64(2) * person.age + Int64(1), min(person.first_name) + Aggregate: groupBy=[[person.age + Int64(1)]], aggr=[[min(person.first_name)]] + TableScan: person + " ); } @@ -1886,9 +1838,7 @@ fn select_simple_aggregate_with_groupby_non_column_expression_nested_and_not_res assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Column in SELECT must be in GROUP BY or an aggregate function: While expanding wildcard, column "person.age" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "person.age + Int64(1), min(person.first_name)" appears in the SELECT clause satisfies this requirement - "# + @r#"Error during planning: Column in SELECT must be in GROUP BY or an aggregate function: While expanding wildcard, column "person.age" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "person.age + Int64(1), min(person.first_name)" appears in the SELECT clause satisfies this requirement"# ); } @@ -1899,9 +1849,7 @@ fn select_simple_aggregate_with_groupby_non_column_expression_and_its_column_sel assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Column in SELECT must be in GROUP BY or an aggregate function: While expanding wildcard, column "person.age" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "person.age + Int64(1), min(person.first_name)" appears in the SELECT clause satisfies this requirement - "# + @r#"Error during planning: Column in SELECT must be in GROUP BY or an aggregate function: While expanding wildcard, column "person.age" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "person.age + Int64(1), min(person.first_name)" appears in the SELECT clause satisfies this requirement"# ); } @@ -1911,11 +1859,11 @@ fn select_simple_aggregate_nested_in_binary_expr_with_groupby() { logical_plan("SELECT state, MIN(age) < 10 FROM person GROUP BY state").unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.state, min(person.age) < Int64(10) - Aggregate: groupBy=[[person.state]], aggr=[[min(person.age)]] - TableScan: person - "# + @r" + Projection: person.state, min(person.age) < Int64(10) + Aggregate: groupBy=[[person.state]], aggr=[[min(person.age)]] + TableScan: person + " ); } @@ -1925,11 +1873,11 @@ fn select_simple_aggregate_and_nested_groupby_column() { logical_plan("SELECT MAX(first_name), age + 1 FROM person GROUP BY age").unwrap(); assert_snapshot!( plan, - @r#" - Projection: max(person.first_name), person.age + Int64(1) - Aggregate: groupBy=[[person.age]], aggr=[[max(person.first_name)]] - TableScan: person - "# + @r" + Projection: max(person.first_name), person.age + Int64(1) + Aggregate: groupBy=[[person.age]], aggr=[[max(person.first_name)]] + TableScan: person + " ); } @@ -1938,11 +1886,11 @@ fn select_aggregate_compounded_with_groupby_column() { let plan = logical_plan("SELECT age + MIN(salary) FROM person GROUP BY age").unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.age + min(person.salary) - Aggregate: groupBy=[[person.age]], aggr=[[min(person.salary)]] - TableScan: person - "# + @r" + Projection: person.age + min(person.salary) + Aggregate: groupBy=[[person.age]], aggr=[[min(person.salary)]] + TableScan: person + " ); } @@ -1952,11 +1900,11 @@ fn select_aggregate_with_non_column_inner_expression_with_groupby() { logical_plan("SELECT state, MIN(age + 1) FROM person GROUP BY state").unwrap(); assert_snapshot!( plan, - @r#" - Projection: person.state, min(person.age + Int64(1)) - Aggregate: groupBy=[[person.state]], aggr=[[min(person.age + Int64(1))]] - TableScan: person - "# + @r" + Projection: person.state, min(person.age + Int64(1)) + Aggregate: groupBy=[[person.state]], aggr=[[min(person.age + Int64(1))]] + TableScan: person + " ); } @@ -1966,11 +1914,11 @@ fn select_count_one() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: count(Int64(1)) - Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] - TableScan: person -"# + @r" + Projection: count(Int64(1)) + Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] + TableScan: person + " ); } @@ -1980,11 +1928,11 @@ fn select_count_column() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: count(person.id) - Aggregate: groupBy=[[]], aggr=[[count(person.id)]] - TableScan: person -"# + @r" + Projection: count(person.id) + Aggregate: groupBy=[[]], aggr=[[count(person.id)]] + TableScan: person + " ); } @@ -1994,11 +1942,11 @@ fn select_approx_median() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: approx_median(person.age) - Aggregate: groupBy=[[]], aggr=[[approx_median(person.age)]] - TableScan: person -"# + @r" + Projection: approx_median(person.age) + Aggregate: groupBy=[[]], aggr=[[approx_median(person.age)]] + TableScan: person + " ); } @@ -2008,10 +1956,10 @@ fn select_scalar_func() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: sqrt(person.age) - TableScan: person -"# + @r" + Projection: sqrt(person.age) + TableScan: person + " ); } @@ -2021,10 +1969,10 @@ fn select_aliased_scalar_func() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: sqrt(person.age) AS square_people - TableScan: person -"# + @r" + Projection: sqrt(person.age) AS square_people + TableScan: person + " ); } @@ -2035,11 +1983,11 @@ fn select_where_nullif_division() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: aggregate_test_100.c3 / (aggregate_test_100.c4 + aggregate_test_100.c5) - Filter: aggregate_test_100.c3 / nullif(aggregate_test_100.c4 + aggregate_test_100.c5, Int64(0)) > Float64(0.1) - TableScan: aggregate_test_100 -"# + @r" + Projection: aggregate_test_100.c3 / (aggregate_test_100.c4 + aggregate_test_100.c5) + Filter: aggregate_test_100.c3 / nullif(aggregate_test_100.c4 + aggregate_test_100.c5, Int64(0)) > Float64(0.1) + TableScan: aggregate_test_100 + " ); } @@ -2049,11 +1997,11 @@ fn select_where_with_negative_operator() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: aggregate_test_100.c3 - Filter: aggregate_test_100.c3 > Float64(-0.1) AND (- aggregate_test_100.c4) > Int64(0) - TableScan: aggregate_test_100 -"# + @r" + Projection: aggregate_test_100.c3 + Filter: aggregate_test_100.c3 > Float64(-0.1) AND (- aggregate_test_100.c4) > Int64(0) + TableScan: aggregate_test_100 + " ); } @@ -2063,11 +2011,11 @@ fn select_where_with_positive_operator() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: aggregate_test_100.c3 - Filter: aggregate_test_100.c3 > Float64(0.1) AND aggregate_test_100.c4 > Int64(0) - TableScan: aggregate_test_100 -"# + @r" + Projection: aggregate_test_100.c3 + Filter: aggregate_test_100.c3 > Float64(0.1) AND aggregate_test_100.c4 > Int64(0) + TableScan: aggregate_test_100 + " ); } @@ -2079,11 +2027,11 @@ fn select_where_compound_identifiers() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: public.aggregate_test_100.c3 - Filter: public.aggregate_test_100.c3 > Float64(0.1) - TableScan: public.aggregate_test_100 -"# + @r" + Projection: public.aggregate_test_100.c3 + Filter: public.aggregate_test_100.c3 > Float64(0.1) + TableScan: public.aggregate_test_100 + " ); } @@ -2093,11 +2041,11 @@ fn select_order_by_index() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Sort: person.id ASC NULLS LAST - Projection: person.id - TableScan: person -"# + @r" + Sort: person.id ASC NULLS LAST + Projection: person.id + TableScan: person + " ); } @@ -2107,11 +2055,11 @@ fn select_order_by_multiple_index() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Sort: person.id ASC NULLS LAST, person.age ASC NULLS LAST - Projection: person.id, person.state, person.age - TableScan: person -"# + @r" + Sort: person.id ASC NULLS LAST, person.age ASC NULLS LAST + Projection: person.id, person.state, person.age + TableScan: person + " ); } @@ -2124,9 +2072,7 @@ fn select_order_by_index_of_0() { assert_snapshot!( err, - @r#" - Error during planning: Order by index starts at 1 for column indexes - "# + @"Error during planning: Order by index starts at 1 for column indexes" ); } @@ -2139,9 +2085,7 @@ fn select_order_by_index_oob() { assert_snapshot!( err, - @r#" - Error during planning: Order by column out of bounds, specified: 2, max: 1 - "# + @"Error during planning: Order by column out of bounds, specified: 2, max: 1" ); } @@ -2151,11 +2095,11 @@ fn select_with_order_by() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Sort: person.id ASC NULLS LAST - Projection: person.id - TableScan: person -"# + @r" + Sort: person.id ASC NULLS LAST + Projection: person.id + TableScan: person + " ); } @@ -2165,11 +2109,11 @@ fn select_order_by_desc() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Sort: person.id DESC NULLS FIRST - Projection: person.id - TableScan: person -"# + @r" + Sort: person.id DESC NULLS FIRST + Projection: person.id + TableScan: person + " ); } @@ -2178,21 +2122,21 @@ fn select_order_by_nulls_last() { let plan = logical_plan("SELECT id FROM person ORDER BY id DESC NULLS LAST").unwrap(); assert_snapshot!( plan, - @r#" -Sort: person.id DESC NULLS LAST - Projection: person.id - TableScan: person -"# + @r" + Sort: person.id DESC NULLS LAST + Projection: person.id + TableScan: person + " ); let plan = logical_plan("SELECT id FROM person ORDER BY id NULLS LAST").unwrap(); assert_snapshot!( plan, - @r#" -Sort: person.id ASC NULLS LAST - Projection: person.id - TableScan: person -"# + @r" + Sort: person.id ASC NULLS LAST + Projection: person.id + TableScan: person + " ); } @@ -2202,11 +2146,11 @@ fn select_group_by() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.state - Aggregate: groupBy=[[person.state]], aggr=[[]] - TableScan: person -"# + @r" + Projection: person.state + Aggregate: groupBy=[[person.state]], aggr=[[]] + TableScan: person + " ); } @@ -2216,11 +2160,11 @@ fn select_group_by_columns_not_in_select() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: max(person.age) - Aggregate: groupBy=[[person.state]], aggr=[[max(person.age)]] - TableScan: person -"# + @r" + Projection: max(person.age) + Aggregate: groupBy=[[person.state]], aggr=[[max(person.age)]] + TableScan: person + " ); } @@ -2230,11 +2174,11 @@ fn select_group_by_count_star() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.state, count(*) - Aggregate: groupBy=[[person.state]], aggr=[[count(*)]] - TableScan: person -"# + @r" + Projection: person.state, count(*) + Aggregate: groupBy=[[person.state]], aggr=[[count(*)]] + TableScan: person + " ); } @@ -2244,11 +2188,11 @@ fn select_group_by_needs_projection() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - Projection: count(person.state), person.state - Aggregate: groupBy=[[person.state]], aggr=[[count(person.state)]] - TableScan: person - "# + @r" + Projection: count(person.state), person.state + Aggregate: groupBy=[[person.state]], aggr=[[count(person.state)]] + TableScan: person + " ); } @@ -2258,11 +2202,11 @@ fn select_7480_1() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: aggregate_test_100.c1, min(aggregate_test_100.c12) - Aggregate: groupBy=[[aggregate_test_100.c1, aggregate_test_100.c13]], aggr=[[min(aggregate_test_100.c12)]] - TableScan: aggregate_test_100 -"# + @r" + Projection: aggregate_test_100.c1, min(aggregate_test_100.c12) + Aggregate: groupBy=[[aggregate_test_100.c1, aggregate_test_100.c13]], aggr=[[min(aggregate_test_100.c12)]] + TableScan: aggregate_test_100 + " ); } @@ -2273,9 +2217,7 @@ fn select_7480_2() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: Column in SELECT must be in GROUP BY or an aggregate function: While expanding wildcard, column "aggregate_test_100.c13" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "aggregate_test_100.c1, min(aggregate_test_100.c12)" appears in the SELECT clause satisfies this requirement - "# + @r#"Error during planning: Column in SELECT must be in GROUP BY or an aggregate function: While expanding wildcard, column "aggregate_test_100.c13" must appear in the GROUP BY clause or must be part of an aggregate function, currently only "aggregate_test_100.c1, min(aggregate_test_100.c12)" appears in the SELECT clause satisfies this requirement"# ); } @@ -2285,9 +2227,7 @@ fn create_external_table_csv() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateExternalTable: Bare { table: "t" } -"# + @r#"CreateExternalTable: Bare { table: "t" }"# ); } @@ -2297,9 +2237,7 @@ fn create_external_table_with_pk() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateExternalTable: Bare { table: "t" } constraints=[PrimaryKey([0])] - "# + @r#"CreateExternalTable: Bare { table: "t" } constraints=[PrimaryKey([0])]"# ); } @@ -2309,9 +2247,7 @@ fn create_external_table_wih_schema() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateExternalTable: Partial { schema: "staging", table: "foo" } -"# + @r#"CreateExternalTable: Partial { schema: "staging", table: "foo" }"# ); } @@ -2321,9 +2257,7 @@ fn create_schema_with_quoted_name() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateCatalogSchema: "quoted_schema_name" -"# + @r#"CreateCatalogSchema: "quoted_schema_name""# ); } @@ -2333,9 +2267,7 @@ fn create_schema_with_quoted_unnormalized_name() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateCatalogSchema: "Foo" -"# + @r#"CreateCatalogSchema: "Foo""# ); } @@ -2345,9 +2277,7 @@ fn create_schema_with_unquoted_normalized_name() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateCatalogSchema: "foo" -"# + @r#"CreateCatalogSchema: "foo""# ); } @@ -2357,9 +2287,7 @@ fn create_external_table_custom() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateExternalTable: Bare { table: "dt" } -"# + @r#"CreateExternalTable: Bare { table: "dt" }"# ); } @@ -2369,9 +2297,7 @@ fn create_external_table_csv_no_schema() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateExternalTable: Bare { table: "t" } -"# + @r#"CreateExternalTable: Bare { table: "t" }"# ); } @@ -2391,9 +2317,7 @@ fn create_external_table_with_compression_type() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" - CreateExternalTable: Bare { table: "t" } - "# + @r#"CreateExternalTable: Bare { table: "t" }"# ); } @@ -2415,9 +2339,7 @@ fn create_external_table_with_compression_type() { assert_snapshot!( err.strip_backtrace(), - @r#" - Error during planning: File compression type cannot be set for PARQUET, AVRO, or ARROW files. - "# + @"Error during planning: File compression type cannot be set for PARQUET, AVRO, or ARROW files." ); } @@ -2430,9 +2352,7 @@ fn create_external_table_parquet() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateExternalTable: Bare { table: "t" } -"# + @r#"CreateExternalTable: Bare { table: "t" }"# ); } @@ -2442,9 +2362,7 @@ fn create_external_table_parquet_sort_order() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateExternalTable: Bare { table: "foo" } -"# + @r#"CreateExternalTable: Bare { table: "foo" }"# ); } @@ -2464,9 +2382,7 @@ fn create_external_table_parquet_no_schema_sort_order() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -CreateExternalTable: Bare { table: "t" } -"# + @r#"CreateExternalTable: Bare { table: "t" }"# ); } @@ -2479,12 +2395,12 @@ fn equijoin_explicit_syntax() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Inner Join: Filter: person.id = orders.customer_id + TableScan: person + TableScan: orders + " ); } @@ -2497,12 +2413,12 @@ fn equijoin_with_condition() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id AND orders.order_id > Int64(1) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Inner Join: Filter: person.id = orders.customer_id AND orders.order_id > Int64(1) + TableScan: person + TableScan: orders + " ); } @@ -2515,12 +2431,12 @@ fn left_equijoin_with_conditions() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Left Join: Filter: person.id = orders.customer_id AND orders.order_id > Int64(1) AND person.age < Int64(30) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Left Join: Filter: person.id = orders.customer_id AND orders.order_id > Int64(1) AND person.age < Int64(30) + TableScan: person + TableScan: orders + " ); } @@ -2533,12 +2449,12 @@ fn right_equijoin_with_conditions() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Right Join: Filter: person.id = orders.customer_id AND person.id > Int64(1) AND orders.order_id < Int64(100) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Right Join: Filter: person.id = orders.customer_id AND person.id > Int64(1) AND orders.order_id < Int64(100) + TableScan: person + TableScan: orders + " ); } @@ -2551,12 +2467,12 @@ fn full_equijoin_with_conditions() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Full Join: Filter: person.id = orders.customer_id AND person.id > Int64(1) AND orders.order_id < Int64(100) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Full Join: Filter: person.id = orders.customer_id AND person.id > Int64(1) AND orders.order_id < Int64(100) + TableScan: person + TableScan: orders + " ); } @@ -2569,12 +2485,12 @@ fn join_with_table_name() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Inner Join: Filter: person.id = orders.customer_id + TableScan: person + TableScan: orders + " ); } @@ -2587,13 +2503,13 @@ fn join_with_using() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.first_name, person.id - Inner Join: Using person.id = person2.id - TableScan: person - SubqueryAlias: person2 - TableScan: person -"# + @r" + Projection: person.first_name, person.id + Inner Join: Using person.id = person2.id + TableScan: person + SubqueryAlias: person2 + TableScan: person + " ); } @@ -2606,14 +2522,14 @@ fn equijoin_explicit_syntax_3_tables() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id, lineitem.l_description - Inner Join: Filter: orders.o_item_id = lineitem.l_item_id - Inner Join: Filter: person.id = orders.customer_id - TableScan: person - TableScan: orders - TableScan: lineitem -"# + @r" + Projection: person.id, orders.order_id, lineitem.l_description + Inner Join: Filter: orders.o_item_id = lineitem.l_item_id + Inner Join: Filter: person.id = orders.customer_id + TableScan: person + TableScan: orders + TableScan: lineitem + " ); } @@ -2625,11 +2541,11 @@ fn boolean_literal_in_condition_expression() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id - Filter: orders.delivered = Boolean(false) OR orders.delivered = Boolean(true) - TableScan: orders -"# + @r" + Projection: orders.order_id + Filter: orders.delivered = Boolean(false) OR orders.delivered = Boolean(true) + TableScan: orders + " ); } @@ -2639,14 +2555,14 @@ fn union() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Distinct: - Union - Projection: orders.order_id - TableScan: orders - Projection: orders.order_id - TableScan: orders -"# + @r" + Distinct: + Union + Projection: orders.order_id + TableScan: orders + Projection: orders.order_id + TableScan: orders + " ); } @@ -2656,16 +2572,16 @@ fn union_by_name_different_columns() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Distinct: - Union - Projection: order_id, NULL AS Int64(1) - Projection: orders.order_id - TableScan: orders - Projection: order_id, Int64(1) - Projection: orders.order_id, Int64(1) - TableScan: orders -"# + @r" + Distinct: + Union + Projection: order_id, NULL AS Int64(1) + Projection: orders.order_id + TableScan: orders + Projection: order_id, Int64(1) + Projection: orders.order_id, Int64(1) + TableScan: orders + " ); } @@ -2675,14 +2591,14 @@ fn union_by_name_same_column_names() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Distinct: - Union - Projection: orders.order_id - TableScan: orders - Projection: orders.order_id - TableScan: orders -"# + @r" + Distinct: + Union + Projection: orders.order_id + TableScan: orders + Projection: orders.order_id + TableScan: orders + " ); } @@ -2692,13 +2608,13 @@ fn union_all() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Union - Projection: orders.order_id - TableScan: orders - Projection: orders.order_id - TableScan: orders -"# + @r" + Union + Projection: orders.order_id + TableScan: orders + Projection: orders.order_id + TableScan: orders + " ); } @@ -2709,15 +2625,15 @@ fn union_all_by_name_different_columns() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Union - Projection: order_id, NULL AS Int64(1) - Projection: orders.order_id - TableScan: orders - Projection: order_id, Int64(1) - Projection: orders.order_id, Int64(1) - TableScan: orders -"# + @r" + Union + Projection: order_id, NULL AS Int64(1) + Projection: orders.order_id + TableScan: orders + Projection: order_id, Int64(1) + Projection: orders.order_id, Int64(1) + TableScan: orders + " ); } @@ -2727,15 +2643,15 @@ fn union_all_by_name_same_column_names() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Union - Projection: order_id - Projection: orders.order_id - TableScan: orders - Projection: order_id - Projection: orders.order_id - TableScan: orders -"# + @r" + Union + Projection: order_id + Projection: orders.order_id + TableScan: orders + Projection: order_id + Projection: orders.order_id + TableScan: orders + " ); } @@ -2745,11 +2661,11 @@ fn empty_over() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - WindowAggr: windowExpr=[[max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + WindowAggr: windowExpr=[[max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + TableScan: orders + " ); } @@ -2759,11 +2675,11 @@ fn empty_over_with_alias() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id AS oid, max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS max_oid - WindowAggr: windowExpr=[[max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - TableScan: orders -"# + @r" + Projection: orders.order_id AS oid, max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS max_oid + WindowAggr: windowExpr=[[max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + TableScan: orders + " ); } @@ -2773,11 +2689,11 @@ fn empty_over_dup_with_alias() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id AS oid, max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS max_oid, max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS max_oid_dup - WindowAggr: windowExpr=[[max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - TableScan: orders -"# + @r" + Projection: orders.order_id AS oid, max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS max_oid, max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS max_oid_dup + WindowAggr: windowExpr=[[max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + TableScan: orders + " ); } @@ -2787,12 +2703,12 @@ fn empty_over_dup_with_different_sort() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id AS oid, max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, max(orders.order_id) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - WindowAggr: windowExpr=[[max(orders.order_id) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id AS oid, max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, max(orders.order_id) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[max(orders.order_id) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + WindowAggr: windowExpr=[[max(orders.order_id) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -2802,11 +2718,11 @@ fn empty_over_plus() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty * Float64(1.1)) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - WindowAggr: windowExpr=[[max(orders.qty * Float64(1.1)) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty * Float64(1.1)) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + WindowAggr: windowExpr=[[max(orders.qty * Float64(1.1)) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + TableScan: orders + " ); } @@ -2816,11 +2732,11 @@ fn empty_over_multiple() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, min(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, avg(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - WindowAggr: windowExpr=[[max(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, min(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, avg(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, min(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, avg(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + WindowAggr: windowExpr=[[max(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, min(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, avg(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + TableScan: orders + " ); } @@ -2839,11 +2755,11 @@ fn over_partition_by() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + TableScan: orders + " ); } @@ -2865,12 +2781,12 @@ fn over_order_by() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -2880,12 +2796,12 @@ fn over_order_by_with_window_frame_double_end() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING, min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING]] - WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING, min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING]] + WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -2895,12 +2811,12 @@ fn over_order_by_with_window_frame_single_end() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND CURRENT ROW, min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND CURRENT ROW, min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] ROWS BETWEEN 3 PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -2910,12 +2826,12 @@ fn over_order_by_with_window_frame_single_end_groups() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] GROUPS BETWEEN 3 PRECEDING AND CURRENT ROW, min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] GROUPS BETWEEN 3 PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] GROUPS BETWEEN 3 PRECEDING AND CURRENT ROW, min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] GROUPS BETWEEN 3 PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -2937,12 +2853,12 @@ fn over_order_by_two_sort_keys() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, min(orders.qty) ORDER BY [orders.order_id + Int64(1) ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id + Int64(1) ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, min(orders.qty) ORDER BY [orders.order_id + Int64(1) ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id + Int64(1) ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -2965,13 +2881,13 @@ fn over_order_by_sort_keys_sorting() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) ORDER BY [orders.qty ASC NULLS LAST, orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.qty ASC NULLS LAST, orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) ORDER BY [orders.qty ASC NULLS LAST, orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.qty ASC NULLS LAST, orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -2992,13 +2908,13 @@ fn over_order_by_sort_keys_sorting_prefix_compacting() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -3024,14 +2940,14 @@ fn over_order_by_sort_keys_sorting_global_order_compacting() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Sort: orders.order_id ASC NULLS LAST - Projection: orders.order_id, max(orders.qty) ORDER BY [orders.qty ASC NULLS LAST, orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.qty ASC NULLS LAST, orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Sort: orders.order_id ASC NULLS LAST + Projection: orders.order_id, max(orders.qty) ORDER BY [orders.qty ASC NULLS LAST, orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[sum(orders.qty) ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + WindowAggr: windowExpr=[[max(orders.qty) ORDER BY [orders.qty ASC NULLS LAST, orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[min(orders.qty) ORDER BY [orders.order_id ASC NULLS LAST, orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -3051,11 +2967,11 @@ fn over_partition_by_order_by() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -3074,11 +2990,11 @@ fn over_partition_by_order_by_no_dup() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -3100,12 +3016,12 @@ fn over_partition_by_order_by_mix_up() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, min(orders.qty) PARTITION BY [orders.qty] ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[min(orders.qty) PARTITION BY [orders.qty] ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, min(orders.qty) PARTITION BY [orders.qty] ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[min(orders.qty) PARTITION BY [orders.qty] ORDER BY [orders.order_id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -3126,12 +3042,12 @@ fn over_partition_by_order_by_mix_up_prefix() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, min(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.price ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[min(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.price ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, min(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.price ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id] ORDER BY [orders.qty ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[min(orders.qty) PARTITION BY [orders.order_id, orders.qty] ORDER BY [orders.price ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: orders + " ); } @@ -3142,11 +3058,11 @@ fn approx_median_window() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, approx_median(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - WindowAggr: windowExpr=[[approx_median(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - TableScan: orders -"# + @r" + Projection: orders.order_id, approx_median(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + WindowAggr: windowExpr=[[approx_median(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + TableScan: orders + " ); } @@ -3182,10 +3098,10 @@ fn select_multibyte_column() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.😀 - TableScan: person -"# + @r" + Projection: person.😀 + TableScan: person + " ); } @@ -3230,11 +3146,11 @@ fn select_groupby_orderby() { plan, // expect that this is not an ambiguous reference @r#" - Sort: birth_date ASC NULLS LAST - Projection: avg(person.age) AS value, date_trunc(Utf8("month"), person.birth_date) AS birth_date - Aggregate: groupBy=[[person.birth_date]], aggr=[[avg(person.age)]] - TableScan: person - "# + Sort: birth_date ASC NULLS LAST + Projection: avg(person.age) AS value, date_trunc(Utf8("month"), person.birth_date) AS birth_date + Aggregate: groupBy=[[person.birth_date]], aggr=[[avg(person.age)]] + TableScan: person + "# ); } } @@ -3250,11 +3166,11 @@ fn select_groupby_orderby() { assert_snapshot!( plan, @r#" -Sort: avg(person.age) + avg(person.age) ASC NULLS LAST - Projection: avg(person.age) + avg(person.age), date_trunc(Utf8("month"), person.birth_date) AS birth_date - Aggregate: groupBy=[[person.birth_date]], aggr=[[avg(person.age)]] - TableScan: person -"# + Sort: avg(person.age) + avg(person.age) ASC NULLS LAST + Projection: avg(person.age) + avg(person.age), date_trunc(Utf8("month"), person.birth_date) AS birth_date + Aggregate: groupBy=[[person.birth_date]], aggr=[[avg(person.age)]] + TableScan: person + "# ); } @@ -3264,13 +3180,13 @@ fn select_groupby_orderby_aggregate_on_non_selected_column() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.state - Sort: min(person.age) ASC NULLS LAST - Projection: person.state, min(person.age) - Aggregate: groupBy=[[person.state]], aggr=[[min(person.age)]] - TableScan: person -"# + @r" + Projection: person.state + Sort: min(person.age) ASC NULLS LAST + Projection: person.state, min(person.age) + Aggregate: groupBy=[[person.state]], aggr=[[min(person.age)]] + TableScan: person + " ); } @@ -3281,13 +3197,13 @@ fn select_groupby_orderby_multiple_aggregates_on_non_selected_columns() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.state - Sort: min(person.age) ASC NULLS LAST, max(person.salary) DESC NULLS FIRST - Projection: person.state, min(person.age), max(person.salary) - Aggregate: groupBy=[[person.state]], aggr=[[min(person.age), max(person.salary)]] - TableScan: person -"# + @r" + Projection: person.state + Sort: min(person.age) ASC NULLS LAST, max(person.salary) DESC NULLS FIRST + Projection: person.state, min(person.age), max(person.salary) + Aggregate: groupBy=[[person.state]], aggr=[[min(person.age), max(person.salary)]] + TableScan: person + " ); } @@ -3296,14 +3212,14 @@ fn select_groupby_orderby_aggregate_on_non_selected_column_original_issue() { let sql = "SELECT id FROM person GROUP BY id ORDER BY min(age)"; let plan = logical_plan(sql).unwrap(); assert_snapshot!( - plan, - @r#" -Projection: person.id - Sort: min(person.age) ASC NULLS LAST - Projection: person.id, min(person.age) - Aggregate: groupBy=[[person.id]], aggr=[[min(person.age)]] - TableScan: person -"# + plan, + @r" + Projection: person.id + Sort: min(person.age) ASC NULLS LAST + Projection: person.id, min(person.age) + Aggregate: groupBy=[[person.id]], aggr=[[min(person.age)]] + TableScan: person + " ); } @@ -3462,10 +3378,10 @@ fn select_partially_qualified_column() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: public.person.first_name - TableScan: public.person -"# + @r" + Projection: public.person.first_name + TableScan: public.person + " ); } @@ -3476,15 +3392,15 @@ fn cross_join_not_to_inner_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id - Filter: person.id = person.age - Cross Join: - Cross Join: - TableScan: person - TableScan: orders - TableScan: lineitem -"# + @r" + Projection: person.id + Filter: person.id = person.age + Cross Join: + Cross Join: + TableScan: person + TableScan: orders + TableScan: lineitem + " ); } @@ -3494,14 +3410,14 @@ fn join_with_aliases() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: peeps.id, folks.first_name - Inner Join: Filter: peeps.id = folks.id - SubqueryAlias: peeps - TableScan: person - SubqueryAlias: folks - TableScan: person -"# + @r" + Projection: peeps.id, folks.first_name + Inner Join: Filter: peeps.id = folks.id + SubqueryAlias: peeps + TableScan: person + SubqueryAlias: folks + TableScan: person + " ); } @@ -3551,9 +3467,9 @@ fn date_plus_interval_in_projection() { assert_snapshot!( plan, @r#" -Projection: test.t_date32 + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }") - TableScan: test -"# + Projection: test.t_date32 + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 5, nanoseconds: 0 }") + TableScan: test + "# ); } @@ -3567,10 +3483,10 @@ fn date_plus_interval_in_filter() { assert_snapshot!( plan, @r#" -Projection: test.t_date64 - Filter: test.t_date64 BETWEEN CAST(Utf8("1999-12-31") AS Date32) AND CAST(Utf8("1999-12-31") AS Date32) + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 30, nanoseconds: 0 }") - TableScan: test -"# + Projection: test.t_date64 + Filter: test.t_date64 BETWEEN CAST(Utf8("1999-12-31") AS Date32) AND CAST(Utf8("1999-12-31") AS Date32) + IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 30, nanoseconds: 0 }") + TableScan: test + "# ); } @@ -3583,16 +3499,16 @@ fn exists_subquery() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: p.id - Filter: EXISTS () - Subquery: - Projection: person.first_name - Filter: person.last_name = outer_ref(p.last_name) AND person.state = outer_ref(p.state) + @r" + Projection: p.id + Filter: EXISTS () + Subquery: + Projection: person.first_name + Filter: person.last_name = outer_ref(p.last_name) AND person.state = outer_ref(p.state) + TableScan: person + SubqueryAlias: p TableScan: person - SubqueryAlias: p - TableScan: person -"# + " ); } @@ -3608,21 +3524,21 @@ fn exists_subquery_schema_outer_schema_overlap() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id - Filter: person.id = p.id AND EXISTS () - Subquery: - Projection: person.first_name - Filter: person.id = p2.id AND person.last_name = outer_ref(p.last_name) AND person.state = outer_ref(p.state) - Cross Join: + @r" + Projection: person.id + Filter: person.id = p.id AND EXISTS () + Subquery: + Projection: person.first_name + Filter: person.id = p2.id AND person.last_name = outer_ref(p.last_name) AND person.state = outer_ref(p.state) + Cross Join: + TableScan: person + SubqueryAlias: p2 + TableScan: person + Cross Join: + TableScan: person + SubqueryAlias: p TableScan: person - SubqueryAlias: p2 - TableScan: person - Cross Join: - TableScan: person - SubqueryAlias: p - TableScan: person -"# + " ); } @@ -3633,15 +3549,15 @@ fn in_subquery_uncorrelated() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: p.id - Filter: p.id IN () - Subquery: - Projection: person.id - TableScan: person - SubqueryAlias: p - TableScan: person -"# + @r" + Projection: p.id + Filter: p.id IN () + Subquery: + Projection: person.id + TableScan: person + SubqueryAlias: p + TableScan: person + " ); } @@ -3653,15 +3569,15 @@ fn not_in_subquery_correlated() { assert_snapshot!( plan, @r#" -Projection: p.id - Filter: p.id NOT IN () - Subquery: - Projection: person.id - Filter: person.last_name = outer_ref(p.last_name) AND person.state = Utf8("CO") + Projection: p.id + Filter: p.id NOT IN () + Subquery: + Projection: person.id + Filter: person.last_name = outer_ref(p.last_name) AND person.state = Utf8("CO") + TableScan: person + SubqueryAlias: p TableScan: person - SubqueryAlias: p - TableScan: person -"# + "# ); } @@ -3671,16 +3587,16 @@ fn scalar_subquery() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: p.id, () - Subquery: - Projection: max(person.id) - Aggregate: groupBy=[[]], aggr=[[max(person.id)]] - Filter: person.last_name = outer_ref(p.last_name) - TableScan: person - SubqueryAlias: p - TableScan: person -"# + @r" + Projection: p.id, () + Subquery: + Projection: max(person.id) + Aggregate: groupBy=[[]], aggr=[[max(person.id)]] + Filter: person.last_name = outer_ref(p.last_name) + TableScan: person + SubqueryAlias: p + TableScan: person + " ); } @@ -3696,20 +3612,20 @@ fn scalar_subquery_reference_outer_field() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: j1.j1_string, j2.j2_string - Filter: j1.j1_id = j2.j2_id - Int64(1) AND j2.j2_id < () - Subquery: - Projection: count(*) - Aggregate: groupBy=[[]], aggr=[[count(*)]] - Filter: outer_ref(j2.j2_id) = j1.j1_id AND j1.j1_id = j3.j3_id - Cross Join: - TableScan: j1 - TableScan: j3 - Cross Join: - TableScan: j1 - TableScan: j2 -"# + @r" + Projection: j1.j1_string, j2.j2_string + Filter: j1.j1_id = j2.j2_id - Int64(1) AND j2.j2_id < () + Subquery: + Projection: count(*) + Aggregate: groupBy=[[]], aggr=[[count(*)]] + Filter: outer_ref(j2.j2_id) = j1.j1_id AND j1.j1_id = j3.j3_id + Cross Join: + TableScan: j1 + TableScan: j3 + Cross Join: + TableScan: j1 + TableScan: j2 + " ); } @@ -3720,11 +3636,11 @@ fn aggregate_with_rollup() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.state, person.age, count(*) - Aggregate: groupBy=[[GROUPING SETS ((person.id), (person.id, person.state), (person.id, person.state, person.age))]], aggr=[[count(*)]] - TableScan: person -"# + @r" + Projection: person.id, person.state, person.age, count(*) + Aggregate: groupBy=[[GROUPING SETS ((person.id), (person.id, person.state), (person.id, person.state, person.age))]], aggr=[[count(*)]] + TableScan: person + " ); } @@ -3735,11 +3651,11 @@ fn aggregate_with_rollup_with_grouping() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.state, person.age, grouping(person.state), grouping(person.age), grouping(person.state) + grouping(person.age), count(*) - Aggregate: groupBy=[[GROUPING SETS ((person.id), (person.id, person.state), (person.id, person.state, person.age))]], aggr=[[grouping(person.state), grouping(person.age), count(*)]] - TableScan: person -"# + @r" + Projection: person.id, person.state, person.age, grouping(person.state), grouping(person.age), grouping(person.state) + grouping(person.age), count(*) + Aggregate: groupBy=[[GROUPING SETS ((person.id), (person.id, person.state), (person.id, person.state, person.age))]], aggr=[[grouping(person.state), grouping(person.age), count(*)]] + TableScan: person + " ); } @@ -3761,12 +3677,12 @@ fn rank_partition_grouping() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: sum(person.age) AS total_sum, person.state, person.last_name, grouping(person.state) + grouping(person.last_name) AS x, rank() PARTITION BY [grouping(person.state) + grouping(person.last_name), CASE WHEN grouping(person.last_name) = Int64(0) THEN person.state END] ORDER BY [sum(person.age) DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS the_rank - WindowAggr: windowExpr=[[rank() PARTITION BY [grouping(person.state) + grouping(person.last_name), CASE WHEN grouping(person.last_name) = Int64(0) THEN person.state END] ORDER BY [sum(person.age) DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - Aggregate: groupBy=[[ROLLUP (person.state, person.last_name)]], aggr=[[sum(person.age), grouping(person.state), grouping(person.last_name)]] - TableScan: person -"# + @r" + Projection: sum(person.age) AS total_sum, person.state, person.last_name, grouping(person.state) + grouping(person.last_name) AS x, rank() PARTITION BY [grouping(person.state) + grouping(person.last_name), CASE WHEN grouping(person.last_name) = Int64(0) THEN person.state END] ORDER BY [sum(person.age) DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS the_rank + WindowAggr: windowExpr=[[rank() PARTITION BY [grouping(person.state) + grouping(person.last_name), CASE WHEN grouping(person.last_name) = Int64(0) THEN person.state END] ORDER BY [sum(person.age) DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + Aggregate: groupBy=[[ROLLUP (person.state, person.last_name)]], aggr=[[sum(person.age), grouping(person.state), grouping(person.last_name)]] + TableScan: person + " ); } @@ -3777,11 +3693,11 @@ fn aggregate_with_cube() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.state, person.age, count(*) - Aggregate: groupBy=[[GROUPING SETS ((person.id), (person.id, person.state), (person.id, person.age), (person.id, person.state, person.age))]], aggr=[[count(*)]] - TableScan: person -"# + @r" + Projection: person.id, person.state, person.age, count(*) + Aggregate: groupBy=[[GROUPING SETS ((person.id), (person.id, person.state), (person.id, person.age), (person.id, person.state, person.age))]], aggr=[[count(*)]] + TableScan: person + " ); } @@ -3791,10 +3707,10 @@ fn round_decimal() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: round(test_decimal.price / Int64(3), Int64(2)) - TableScan: test_decimal -"# + @r" + Projection: round(test_decimal.price / Int64(3), Int64(2)) + TableScan: test_decimal + " ); } @@ -3804,11 +3720,11 @@ fn aggregate_with_grouping_sets() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.state, person.age, count(*) - Aggregate: groupBy=[[GROUPING SETS ((person.id, person.state), (person.id, person.state, person.age), (person.id, person.id, person.state))]], aggr=[[count(*)]] - TableScan: person -"# + @r" + Projection: person.id, person.state, person.age, count(*) + Aggregate: groupBy=[[GROUPING SETS ((person.id, person.state), (person.id, person.state, person.age), (person.id, person.id, person.state))]], aggr=[[count(*)]] + TableScan: person + " ); } @@ -3820,12 +3736,12 @@ fn join_on_disjunction_condition() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id OR person.age > Int64(30) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Inner Join: Filter: person.id = orders.customer_id OR person.age > Int64(30) + TableScan: person + TableScan: orders + " ); } @@ -3838,11 +3754,11 @@ fn join_on_complex_condition() { assert_snapshot!( plan, @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id AND (person.age > Int64(30) OR person.last_name = Utf8("X")) - TableScan: person - TableScan: orders -"# + Projection: person.id, orders.order_id + Inner Join: Filter: person.id = orders.customer_id AND (person.age > Int64(30) OR person.last_name = Utf8("X")) + TableScan: person + TableScan: orders + "# ); } @@ -3854,11 +3770,11 @@ fn hive_aggregate_with_filter() -> Result<()> { assert_snapshot!( plan, - @r##" - Projection: sum(person.age) FILTER (WHERE person.age > Int64(4)) - Aggregate: groupBy=[[]], aggr=[[sum(person.age) FILTER (WHERE person.age > Int64(4))]] - TableScan: person - "## + @r" + Projection: sum(person.age) FILTER (WHERE person.age > Int64(4)) + Aggregate: groupBy=[[]], aggr=[[sum(person.age) FILTER (WHERE person.age > Int64(4))]] + TableScan: person + " ); Ok(()) @@ -3874,13 +3790,13 @@ fn order_by_unaliased_name() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Sort: z ASC NULLS LAST - Projection: p.state AS z, sum(p.age) AS q - Aggregate: groupBy=[[p.state]], aggr=[[sum(p.age)]] - SubqueryAlias: p - TableScan: person -"# + @r" + Sort: z ASC NULLS LAST + Projection: p.state AS z, sum(p.age) AS q + Aggregate: groupBy=[[p.state]], aggr=[[sum(p.age)]] + SubqueryAlias: p + TableScan: person + " ); } @@ -3891,9 +3807,7 @@ fn order_by_ambiguous_name() { assert_snapshot!( err, - @r###" - Schema error: Ambiguous reference to unqualified field age - "### + @"Schema error: Ambiguous reference to unqualified field age" ); } @@ -3904,9 +3818,7 @@ fn group_by_ambiguous_name() { assert_snapshot!( err, - @r###" - Schema error: Ambiguous reference to unqualified field age - "### + @"Schema error: Ambiguous reference to unqualified field age" ); } @@ -3916,24 +3828,24 @@ fn test_zero_offset_with_limit() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Limit: skip=0, fetch=5 - Projection: person.id - Filter: person.id > Int64(100) - TableScan: person -"# + @r" + Limit: skip=0, fetch=5 + Projection: person.id + Filter: person.id > Int64(100) + TableScan: person + " ); // Flip the order of LIMIT and OFFSET in the query. Plan should remain the same. let sql = "SELECT id FROM person WHERE person.id > 100 OFFSET 0 LIMIT 5;"; let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Limit: skip=0, fetch=5 - Projection: person.id - Filter: person.id > Int64(100) - TableScan: person -"# + @r" + Limit: skip=0, fetch=5 + Projection: person.id + Filter: person.id > Int64(100) + TableScan: person + " ); } @@ -3943,12 +3855,12 @@ fn test_offset_no_limit() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Limit: skip=5, fetch=None - Projection: person.id - Filter: person.id > Int64(100) - TableScan: person -"# + @r" + Limit: skip=5, fetch=None + Projection: person.id + Filter: person.id > Int64(100) + TableScan: person + " ); } @@ -3958,12 +3870,12 @@ fn test_offset_after_limit() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Limit: skip=3, fetch=5 - Projection: person.id - Filter: person.id > Int64(100) - TableScan: person -"# + @r" + Limit: skip=3, fetch=5 + Projection: person.id + Filter: person.id > Int64(100) + TableScan: person + " ); } @@ -3980,12 +3892,12 @@ fn test_offset_before_limit() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Limit: skip=3, fetch=5 - Projection: person.id - Filter: person.id > Int64(100) - TableScan: person -"# + @r" + Limit: skip=3, fetch=5 + Projection: person.id + Filter: person.id > Int64(100) + TableScan: person + " ); } @@ -3995,11 +3907,11 @@ fn test_distribute_by() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Repartition: DistributeBy(person.state) - Projection: person.id - TableScan: person -"# + @r" + Repartition: DistributeBy(person.state) + Projection: person.id + TableScan: person + " ); } @@ -4031,12 +3943,12 @@ fn test_constant_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: person.id = Int64(10) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Inner Join: Filter: person.id = Int64(10) + TableScan: person + TableScan: orders + " ); } @@ -4049,12 +3961,12 @@ fn test_right_left_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: orders.customer_id * Int64(2) = person.id + Int64(10) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Inner Join: Filter: orders.customer_id * Int64(2) = person.id + Int64(10) + TableScan: person + TableScan: orders + " ); } @@ -4067,12 +3979,12 @@ fn test_single_column_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: person.id + Int64(10) = orders.customer_id * Int64(2) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Inner Join: Filter: person.id + Int64(10) = orders.customer_id * Int64(2) + TableScan: person + TableScan: orders + " ); } @@ -4085,12 +3997,12 @@ fn test_multiple_column_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: person.id + person.age + Int64(10) = orders.customer_id * Int64(2) - orders.price - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Inner Join: Filter: person.id + person.age + Int64(10) = orders.customer_id * Int64(2) - orders.price + TableScan: person + TableScan: orders + " ); } @@ -4103,12 +4015,12 @@ fn test_left_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: person.id + person.age + Int64(10) = orders.customer_id - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Inner Join: Filter: person.id + person.age + Int64(10) = orders.customer_id + TableScan: person + TableScan: orders + " ); } @@ -4121,12 +4033,12 @@ fn test_right_expr_eq_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Inner Join: Filter: person.id = orders.customer_id * Int64(2) - orders.price - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Inner Join: Filter: person.id = orders.customer_id * Int64(2) - orders.price + TableScan: person + TableScan: orders + " ); } @@ -4139,12 +4051,12 @@ fn test_noneq_with_filter_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.first_name - Inner Join: Filter: person.age > Int64(10) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, person.first_name + Inner Join: Filter: person.age > Int64(10) + TableScan: person + TableScan: orders + " ); // left join let sql = "SELECT person.id, person.first_name \ @@ -4153,12 +4065,12 @@ Projection: person.id, person.first_name let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.first_name - Left Join: Filter: person.age > Int64(10) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, person.first_name + Left Join: Filter: person.age > Int64(10) + TableScan: person + TableScan: orders + " ); // right join let sql = "SELECT person.id, person.first_name \ @@ -4167,12 +4079,12 @@ Projection: person.id, person.first_name let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.first_name - Right Join: Filter: person.age > Int64(10) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, person.first_name + Right Join: Filter: person.age > Int64(10) + TableScan: person + TableScan: orders + " ); // full join let sql = "SELECT person.id, person.first_name \ @@ -4181,12 +4093,12 @@ Projection: person.id, person.first_name let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.first_name - Full Join: Filter: person.age > Int64(10) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, person.first_name + Full Join: Filter: person.age > Int64(10) + TableScan: person + TableScan: orders + " ); } @@ -4201,12 +4113,12 @@ fn test_one_side_constant_full_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, orders.order_id - Full Join: Filter: person.id = Int64(10) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, orders.order_id + Full Join: Filter: person.id = Int64(10) + TableScan: person + TableScan: orders + " ); } @@ -4219,12 +4131,12 @@ fn test_select_join_key_inner_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.customer_id * Int64(2), person.id + Int64(10) - Inner Join: Filter: orders.customer_id * Int64(2) = person.id + Int64(10) - TableScan: person - TableScan: orders -"# + @r" + Projection: orders.customer_id * Int64(2), person.id + Int64(10) + Inner Join: Filter: orders.customer_id * Int64(2) = person.id + Int64(10) + TableScan: person + TableScan: orders + " ); } @@ -4235,11 +4147,11 @@ fn test_select_order_by() { assert_snapshot!( plan, @r#" -Projection: Utf8("1") - Sort: person.id ASC NULLS LAST - Projection: Utf8("1"), person.id - TableScan: person -"# + Projection: Utf8("1") + Sort: person.id ASC NULLS LAST + Projection: Utf8("1"), person.id + TableScan: person + "# ); } @@ -4254,9 +4166,7 @@ fn test_select_distinct_order_by() { assert_snapshot!( err, - @r###" - Error during planning: For SELECT DISTINCT, ORDER BY expressions person.id must appear in select list - "### + @"Error during planning: For SELECT DISTINCT, ORDER BY expressions person.id must appear in select list" ); } @@ -4266,12 +4176,12 @@ fn test_select_qualify_basic() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rn - Filter: row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW = Int64(1) - WindowAggr: windowExpr=[[row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: person -"# + @r" + Projection: person.id, row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rn + Filter: row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW = Int64(1) + WindowAggr: windowExpr=[[row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: person + " ); } @@ -4352,13 +4262,13 @@ fn test_select_qualify_complex_condition() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.age, row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rn, rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rank - Filter: row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW <= Int64(2) AND rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW <= Int64(5) - WindowAggr: windowExpr=[[rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: person -"# + @r" + Projection: person.id, person.age, row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rn, rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rank + Filter: row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW <= Int64(2) AND rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW <= Int64(5) + WindowAggr: windowExpr=[[rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: person + " ); } @@ -4391,12 +4301,12 @@ fn select_order_by_with_cast() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Sort: CAST(person.first_name AS Int32) ASC NULLS LAST - Projection: person.first_name - Projection: person.first_name - TableScan: person -"# + @r" + Sort: CAST(person.first_name AS Int32) ASC NULLS LAST + Projection: person.first_name + Projection: person.first_name + TableScan: person + " ); } @@ -4421,12 +4331,12 @@ fn test_duplicated_left_join_key_inner_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.age - Inner Join: Filter: person.id * Int64(2) = orders.customer_id + Int64(10) AND person.id * Int64(2) = orders.order_id - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, person.age + Inner Join: Filter: person.id * Int64(2) = orders.customer_id + Int64(10) AND person.id * Int64(2) = orders.order_id + TableScan: person + TableScan: orders + " ); } @@ -4440,12 +4350,12 @@ fn test_duplicated_right_join_key_inner_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.age - Inner Join: Filter: person.id * Int64(2) = orders.customer_id + Int64(10) AND person.id = orders.customer_id + Int64(10) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, person.age + Inner Join: Filter: person.id * Int64(2) = orders.customer_id + Int64(10) AND person.id = orders.customer_id + Int64(10) + TableScan: person + TableScan: orders + " ); } @@ -4463,9 +4373,7 @@ fn test_ambiguous_column_references_in_on_join() { assert_snapshot!( err, - @r###" - Schema error: Ambiguous reference to unqualified field id - "### + @"Schema error: Ambiguous reference to unqualified field id" ); } @@ -4478,14 +4386,14 @@ fn test_ambiguous_column_references_with_in_using_join() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: p1.id, p1.age, p2.id - Inner Join: Using p1.id = p2.id - SubqueryAlias: p1 - TableScan: person - SubqueryAlias: p2 - TableScan: person -"# + @r" + Projection: p1.id, p1.age, p2.id + Inner Join: Using p1.id = p2.id + SubqueryAlias: p1 + TableScan: person + SubqueryAlias: p2 + TableScan: person + " ); } @@ -4498,12 +4406,12 @@ fn test_inner_join_with_cast_key() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.age - Inner Join: Filter: CAST(person.id AS Int32) = CAST(orders.customer_id AS Int32) - TableScan: person - TableScan: orders -"# + @r" + Projection: person.id, person.age + Inner Join: Filter: CAST(person.id AS Int32) = CAST(orders.customer_id AS Int32) + TableScan: person + TableScan: orders + " ); } @@ -4517,11 +4425,11 @@ fn test_multi_grouping_sets() { let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.age - Aggregate: groupBy=[[GROUPING SETS ((person.id, person.age, person.salary), (person.id, person.age))]], aggr=[[]] - TableScan: person -"# + @r" + Projection: person.id, person.age + Aggregate: groupBy=[[GROUPING SETS ((person.id, person.age, person.salary), (person.id, person.age))]], aggr=[[]] + TableScan: person + " ); let sql = "SELECT person.id, person.age FROM person @@ -4532,11 +4440,11 @@ Projection: person.id, person.age let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: person.id, person.age - Aggregate: groupBy=[[GROUPING SETS ((person.id, person.age, person.salary), (person.id, person.age, person.salary, person.state), (person.id, person.age, person.salary, person.state, person.birth_date), (person.id, person.age), (person.id, person.age, person.state), (person.id, person.age, person.state, person.birth_date))]], aggr=[[]] - TableScan: person -"# + @r" + Projection: person.id, person.age + Aggregate: groupBy=[[GROUPING SETS ((person.id, person.age, person.salary), (person.id, person.age, person.salary, person.state), (person.id, person.age, person.salary, person.state, person.birth_date), (person.id, person.age), (person.id, person.age, person.state), (person.id, person.age, person.state, person.birth_date))]], aggr=[[]] + TableScan: person + " ); } @@ -4549,9 +4457,7 @@ fn test_field_not_found_window_function() { assert_snapshot!( order_by_err, - @r###" - Schema error: No field named a. - "### + @"Schema error: No field named a." ); let partition_by_sql = "SELECT count() OVER (PARTITION BY a);"; @@ -4561,20 +4467,18 @@ fn test_field_not_found_window_function() { assert_snapshot!( partition_by_err, - @r###" - Schema error: No field named a. - "### + @"Schema error: No field named a." ); let sql = "SELECT order_id, MAX(qty) OVER (PARTITION BY orders.order_id) from orders"; let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, - @r#" -Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - TableScan: orders -"# + @r" + Projection: orders.order_id, max(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + WindowAggr: windowExpr=[[max(orders.qty) PARTITION BY [orders.order_id] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + TableScan: orders + " ); } @@ -4611,9 +4515,7 @@ fn test_parse_escaped_string_literal_value() { assert_snapshot!( logical_plan(sql).unwrap_err(), - @r###" - SQL error: TokenizerError("Unterminated encoded string literal at Line: 1, Column: 25") - "### + @r#"SQL error: TokenizerError("Unterminated encoded string literal at Line: 1, Column: 25")"# ); } diff --git a/datafusion/substrait/tests/cases/aggregation_tests.rs b/datafusion/substrait/tests/cases/aggregation_tests.rs index 815550bca5b89..92a41850b208d 100644 --- a/datafusion/substrait/tests/cases/aggregation_tests.rs +++ b/datafusion/substrait/tests/cases/aggregation_tests.rs @@ -35,10 +35,10 @@ mod tests { assert_snapshot!( plan, - @r#" - Aggregate: groupBy=[[]], aggr=[[sum(c0) AS summation]] - EmptyRelation: rows=0 - "# + @r" + Aggregate: groupBy=[[]], aggr=[[sum(c0) AS summation]] + EmptyRelation: rows=0 + " ); // Trigger execution to ensure plan validity @@ -57,10 +57,10 @@ mod tests { assert_snapshot!( plan, - @r#" - Aggregate: groupBy=[[c0]], aggr=[[sum(c0) AS summation]] - EmptyRelation: rows=0 - "# + @r" + Aggregate: groupBy=[[c0]], aggr=[[sum(c0) AS summation]] + EmptyRelation: rows=0 + " ); // Trigger execution to ensure plan validity diff --git a/datafusion/substrait/tests/cases/consumer_integration.rs b/datafusion/substrait/tests/cases/consumer_integration.rs index a92fc2957cae3..194098cf060e3 100644 --- a/datafusion/substrait/tests/cases/consumer_integration.rs +++ b/datafusion/substrait/tests/cases/consumer_integration.rs @@ -53,13 +53,13 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: LINEITEM.L_RETURNFLAG, LINEITEM.L_LINESTATUS, sum(LINEITEM.L_QUANTITY) AS SUM_QTY, sum(LINEITEM.L_EXTENDEDPRICE) AS SUM_BASE_PRICE, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS SUM_DISC_PRICE, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT * Int32(1) + LINEITEM.L_TAX) AS SUM_CHARGE, avg(LINEITEM.L_QUANTITY) AS AVG_QTY, avg(LINEITEM.L_EXTENDEDPRICE) AS AVG_PRICE, avg(LINEITEM.L_DISCOUNT) AS AVG_DISC, count(Int64(1)) AS COUNT_ORDER - Sort: LINEITEM.L_RETURNFLAG ASC NULLS LAST, LINEITEM.L_LINESTATUS ASC NULLS LAST - Aggregate: groupBy=[[LINEITEM.L_RETURNFLAG, LINEITEM.L_LINESTATUS]], aggr=[[sum(LINEITEM.L_QUANTITY), sum(LINEITEM.L_EXTENDEDPRICE), sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT), sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT * Int32(1) + LINEITEM.L_TAX), avg(LINEITEM.L_QUANTITY), avg(LINEITEM.L_EXTENDEDPRICE), avg(LINEITEM.L_DISCOUNT), count(Int64(1))]] - Projection: LINEITEM.L_RETURNFLAG, LINEITEM.L_LINESTATUS, LINEITEM.L_QUANTITY, LINEITEM.L_EXTENDEDPRICE, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT), LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) * (CAST(Int32(1) AS Decimal128(15, 2)) + LINEITEM.L_TAX), LINEITEM.L_DISCOUNT - Filter: LINEITEM.L_SHIPDATE <= Date32("1998-12-01") - IntervalDayTime("IntervalDayTime { days: 0, milliseconds: 10368000 }") - TableScan: LINEITEM - "# + Projection: LINEITEM.L_RETURNFLAG, LINEITEM.L_LINESTATUS, sum(LINEITEM.L_QUANTITY) AS SUM_QTY, sum(LINEITEM.L_EXTENDEDPRICE) AS SUM_BASE_PRICE, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS SUM_DISC_PRICE, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT * Int32(1) + LINEITEM.L_TAX) AS SUM_CHARGE, avg(LINEITEM.L_QUANTITY) AS AVG_QTY, avg(LINEITEM.L_EXTENDEDPRICE) AS AVG_PRICE, avg(LINEITEM.L_DISCOUNT) AS AVG_DISC, count(Int64(1)) AS COUNT_ORDER + Sort: LINEITEM.L_RETURNFLAG ASC NULLS LAST, LINEITEM.L_LINESTATUS ASC NULLS LAST + Aggregate: groupBy=[[LINEITEM.L_RETURNFLAG, LINEITEM.L_LINESTATUS]], aggr=[[sum(LINEITEM.L_QUANTITY), sum(LINEITEM.L_EXTENDEDPRICE), sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT), sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT * Int32(1) + LINEITEM.L_TAX), avg(LINEITEM.L_QUANTITY), avg(LINEITEM.L_EXTENDEDPRICE), avg(LINEITEM.L_DISCOUNT), count(Int64(1))]] + Projection: LINEITEM.L_RETURNFLAG, LINEITEM.L_LINESTATUS, LINEITEM.L_QUANTITY, LINEITEM.L_EXTENDEDPRICE, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT), LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) * (CAST(Int32(1) AS Decimal128(15, 2)) + LINEITEM.L_TAX), LINEITEM.L_DISCOUNT + Filter: LINEITEM.L_SHIPDATE <= Date32("1998-12-01") - IntervalDayTime("IntervalDayTime { days: 0, milliseconds: 10368000 }") + TableScan: LINEITEM + "# ); Ok(()) } @@ -70,31 +70,31 @@ mod tests { assert_snapshot!( plan_str, @r#" - Limit: skip=0, fetch=100 - Sort: SUPPLIER.S_ACCTBAL DESC NULLS FIRST, NATION.N_NAME ASC NULLS LAST, SUPPLIER.S_NAME ASC NULLS LAST, PART.P_PARTKEY ASC NULLS LAST - Projection: SUPPLIER.S_ACCTBAL, SUPPLIER.S_NAME, NATION.N_NAME, PART.P_PARTKEY, PART.P_MFGR, SUPPLIER.S_ADDRESS, SUPPLIER.S_PHONE, SUPPLIER.S_COMMENT - Filter: PART.P_PARTKEY = PARTSUPP.PS_PARTKEY AND SUPPLIER.S_SUPPKEY = PARTSUPP.PS_SUPPKEY AND PART.P_SIZE = Int32(15) AND PART.P_TYPE LIKE CAST(Utf8("%BRASS") AS Utf8) AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_REGIONKEY = REGION.R_REGIONKEY AND REGION.R_NAME = Utf8("EUROPE") AND PARTSUPP.PS_SUPPLYCOST = () - Subquery: - Aggregate: groupBy=[[]], aggr=[[min(PARTSUPP.PS_SUPPLYCOST)]] - Projection: PARTSUPP.PS_SUPPLYCOST - Filter: PARTSUPP.PS_PARTKEY = PARTSUPP.PS_PARTKEY AND SUPPLIER.S_SUPPKEY = PARTSUPP.PS_SUPPKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_REGIONKEY = REGION.R_REGIONKEY AND REGION.R_NAME = Utf8("EUROPE") + Limit: skip=0, fetch=100 + Sort: SUPPLIER.S_ACCTBAL DESC NULLS FIRST, NATION.N_NAME ASC NULLS LAST, SUPPLIER.S_NAME ASC NULLS LAST, PART.P_PARTKEY ASC NULLS LAST + Projection: SUPPLIER.S_ACCTBAL, SUPPLIER.S_NAME, NATION.N_NAME, PART.P_PARTKEY, PART.P_MFGR, SUPPLIER.S_ADDRESS, SUPPLIER.S_PHONE, SUPPLIER.S_COMMENT + Filter: PART.P_PARTKEY = PARTSUPP.PS_PARTKEY AND SUPPLIER.S_SUPPKEY = PARTSUPP.PS_SUPPKEY AND PART.P_SIZE = Int32(15) AND PART.P_TYPE LIKE CAST(Utf8("%BRASS") AS Utf8) AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_REGIONKEY = REGION.R_REGIONKEY AND REGION.R_NAME = Utf8("EUROPE") AND PARTSUPP.PS_SUPPLYCOST = () + Subquery: + Aggregate: groupBy=[[]], aggr=[[min(PARTSUPP.PS_SUPPLYCOST)]] + Projection: PARTSUPP.PS_SUPPLYCOST + Filter: PARTSUPP.PS_PARTKEY = PARTSUPP.PS_PARTKEY AND SUPPLIER.S_SUPPKEY = PARTSUPP.PS_SUPPKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_REGIONKEY = REGION.R_REGIONKEY AND REGION.R_NAME = Utf8("EUROPE") + Cross Join: + Cross Join: Cross Join: - Cross Join: - Cross Join: - TableScan: PARTSUPP - TableScan: SUPPLIER - TableScan: NATION - TableScan: REGION + TableScan: PARTSUPP + TableScan: SUPPLIER + TableScan: NATION + TableScan: REGION + Cross Join: + Cross Join: Cross Join: Cross Join: - Cross Join: - Cross Join: - TableScan: PART - TableScan: SUPPLIER - TableScan: PARTSUPP - TableScan: NATION - TableScan: REGION - "# + TableScan: PART + TableScan: SUPPLIER + TableScan: PARTSUPP + TableScan: NATION + TableScan: REGION + "# ); Ok(()) } @@ -105,19 +105,19 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: LINEITEM.L_ORDERKEY, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS REVENUE, ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY - Limit: skip=0, fetch=10 - Sort: sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) DESC NULLS FIRST, ORDERS.O_ORDERDATE ASC NULLS LAST - Projection: LINEITEM.L_ORDERKEY, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT), ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY - Aggregate: groupBy=[[LINEITEM.L_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] - Projection: LINEITEM.L_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) - Filter: CUSTOMER.C_MKTSEGMENT = Utf8("BUILDING") AND CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY AND ORDERS.O_ORDERDATE < CAST(Utf8("1995-03-15") AS Date32) AND LINEITEM.L_SHIPDATE > CAST(Utf8("1995-03-15") AS Date32) - Cross Join: - Cross Join: - TableScan: LINEITEM - TableScan: CUSTOMER - TableScan: ORDERS - "# + Projection: LINEITEM.L_ORDERKEY, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS REVENUE, ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY + Limit: skip=0, fetch=10 + Sort: sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) DESC NULLS FIRST, ORDERS.O_ORDERDATE ASC NULLS LAST + Projection: LINEITEM.L_ORDERKEY, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT), ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY + Aggregate: groupBy=[[LINEITEM.L_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] + Projection: LINEITEM.L_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_SHIPPRIORITY, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) + Filter: CUSTOMER.C_MKTSEGMENT = Utf8("BUILDING") AND CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY AND ORDERS.O_ORDERDATE < CAST(Utf8("1995-03-15") AS Date32) AND LINEITEM.L_SHIPDATE > CAST(Utf8("1995-03-15") AS Date32) + Cross Join: + Cross Join: + TableScan: LINEITEM + TableScan: CUSTOMER + TableScan: ORDERS + "# ); Ok(()) } @@ -128,16 +128,16 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: ORDERS.O_ORDERPRIORITY, count(Int64(1)) AS ORDER_COUNT - Sort: ORDERS.O_ORDERPRIORITY ASC NULLS LAST - Aggregate: groupBy=[[ORDERS.O_ORDERPRIORITY]], aggr=[[count(Int64(1))]] - Projection: ORDERS.O_ORDERPRIORITY - Filter: ORDERS.O_ORDERDATE >= CAST(Utf8("1993-07-01") AS Date32) AND ORDERS.O_ORDERDATE < CAST(Utf8("1993-10-01") AS Date32) AND EXISTS () - Subquery: - Filter: LINEITEM.L_ORDERKEY = LINEITEM.L_ORDERKEY AND LINEITEM.L_COMMITDATE < LINEITEM.L_RECEIPTDATE - TableScan: LINEITEM - TableScan: ORDERS - "# + Projection: ORDERS.O_ORDERPRIORITY, count(Int64(1)) AS ORDER_COUNT + Sort: ORDERS.O_ORDERPRIORITY ASC NULLS LAST + Aggregate: groupBy=[[ORDERS.O_ORDERPRIORITY]], aggr=[[count(Int64(1))]] + Projection: ORDERS.O_ORDERPRIORITY + Filter: ORDERS.O_ORDERDATE >= CAST(Utf8("1993-07-01") AS Date32) AND ORDERS.O_ORDERDATE < CAST(Utf8("1993-10-01") AS Date32) AND EXISTS () + Subquery: + Filter: LINEITEM.L_ORDERKEY = LINEITEM.L_ORDERKEY AND LINEITEM.L_COMMITDATE < LINEITEM.L_RECEIPTDATE + TableScan: LINEITEM + TableScan: ORDERS + "# ); Ok(()) } @@ -148,23 +148,23 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: NATION.N_NAME, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS REVENUE - Sort: sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) DESC NULLS FIRST - Aggregate: groupBy=[[NATION.N_NAME]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] - Projection: NATION.N_NAME, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) - Filter: CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY AND LINEITEM.L_SUPPKEY = SUPPLIER.S_SUPPKEY AND CUSTOMER.C_NATIONKEY = SUPPLIER.S_NATIONKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_REGIONKEY = REGION.R_REGIONKEY AND REGION.R_NAME = Utf8("ASIA") AND ORDERS.O_ORDERDATE >= CAST(Utf8("1994-01-01") AS Date32) AND ORDERS.O_ORDERDATE < CAST(Utf8("1995-01-01") AS Date32) + Projection: NATION.N_NAME, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS REVENUE + Sort: sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) DESC NULLS FIRST + Aggregate: groupBy=[[NATION.N_NAME]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] + Projection: NATION.N_NAME, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) + Filter: CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY AND LINEITEM.L_SUPPKEY = SUPPLIER.S_SUPPKEY AND CUSTOMER.C_NATIONKEY = SUPPLIER.S_NATIONKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_REGIONKEY = REGION.R_REGIONKEY AND REGION.R_NAME = Utf8("ASIA") AND ORDERS.O_ORDERDATE >= CAST(Utf8("1994-01-01") AS Date32) AND ORDERS.O_ORDERDATE < CAST(Utf8("1995-01-01") AS Date32) + Cross Join: + Cross Join: Cross Join: Cross Join: Cross Join: - Cross Join: - Cross Join: - TableScan: CUSTOMER - TableScan: ORDERS - TableScan: LINEITEM - TableScan: SUPPLIER - TableScan: NATION - TableScan: REGION - "# + TableScan: CUSTOMER + TableScan: ORDERS + TableScan: LINEITEM + TableScan: SUPPLIER + TableScan: NATION + TableScan: REGION + "# ); Ok(()) } @@ -175,11 +175,11 @@ mod tests { assert_snapshot!( plan_str, @r#" - Aggregate: groupBy=[[]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * LINEITEM.L_DISCOUNT) AS REVENUE]] - Projection: LINEITEM.L_EXTENDEDPRICE * LINEITEM.L_DISCOUNT - Filter: LINEITEM.L_SHIPDATE >= CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_SHIPDATE < CAST(Utf8("1995-01-01") AS Date32) AND LINEITEM.L_DISCOUNT >= Decimal128(Some(5),3,2) AND LINEITEM.L_DISCOUNT <= Decimal128(Some(7),3,2) AND LINEITEM.L_QUANTITY < CAST(Int32(24) AS Decimal128(15, 2)) - TableScan: LINEITEM - "# + Aggregate: groupBy=[[]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * LINEITEM.L_DISCOUNT) AS REVENUE]] + Projection: LINEITEM.L_EXTENDEDPRICE * LINEITEM.L_DISCOUNT + Filter: LINEITEM.L_SHIPDATE >= CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_SHIPDATE < CAST(Utf8("1995-01-01") AS Date32) AND LINEITEM.L_DISCOUNT >= Decimal128(Some(5),3,2) AND LINEITEM.L_DISCOUNT <= Decimal128(Some(7),3,2) AND LINEITEM.L_QUANTITY < CAST(Int32(24) AS Decimal128(15, 2)) + TableScan: LINEITEM + "# ); Ok(()) } @@ -214,21 +214,21 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS REVENUE, CUSTOMER.C_ACCTBAL, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_PHONE, CUSTOMER.C_COMMENT - Limit: skip=0, fetch=20 - Sort: sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) DESC NULLS FIRST - Projection: CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT), CUSTOMER.C_ACCTBAL, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_PHONE, CUSTOMER.C_COMMENT - Aggregate: groupBy=[[CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, CUSTOMER.C_ACCTBAL, CUSTOMER.C_PHONE, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_COMMENT]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] - Projection: CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, CUSTOMER.C_ACCTBAL, CUSTOMER.C_PHONE, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_COMMENT, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) - Filter: CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY AND ORDERS.O_ORDERDATE >= CAST(Utf8("1993-10-01") AS Date32) AND ORDERS.O_ORDERDATE < CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_RETURNFLAG = Utf8("R") AND CUSTOMER.C_NATIONKEY = NATION.N_NATIONKEY + Projection: CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS REVENUE, CUSTOMER.C_ACCTBAL, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_PHONE, CUSTOMER.C_COMMENT + Limit: skip=0, fetch=20 + Sort: sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) DESC NULLS FIRST + Projection: CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT), CUSTOMER.C_ACCTBAL, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_PHONE, CUSTOMER.C_COMMENT + Aggregate: groupBy=[[CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, CUSTOMER.C_ACCTBAL, CUSTOMER.C_PHONE, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_COMMENT]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] + Projection: CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, CUSTOMER.C_ACCTBAL, CUSTOMER.C_PHONE, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_COMMENT, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) + Filter: CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY AND ORDERS.O_ORDERDATE >= CAST(Utf8("1993-10-01") AS Date32) AND ORDERS.O_ORDERDATE < CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_RETURNFLAG = Utf8("R") AND CUSTOMER.C_NATIONKEY = NATION.N_NATIONKEY + Cross Join: + Cross Join: Cross Join: - Cross Join: - Cross Join: - TableScan: CUSTOMER - TableScan: ORDERS - TableScan: LINEITEM - TableScan: NATION - "# + TableScan: CUSTOMER + TableScan: ORDERS + TableScan: LINEITEM + TableScan: NATION + "# ); Ok(()) } @@ -239,28 +239,28 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: PARTSUPP.PS_PARTKEY, sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY) AS value - Sort: sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY) DESC NULLS FIRST - Filter: sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY) > () - Subquery: - Projection: sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY) * Decimal128(Some(1000000),11,10) - Aggregate: groupBy=[[]], aggr=[[sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY)]] - Projection: PARTSUPP.PS_SUPPLYCOST * CAST(PARTSUPP.PS_AVAILQTY AS Decimal128(19, 0)) - Filter: PARTSUPP.PS_SUPPKEY = SUPPLIER.S_SUPPKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_NAME = Utf8("JAPAN") - Cross Join: - Cross Join: - TableScan: PARTSUPP - TableScan: SUPPLIER - TableScan: NATION - Aggregate: groupBy=[[PARTSUPP.PS_PARTKEY]], aggr=[[sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY)]] - Projection: PARTSUPP.PS_PARTKEY, PARTSUPP.PS_SUPPLYCOST * CAST(PARTSUPP.PS_AVAILQTY AS Decimal128(19, 0)) + Projection: PARTSUPP.PS_PARTKEY, sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY) AS value + Sort: sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY) DESC NULLS FIRST + Filter: sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY) > () + Subquery: + Projection: sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY) * Decimal128(Some(1000000),11,10) + Aggregate: groupBy=[[]], aggr=[[sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY)]] + Projection: PARTSUPP.PS_SUPPLYCOST * CAST(PARTSUPP.PS_AVAILQTY AS Decimal128(19, 0)) Filter: PARTSUPP.PS_SUPPKEY = SUPPLIER.S_SUPPKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_NAME = Utf8("JAPAN") Cross Join: Cross Join: TableScan: PARTSUPP TableScan: SUPPLIER TableScan: NATION - "# + Aggregate: groupBy=[[PARTSUPP.PS_PARTKEY]], aggr=[[sum(PARTSUPP.PS_SUPPLYCOST * PARTSUPP.PS_AVAILQTY)]] + Projection: PARTSUPP.PS_PARTKEY, PARTSUPP.PS_SUPPLYCOST * CAST(PARTSUPP.PS_AVAILQTY AS Decimal128(19, 0)) + Filter: PARTSUPP.PS_SUPPKEY = SUPPLIER.S_SUPPKEY AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_NAME = Utf8("JAPAN") + Cross Join: + Cross Join: + TableScan: PARTSUPP + TableScan: SUPPLIER + TableScan: NATION + "# ); Ok(()) } @@ -271,15 +271,15 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: LINEITEM.L_SHIPMODE, sum(CASE WHEN ORDERS.O_ORDERPRIORITY = Utf8("1-URGENT") OR ORDERS.O_ORDERPRIORITY = Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END) AS HIGH_LINE_COUNT, sum(CASE WHEN ORDERS.O_ORDERPRIORITY != Utf8("1-URGENT") AND ORDERS.O_ORDERPRIORITY != Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END) AS LOW_LINE_COUNT - Sort: LINEITEM.L_SHIPMODE ASC NULLS LAST - Aggregate: groupBy=[[LINEITEM.L_SHIPMODE]], aggr=[[sum(CASE WHEN ORDERS.O_ORDERPRIORITY = Utf8("1-URGENT") OR ORDERS.O_ORDERPRIORITY = Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END), sum(CASE WHEN ORDERS.O_ORDERPRIORITY != Utf8("1-URGENT") AND ORDERS.O_ORDERPRIORITY != Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END)]] - Projection: LINEITEM.L_SHIPMODE, CASE WHEN ORDERS.O_ORDERPRIORITY = Utf8("1-URGENT") OR ORDERS.O_ORDERPRIORITY = Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END, CASE WHEN ORDERS.O_ORDERPRIORITY != Utf8("1-URGENT") AND ORDERS.O_ORDERPRIORITY != Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END - Filter: ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY AND (LINEITEM.L_SHIPMODE = CAST(Utf8("MAIL") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("SHIP") AS Utf8)) AND LINEITEM.L_COMMITDATE < LINEITEM.L_RECEIPTDATE AND LINEITEM.L_SHIPDATE < LINEITEM.L_COMMITDATE AND LINEITEM.L_RECEIPTDATE >= CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_RECEIPTDATE < CAST(Utf8("1995-01-01") AS Date32) - Cross Join: - TableScan: ORDERS - TableScan: LINEITEM - "# + Projection: LINEITEM.L_SHIPMODE, sum(CASE WHEN ORDERS.O_ORDERPRIORITY = Utf8("1-URGENT") OR ORDERS.O_ORDERPRIORITY = Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END) AS HIGH_LINE_COUNT, sum(CASE WHEN ORDERS.O_ORDERPRIORITY != Utf8("1-URGENT") AND ORDERS.O_ORDERPRIORITY != Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END) AS LOW_LINE_COUNT + Sort: LINEITEM.L_SHIPMODE ASC NULLS LAST + Aggregate: groupBy=[[LINEITEM.L_SHIPMODE]], aggr=[[sum(CASE WHEN ORDERS.O_ORDERPRIORITY = Utf8("1-URGENT") OR ORDERS.O_ORDERPRIORITY = Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END), sum(CASE WHEN ORDERS.O_ORDERPRIORITY != Utf8("1-URGENT") AND ORDERS.O_ORDERPRIORITY != Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END)]] + Projection: LINEITEM.L_SHIPMODE, CASE WHEN ORDERS.O_ORDERPRIORITY = Utf8("1-URGENT") OR ORDERS.O_ORDERPRIORITY = Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END, CASE WHEN ORDERS.O_ORDERPRIORITY != Utf8("1-URGENT") AND ORDERS.O_ORDERPRIORITY != Utf8("2-HIGH") THEN Int32(1) ELSE Int32(0) END + Filter: ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY AND (LINEITEM.L_SHIPMODE = CAST(Utf8("MAIL") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("SHIP") AS Utf8)) AND LINEITEM.L_COMMITDATE < LINEITEM.L_RECEIPTDATE AND LINEITEM.L_SHIPDATE < LINEITEM.L_COMMITDATE AND LINEITEM.L_RECEIPTDATE >= CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_RECEIPTDATE < CAST(Utf8("1995-01-01") AS Date32) + Cross Join: + TableScan: ORDERS + TableScan: LINEITEM + "# ); Ok(()) } @@ -290,17 +290,17 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: count(ORDERS.O_ORDERKEY) AS C_COUNT, count(Int64(1)) AS CUSTDIST - Sort: count(Int64(1)) DESC NULLS FIRST, count(ORDERS.O_ORDERKEY) DESC NULLS FIRST - Projection: count(ORDERS.O_ORDERKEY), count(Int64(1)) - Aggregate: groupBy=[[count(ORDERS.O_ORDERKEY)]], aggr=[[count(Int64(1))]] - Projection: count(ORDERS.O_ORDERKEY) - Aggregate: groupBy=[[CUSTOMER.C_CUSTKEY]], aggr=[[count(ORDERS.O_ORDERKEY)]] - Projection: CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY - Left Join: CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY Filter: NOT ORDERS.O_COMMENT LIKE CAST(Utf8("%special%requests%") AS Utf8) - TableScan: CUSTOMER - TableScan: ORDERS - "# ); + Projection: count(ORDERS.O_ORDERKEY) AS C_COUNT, count(Int64(1)) AS CUSTDIST + Sort: count(Int64(1)) DESC NULLS FIRST, count(ORDERS.O_ORDERKEY) DESC NULLS FIRST + Projection: count(ORDERS.O_ORDERKEY), count(Int64(1)) + Aggregate: groupBy=[[count(ORDERS.O_ORDERKEY)]], aggr=[[count(Int64(1))]] + Projection: count(ORDERS.O_ORDERKEY) + Aggregate: groupBy=[[CUSTOMER.C_CUSTKEY]], aggr=[[count(ORDERS.O_ORDERKEY)]] + Projection: CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY + Left Join: CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY Filter: NOT ORDERS.O_COMMENT LIKE CAST(Utf8("%special%requests%") AS Utf8) + TableScan: CUSTOMER + TableScan: ORDERS + "# ); Ok(()) } @@ -310,14 +310,14 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: Decimal128(Some(10000),5,2) * sum(CASE WHEN PART.P_TYPE LIKE Utf8("PROMO%") THEN LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT ELSE Decimal128(Some(0),19,4) END) / sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS PROMO_REVENUE - Aggregate: groupBy=[[]], aggr=[[sum(CASE WHEN PART.P_TYPE LIKE Utf8("PROMO%") THEN LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT ELSE Decimal128(Some(0),19,4) END), sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] - Projection: CASE WHEN PART.P_TYPE LIKE CAST(Utf8("PROMO%") AS Utf8) THEN LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) ELSE Decimal128(Some(0),19,4) END, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) - Filter: LINEITEM.L_PARTKEY = PART.P_PARTKEY AND LINEITEM.L_SHIPDATE >= Date32("1995-09-01") AND LINEITEM.L_SHIPDATE < CAST(Utf8("1995-10-01") AS Date32) - Cross Join: - TableScan: LINEITEM - TableScan: PART - "# + Projection: Decimal128(Some(10000),5,2) * sum(CASE WHEN PART.P_TYPE LIKE Utf8("PROMO%") THEN LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT ELSE Decimal128(Some(0),19,4) END) / sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS PROMO_REVENUE + Aggregate: groupBy=[[]], aggr=[[sum(CASE WHEN PART.P_TYPE LIKE Utf8("PROMO%") THEN LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT ELSE Decimal128(Some(0),19,4) END), sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT)]] + Projection: CASE WHEN PART.P_TYPE LIKE CAST(Utf8("PROMO%") AS Utf8) THEN LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) ELSE Decimal128(Some(0),19,4) END, LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) + Filter: LINEITEM.L_PARTKEY = PART.P_PARTKEY AND LINEITEM.L_SHIPDATE >= Date32("1995-09-01") AND LINEITEM.L_SHIPDATE < CAST(Utf8("1995-10-01") AS Date32) + Cross Join: + TableScan: LINEITEM + TableScan: PART + "# ); Ok(()) } @@ -336,19 +336,19 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: PART.P_BRAND, PART.P_TYPE, PART.P_SIZE, count(DISTINCT PARTSUPP.PS_SUPPKEY) AS SUPPLIER_CNT - Sort: count(DISTINCT PARTSUPP.PS_SUPPKEY) DESC NULLS FIRST, PART.P_BRAND ASC NULLS LAST, PART.P_TYPE ASC NULLS LAST, PART.P_SIZE ASC NULLS LAST - Aggregate: groupBy=[[PART.P_BRAND, PART.P_TYPE, PART.P_SIZE]], aggr=[[count(DISTINCT PARTSUPP.PS_SUPPKEY)]] - Projection: PART.P_BRAND, PART.P_TYPE, PART.P_SIZE, PARTSUPP.PS_SUPPKEY - Filter: PART.P_PARTKEY = PARTSUPP.PS_PARTKEY AND PART.P_BRAND != Utf8("Brand#45") AND NOT PART.P_TYPE LIKE CAST(Utf8("MEDIUM POLISHED%") AS Utf8) AND (PART.P_SIZE = Int32(49) OR PART.P_SIZE = Int32(14) OR PART.P_SIZE = Int32(23) OR PART.P_SIZE = Int32(45) OR PART.P_SIZE = Int32(19) OR PART.P_SIZE = Int32(3) OR PART.P_SIZE = Int32(36) OR PART.P_SIZE = Int32(9)) AND NOT PARTSUPP.PS_SUPPKEY IN () - Subquery: - Projection: SUPPLIER.S_SUPPKEY - Filter: SUPPLIER.S_COMMENT LIKE CAST(Utf8("%Customer%Complaints%") AS Utf8) - TableScan: SUPPLIER - Cross Join: - TableScan: PARTSUPP - TableScan: PART - "# + Projection: PART.P_BRAND, PART.P_TYPE, PART.P_SIZE, count(DISTINCT PARTSUPP.PS_SUPPKEY) AS SUPPLIER_CNT + Sort: count(DISTINCT PARTSUPP.PS_SUPPKEY) DESC NULLS FIRST, PART.P_BRAND ASC NULLS LAST, PART.P_TYPE ASC NULLS LAST, PART.P_SIZE ASC NULLS LAST + Aggregate: groupBy=[[PART.P_BRAND, PART.P_TYPE, PART.P_SIZE]], aggr=[[count(DISTINCT PARTSUPP.PS_SUPPKEY)]] + Projection: PART.P_BRAND, PART.P_TYPE, PART.P_SIZE, PARTSUPP.PS_SUPPKEY + Filter: PART.P_PARTKEY = PARTSUPP.PS_PARTKEY AND PART.P_BRAND != Utf8("Brand#45") AND NOT PART.P_TYPE LIKE CAST(Utf8("MEDIUM POLISHED%") AS Utf8) AND (PART.P_SIZE = Int32(49) OR PART.P_SIZE = Int32(14) OR PART.P_SIZE = Int32(23) OR PART.P_SIZE = Int32(45) OR PART.P_SIZE = Int32(19) OR PART.P_SIZE = Int32(3) OR PART.P_SIZE = Int32(36) OR PART.P_SIZE = Int32(9)) AND NOT PARTSUPP.PS_SUPPKEY IN () + Subquery: + Projection: SUPPLIER.S_SUPPKEY + Filter: SUPPLIER.S_COMMENT LIKE CAST(Utf8("%Customer%Complaints%") AS Utf8) + TableScan: SUPPLIER + Cross Join: + TableScan: PARTSUPP + TableScan: PART + "# ); Ok(()) } @@ -366,25 +366,25 @@ mod tests { let plan_str = tpch_plan_to_string(18).await?; assert_snapshot!( plan_str, - @r#" - Projection: CUSTOMER.C_NAME, CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_TOTALPRICE, sum(LINEITEM.L_QUANTITY) AS EXPR$5 - Limit: skip=0, fetch=100 - Sort: ORDERS.O_TOTALPRICE DESC NULLS FIRST, ORDERS.O_ORDERDATE ASC NULLS LAST - Aggregate: groupBy=[[CUSTOMER.C_NAME, CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_TOTALPRICE]], aggr=[[sum(LINEITEM.L_QUANTITY)]] - Projection: CUSTOMER.C_NAME, CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_TOTALPRICE, LINEITEM.L_QUANTITY - Filter: ORDERS.O_ORDERKEY IN () AND CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY - Subquery: - Projection: LINEITEM.L_ORDERKEY - Filter: sum(LINEITEM.L_QUANTITY) > CAST(Int32(300) AS Decimal128(15, 2)) - Aggregate: groupBy=[[LINEITEM.L_ORDERKEY]], aggr=[[sum(LINEITEM.L_QUANTITY)]] - Projection: LINEITEM.L_ORDERKEY, LINEITEM.L_QUANTITY - TableScan: LINEITEM - Cross Join: - Cross Join: - TableScan: CUSTOMER - TableScan: ORDERS - TableScan: LINEITEM - "# + @r" + Projection: CUSTOMER.C_NAME, CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_TOTALPRICE, sum(LINEITEM.L_QUANTITY) AS EXPR$5 + Limit: skip=0, fetch=100 + Sort: ORDERS.O_TOTALPRICE DESC NULLS FIRST, ORDERS.O_ORDERDATE ASC NULLS LAST + Aggregate: groupBy=[[CUSTOMER.C_NAME, CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_TOTALPRICE]], aggr=[[sum(LINEITEM.L_QUANTITY)]] + Projection: CUSTOMER.C_NAME, CUSTOMER.C_CUSTKEY, ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE, ORDERS.O_TOTALPRICE, LINEITEM.L_QUANTITY + Filter: ORDERS.O_ORDERKEY IN () AND CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY AND ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY + Subquery: + Projection: LINEITEM.L_ORDERKEY + Filter: sum(LINEITEM.L_QUANTITY) > CAST(Int32(300) AS Decimal128(15, 2)) + Aggregate: groupBy=[[LINEITEM.L_ORDERKEY]], aggr=[[sum(LINEITEM.L_QUANTITY)]] + Projection: LINEITEM.L_ORDERKEY, LINEITEM.L_QUANTITY + TableScan: LINEITEM + Cross Join: + Cross Join: + TableScan: CUSTOMER + TableScan: ORDERS + TableScan: LINEITEM + " ); Ok(()) } @@ -394,13 +394,13 @@ mod tests { assert_snapshot!( plan_str, @r#" - Aggregate: groupBy=[[]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS REVENUE]] - Projection: LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) - Filter: PART.P_PARTKEY = LINEITEM.L_PARTKEY AND PART.P_BRAND = Utf8("Brand#12") AND (PART.P_CONTAINER = CAST(Utf8("SM CASE") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("SM BOX") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("SM PACK") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("SM PKG") AS Utf8)) AND LINEITEM.L_QUANTITY >= CAST(Int32(1) AS Decimal128(15, 2)) AND LINEITEM.L_QUANTITY <= CAST(Int32(1) + Int32(10) AS Decimal128(15, 2)) AND PART.P_SIZE >= Int32(1) AND PART.P_SIZE <= Int32(5) AND (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8)) AND LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON") OR PART.P_PARTKEY = LINEITEM.L_PARTKEY AND PART.P_BRAND = Utf8("Brand#23") AND (PART.P_CONTAINER = CAST(Utf8("MED BAG") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("MED BOX") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("MED PKG") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("MED PACK") AS Utf8)) AND LINEITEM.L_QUANTITY >= CAST(Int32(10) AS Decimal128(15, 2)) AND LINEITEM.L_QUANTITY <= CAST(Int32(10) + Int32(10) AS Decimal128(15, 2)) AND PART.P_SIZE >= Int32(1) AND PART.P_SIZE <= Int32(10) AND (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8)) AND LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON") OR PART.P_PARTKEY = LINEITEM.L_PARTKEY AND PART.P_BRAND = Utf8("Brand#34") AND (PART.P_CONTAINER = CAST(Utf8("LG CASE") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("LG BOX") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("LG PACK") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("LG PKG") AS Utf8)) AND LINEITEM.L_QUANTITY >= CAST(Int32(20) AS Decimal128(15, 2)) AND LINEITEM.L_QUANTITY <= CAST(Int32(20) + Int32(10) AS Decimal128(15, 2)) AND PART.P_SIZE >= Int32(1) AND PART.P_SIZE <= Int32(15) AND (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8)) AND LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON") - Cross Join: - TableScan: LINEITEM - TableScan: PART - "# + Aggregate: groupBy=[[]], aggr=[[sum(LINEITEM.L_EXTENDEDPRICE * Int32(1) - LINEITEM.L_DISCOUNT) AS REVENUE]] + Projection: LINEITEM.L_EXTENDEDPRICE * (CAST(Int32(1) AS Decimal128(15, 2)) - LINEITEM.L_DISCOUNT) + Filter: PART.P_PARTKEY = LINEITEM.L_PARTKEY AND PART.P_BRAND = Utf8("Brand#12") AND (PART.P_CONTAINER = CAST(Utf8("SM CASE") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("SM BOX") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("SM PACK") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("SM PKG") AS Utf8)) AND LINEITEM.L_QUANTITY >= CAST(Int32(1) AS Decimal128(15, 2)) AND LINEITEM.L_QUANTITY <= CAST(Int32(1) + Int32(10) AS Decimal128(15, 2)) AND PART.P_SIZE >= Int32(1) AND PART.P_SIZE <= Int32(5) AND (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8)) AND LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON") OR PART.P_PARTKEY = LINEITEM.L_PARTKEY AND PART.P_BRAND = Utf8("Brand#23") AND (PART.P_CONTAINER = CAST(Utf8("MED BAG") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("MED BOX") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("MED PKG") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("MED PACK") AS Utf8)) AND LINEITEM.L_QUANTITY >= CAST(Int32(10) AS Decimal128(15, 2)) AND LINEITEM.L_QUANTITY <= CAST(Int32(10) + Int32(10) AS Decimal128(15, 2)) AND PART.P_SIZE >= Int32(1) AND PART.P_SIZE <= Int32(10) AND (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8)) AND LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON") OR PART.P_PARTKEY = LINEITEM.L_PARTKEY AND PART.P_BRAND = Utf8("Brand#34") AND (PART.P_CONTAINER = CAST(Utf8("LG CASE") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("LG BOX") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("LG PACK") AS Utf8) OR PART.P_CONTAINER = CAST(Utf8("LG PKG") AS Utf8)) AND LINEITEM.L_QUANTITY >= CAST(Int32(20) AS Decimal128(15, 2)) AND LINEITEM.L_QUANTITY <= CAST(Int32(20) + Int32(10) AS Decimal128(15, 2)) AND PART.P_SIZE >= Int32(1) AND PART.P_SIZE <= Int32(15) AND (LINEITEM.L_SHIPMODE = CAST(Utf8("AIR") AS Utf8) OR LINEITEM.L_SHIPMODE = CAST(Utf8("AIR REG") AS Utf8)) AND LINEITEM.L_SHIPINSTRUCT = Utf8("DELIVER IN PERSON") + Cross Join: + TableScan: LINEITEM + TableScan: PART + "# ); Ok(()) } @@ -411,27 +411,27 @@ mod tests { assert_snapshot!( plan_str, @r#" - Sort: SUPPLIER.S_NAME ASC NULLS LAST - Projection: SUPPLIER.S_NAME, SUPPLIER.S_ADDRESS - Filter: SUPPLIER.S_SUPPKEY IN () AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_NAME = Utf8("CANADA") - Subquery: - Projection: PARTSUPP.PS_SUPPKEY - Filter: PARTSUPP.PS_PARTKEY IN () AND CAST(PARTSUPP.PS_AVAILQTY AS Decimal128(19, 0)) > () - Subquery: - Projection: PART.P_PARTKEY - Filter: PART.P_NAME LIKE CAST(Utf8("forest%") AS Utf8) - TableScan: PART - Subquery: - Projection: Decimal128(Some(5),2,1) * sum(LINEITEM.L_QUANTITY) - Aggregate: groupBy=[[]], aggr=[[sum(LINEITEM.L_QUANTITY)]] - Projection: LINEITEM.L_QUANTITY - Filter: LINEITEM.L_PARTKEY = LINEITEM.L_ORDERKEY AND LINEITEM.L_SUPPKEY = LINEITEM.L_PARTKEY AND LINEITEM.L_SHIPDATE >= CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_SHIPDATE < CAST(Utf8("1995-01-01") AS Date32) - TableScan: LINEITEM - TableScan: PARTSUPP - Cross Join: - TableScan: SUPPLIER - TableScan: NATION - "# + Sort: SUPPLIER.S_NAME ASC NULLS LAST + Projection: SUPPLIER.S_NAME, SUPPLIER.S_ADDRESS + Filter: SUPPLIER.S_SUPPKEY IN () AND SUPPLIER.S_NATIONKEY = NATION.N_NATIONKEY AND NATION.N_NAME = Utf8("CANADA") + Subquery: + Projection: PARTSUPP.PS_SUPPKEY + Filter: PARTSUPP.PS_PARTKEY IN () AND CAST(PARTSUPP.PS_AVAILQTY AS Decimal128(19, 0)) > () + Subquery: + Projection: PART.P_PARTKEY + Filter: PART.P_NAME LIKE CAST(Utf8("forest%") AS Utf8) + TableScan: PART + Subquery: + Projection: Decimal128(Some(5),2,1) * sum(LINEITEM.L_QUANTITY) + Aggregate: groupBy=[[]], aggr=[[sum(LINEITEM.L_QUANTITY)]] + Projection: LINEITEM.L_QUANTITY + Filter: LINEITEM.L_PARTKEY = LINEITEM.L_ORDERKEY AND LINEITEM.L_SUPPKEY = LINEITEM.L_PARTKEY AND LINEITEM.L_SHIPDATE >= CAST(Utf8("1994-01-01") AS Date32) AND LINEITEM.L_SHIPDATE < CAST(Utf8("1995-01-01") AS Date32) + TableScan: LINEITEM + TableScan: PARTSUPP + Cross Join: + TableScan: SUPPLIER + TableScan: NATION + "# ); Ok(()) } @@ -511,10 +511,10 @@ mod tests { assert_snapshot!( plan_str, - @r#" - Aggregate: groupBy=[[]], aggr=[[count(Int64(1)) AS count(*)]] - Values: (Int64(0)) - "# + @r" + Aggregate: groupBy=[[]], aggr=[[count(Int64(1)) AS count(*)]] + Values: (Int64(0)) + " ); Ok(()) } @@ -527,9 +527,9 @@ mod tests { assert_snapshot!( plan_str, @r#" - Projection: dummy1 AS result1, dummy2 AS result2 - Values: (Int64(0), Utf8("temp")), (Int64(1), Utf8("test")) - "# + Projection: dummy1 AS result1, dummy2 AS result2 + Values: (Int64(0), Utf8("temp")), (Int64(1), Utf8("test")) + "# ); Ok(()) } @@ -545,10 +545,10 @@ mod tests { //Test correct plan structure assert_snapshot!(plan_str, - @r#" + @r" Projection: a, b, (a OR b) AND NOT a AND b AS result Values: (Boolean(true), Boolean(true)), (Boolean(true), Boolean(false)), (Boolean(false), Boolean(true)), (Boolean(false), Boolean(false)) - "# + " ); Ok(()) @@ -566,10 +566,10 @@ mod tests { //Test correct plan structure assert_snapshot!(plan_str, - @r#" + @r" Projection: a, b, a AND NOT b AS result Values: (Boolean(true), Boolean(true)), (Boolean(true), Boolean(false)), (Boolean(false), Boolean(true)), (Boolean(false), Boolean(false)) - "# + " ); Ok(()) @@ -582,10 +582,10 @@ mod tests { let plan_str = test_plan_to_string("scalar_fn_to_between_expr.substrait.json").await?; assert_snapshot!(plan_str, - @r#" - Projection: expr BETWEEN low AND high AS result - Values: (Int8(2), Int8(1), Int8(3)), (Int8(4), Int8(1), Int8(2)) - "# + @r" + Projection: expr BETWEEN low AND high AS result + Values: (Int8(2), Int8(1), Int8(3)), (Int8(4), Int8(1), Int8(2)) + " ); Ok(()) } @@ -594,10 +594,10 @@ mod tests { async fn test_logb_expr() -> Result<()> { let plan_str = test_plan_to_string("scalar_fn_logb_expr.substrait.json").await?; assert_snapshot!(plan_str, - @r#" - Projection: x, base, log(base, x) AS result - Values: (Float32(1), Float32(10)), (Float32(100), Float32(10)) - "# + @r" + Projection: x, base, log(base, x) AS result + Values: (Float32(1), Float32(10)), (Float32(100), Float32(10)) + " ); Ok(()) } @@ -639,11 +639,11 @@ mod tests { assert_snapshot!( plan_str, - @r#" + @r" Projection: count(Int64(1)) PARTITION BY [DATA.PART] ORDER BY [DATA.ORD ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING AS LEAD_EXPR WindowAggr: windowExpr=[[count(Int64(1)) PARTITION BY [DATA.PART] ORDER BY [DATA.ORD ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING]] TableScan: DATA - "# + " ); Ok(()) } diff --git a/datafusion/substrait/tests/cases/emit_kind_tests.rs b/datafusion/substrait/tests/cases/emit_kind_tests.rs index e916b4cb0e1a9..24508fd054d97 100644 --- a/datafusion/substrait/tests/cases/emit_kind_tests.rs +++ b/datafusion/substrait/tests/cases/emit_kind_tests.rs @@ -38,10 +38,10 @@ mod tests { assert_snapshot!( plan, - @r#" - Projection: DATA.A AS a, DATA.B AS b, DATA.A + Int64(1) AS add1 - TableScan: DATA - "# + @r" + Projection: DATA.A AS a, DATA.B AS b, DATA.A + Int64(1) AS add1 + TableScan: DATA + " ); Ok(()) } @@ -57,11 +57,11 @@ mod tests { assert_snapshot!( plan, // Note that duplicate references in the remap are aliased - @r#" - Projection: DATA.B, DATA.A AS A1, DATA.A AS DATA.A__temp__0 AS A2 - Filter: DATA.B = Int64(2) - TableScan: DATA - "# + @r" + Projection: DATA.B, DATA.A AS A1, DATA.A AS DATA.A__temp__0 AS A2 + Filter: DATA.B = Int64(2) + TableScan: DATA + " ); Ok(()) } @@ -88,21 +88,21 @@ mod tests { let plan = df.into_unoptimized_plan(); assert_snapshot!( plan, - @r#" - Projection: random() AS c1, data.a + Int64(1) AS c2 - TableScan: data - "# ); + @r" + Projection: random() AS c1, data.a + Int64(1) AS c2 + TableScan: data + " ); let proto = to_substrait_plan(&plan, &ctx.state())?; let plan2 = from_substrait_plan(&ctx.state(), &proto).await?; // note how the Projections are not flattened assert_snapshot!( plan2, - @r#" - Projection: random() AS c1, data.a + Int64(1) AS c2 - Projection: data.a, data.b, data.c, data.d, data.e, data.f, random(), data.a + Int64(1) - TableScan: data - "# + @r" + Projection: random() AS c1, data.a + Int64(1) AS c2 + Projection: data.a, data.b, data.c, data.d, data.e, data.f, random(), data.a + Int64(1) + TableScan: data + " ); Ok(()) } @@ -115,10 +115,10 @@ mod tests { let plan = df.into_unoptimized_plan(); assert_snapshot!( plan, - @r#" - Projection: data.a + Int64(1), data.b + Int64(2) - TableScan: data - "# + @r" + Projection: data.a + Int64(1), data.b + Int64(2) + TableScan: data + " ); let proto = to_substrait_plan(&plan, &ctx.state())?; diff --git a/datafusion/substrait/tests/cases/function_test.rs b/datafusion/substrait/tests/cases/function_test.rs index 1816c64d39212..d71c80678a091 100644 --- a/datafusion/substrait/tests/cases/function_test.rs +++ b/datafusion/substrait/tests/cases/function_test.rs @@ -35,10 +35,10 @@ mod tests { assert_snapshot!( plan, @r#" - Projection: nation.n_name - Filter: contains(nation.n_name, Utf8("IA")) - TableScan: nation - "# + Projection: nation.n_name + Filter: contains(nation.n_name, Utf8("IA")) + TableScan: nation + "# ); Ok(()) } diff --git a/datafusion/substrait/tests/cases/logical_plans.rs b/datafusion/substrait/tests/cases/logical_plans.rs index 7d12fe28e6d46..5ebacaf5336d4 100644 --- a/datafusion/substrait/tests/cases/logical_plans.rs +++ b/datafusion/substrait/tests/cases/logical_plans.rs @@ -43,10 +43,10 @@ mod tests { assert_snapshot!( plan, - @r#" - Projection: NOT DATA.D AS EXPR$0 - TableScan: DATA - "# + @r" + Projection: NOT DATA.D AS EXPR$0 + TableScan: DATA + " ); // Trigger execution to ensure plan validity @@ -74,11 +74,11 @@ mod tests { assert_snapshot!( plan, - @r#" - Projection: sum(DATA.D) PARTITION BY [DATA.PART] ORDER BY [DATA.ORD ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING AS LEAD_EXPR - WindowAggr: windowExpr=[[sum(DATA.D) PARTITION BY [DATA.PART] ORDER BY [DATA.ORD ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING]] - TableScan: DATA - "# + @r" + Projection: sum(DATA.D) PARTITION BY [DATA.PART] ORDER BY [DATA.ORD ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING AS LEAD_EXPR + WindowAggr: windowExpr=[[sum(DATA.D) PARTITION BY [DATA.PART] ORDER BY [DATA.ORD ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING]] + TableScan: DATA + " ); // Trigger execution to ensure plan validity @@ -101,11 +101,11 @@ mod tests { assert_snapshot!( plan, - @r#" - Projection: row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS EXPR$0, row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW__temp__0 AS ALIASED - WindowAggr: windowExpr=[[row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: DATA - "# + @r" + Projection: row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS EXPR$0, row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW__temp__0 AS ALIASED + WindowAggr: windowExpr=[[row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: DATA + " ); // Trigger execution to ensure plan validity @@ -130,12 +130,12 @@ mod tests { assert_snapshot!( plan, - @r#" - Projection: row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS EXPR$0, row_number() PARTITION BY [DATA.A] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS EXPR$1 - WindowAggr: windowExpr=[[row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - WindowAggr: windowExpr=[[row_number() PARTITION BY [DATA.A] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] - TableScan: DATA - "# + @r" + Projection: row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS EXPR$0, row_number() PARTITION BY [DATA.A] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS EXPR$1 + WindowAggr: windowExpr=[[row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + WindowAggr: windowExpr=[[row_number() PARTITION BY [DATA.A] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]] + TableScan: DATA + " ); // Trigger execution to ensure plan validity @@ -165,7 +165,7 @@ mod tests { settings.bind(|| { assert_snapshot!( plan, - @r#" + @r" Projection: left.A, left.[UUID] AS C, right.D, Utf8(NULL) AS [UUID] AS E Left Join: left.A = right.A SubqueryAlias: left @@ -176,7 +176,7 @@ mod tests { TableScan: B SubqueryAlias: right TableScan: C - "# + " ); }); @@ -198,9 +198,7 @@ mod tests { assert_snapshot!( &plan, - @r#" - Values: (List([1, 2])) - "# + @"Values: (List([1, 2]))" ); // Trigger execution to ensure plan validity @@ -218,12 +216,12 @@ mod tests { assert_snapshot!( plan, - @r#" - Projection: lower(sales.product) AS lower(product), sum(count(sales.product)) AS product_count - Aggregate: groupBy=[[sales.product]], aggr=[[sum(count(sales.product))]] - Aggregate: groupBy=[[sales.product]], aggr=[[count(sales.product)]] - TableScan: sales - "# + @r" + Projection: lower(sales.product) AS lower(product), sum(count(sales.product)) AS product_count + Aggregate: groupBy=[[sales.product]], aggr=[[sum(count(sales.product))]] + Aggregate: groupBy=[[sales.product]], aggr=[[count(sales.product)]] + TableScan: sales + " ); // Trigger execution to ensure plan validity diff --git a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs index f9983759871ab..98b35bf082ec4 100644 --- a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs +++ b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs @@ -234,10 +234,10 @@ async fn wildcard_select() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" Projection: data.a, data.b, data.c, data.d, data.e, data.f TableScan: data - "# + " ); Ok(()) } @@ -353,11 +353,11 @@ async fn aggregate_grouping_rollup() -> Result<()> { assert_snapshot!( plan, - @r#" - Projection: data.a, data.c, data.e, avg(data.b) - Aggregate: groupBy=[[GROUPING SETS ((data.a, data.c, data.e), (data.a, data.c), (data.a), ())]], aggr=[[avg(data.b)]] - TableScan: data projection=[a, b, c, e] - "# + @r" + Projection: data.a, data.c, data.e, avg(data.b) + Aggregate: groupBy=[[GROUPING SETS ((data.a, data.c, data.e), (data.a, data.c), (data.a), ())]], aggr=[[avg(data.b)]] + TableScan: data projection=[a, b, c, e] + " ); Ok(()) } @@ -373,11 +373,11 @@ async fn aggregate_grouping_cube() -> Result<()> { assert_snapshot!( plan, - @r#" - Projection: data.a, data.c, avg(data.b) - Aggregate: groupBy=[[GROUPING SETS ((), (data.a), (data.c), (data.a, data.c))]], aggr=[[avg(data.b)]] - TableScan: data projection=[a, b, c] - "# + @r" + Projection: data.a, data.c, avg(data.b) + Aggregate: groupBy=[[GROUPING SETS ((), (data.a), (data.c), (data.a, data.c))]], aggr=[[avg(data.b)]] + TableScan: data projection=[a, b, c] + " ); Ok(()) } @@ -393,11 +393,11 @@ async fn multilayer_aggregate() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" Aggregate: groupBy=[[data.a]], aggr=[[sum(count(data.b)) AS sum(partial_count_b)]] Aggregate: groupBy=[[data.a]], aggr=[[count(data.b)]] TableScan: data projection=[a, b] - "# + " ); Ok(()) } @@ -581,10 +581,10 @@ async fn aggregate_case() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" Aggregate: groupBy=[[]], aggr=[[sum(CASE WHEN data.a > Int64(0) THEN Int64(1) ELSE Int64(NULL) END) AS sum(CASE WHEN data.a > Int64(0) THEN Int64(1) ELSE NULL END)]] TableScan: data projection=[a] - "# + " ); Ok(()) } @@ -679,12 +679,12 @@ async fn roundtrip_exists_filter() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" Projection: data.b LeftSemi Join: data.a = data2.a Filter: data2.e != CAST(data.e AS Int64) TableScan: data projection=[a, b, e] TableScan: data2 projection=[a, e] - "# + " ); Ok(()) } @@ -700,11 +700,11 @@ async fn roundtrip_not_exists_filter_left_anti_join() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" LeftAnti Join: book_author.isbn = book.isbn TableScan: book_author projection=[isbn, author] TableScan: book projection=[isbn] - "# + " ); Ok(()) } @@ -720,11 +720,11 @@ async fn roundtrip_right_anti_join() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" RightAnti Join: book.isbn = book_author.isbn TableScan: book projection=[isbn] TableScan: book_author projection=[isbn, author] - "# + " ); Ok(()) } @@ -740,11 +740,11 @@ async fn roundtrip_right_semi_join() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" RightSemi Join: book.isbn = book_author.isbn TableScan: book projection=[isbn] TableScan: book_author projection=[isbn, author] - "# + " ); Ok(()) } @@ -760,12 +760,12 @@ async fn inner_join() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" Projection: data.a Inner Join: data.a = data2.a TableScan: data projection=[a] TableScan: data2 projection=[a] - "# + " ); Ok(()) } @@ -813,14 +813,14 @@ async fn self_join_introduces_aliases() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" Projection: left.b, right.c Inner Join: left.b = right.b SubqueryAlias: left TableScan: data projection=[b] SubqueryAlias: right TableScan: data projection=[b, c] - "# + " ); Ok(()) } @@ -970,10 +970,10 @@ async fn aggregate_wo_projection_consume() -> Result<()> { let plan = generate_plan_from_substrait(proto_plan).await?; assert_snapshot!( plan, - @r#" - Aggregate: groupBy=[[data.a]], aggr=[[count(data.a) AS countA]] - TableScan: data projection=[a] - "# + @r" + Aggregate: groupBy=[[data.a]], aggr=[[count(data.a) AS countA]] + TableScan: data projection=[a] + " ); Ok(()) } @@ -987,10 +987,10 @@ async fn aggregate_wo_projection_group_expression_ref_consume() -> Result<()> { let plan = generate_plan_from_substrait(proto_plan).await?; assert_snapshot!( plan, - @r#" - Aggregate: groupBy=[[data.a]], aggr=[[count(data.a) AS countA]] - TableScan: data projection=[a] - "# + @r" + Aggregate: groupBy=[[data.a]], aggr=[[count(data.a) AS countA]] + TableScan: data projection=[a] + " ); Ok(()) } @@ -1003,10 +1003,10 @@ async fn aggregate_wo_projection_sorted_consume() -> Result<()> { let plan = generate_plan_from_substrait(proto_plan).await?; assert_snapshot!( plan, - @r#" + @r" Aggregate: groupBy=[[data.a]], aggr=[[count(data.a) ORDER BY [data.a DESC NULLS FIRST] AS countA]] TableScan: data projection=[a] - "# + " ); Ok(()) } @@ -1020,10 +1020,10 @@ async fn aggregate_identical_grouping_expressions() -> Result<()> { let plan = generate_plan_from_substrait(proto_plan).await?; assert_snapshot!( plan, - @r#" + @r" Aggregate: groupBy=[[Int32(1) AS grouping_col_1, Int32(1) AS grouping_col_2]], aggr=[[]] TableScan: data projection=[] - "# + " ); Ok(()) } @@ -1333,10 +1333,10 @@ async fn roundtrip_literal_struct() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" Projection: Struct({c0:1,c1:true,c2:}) AS struct(Int64(1),Boolean(true),NULL) TableScan: data projection=[] - "# + " ); Ok(()) } @@ -1373,10 +1373,10 @@ async fn roundtrip_literal_renamed_struct() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" Projection: Struct({int_field:1}) AS Struct({c0:1}) TableScan: data projection=[] - "# + " ); Ok(()) } @@ -1402,9 +1402,7 @@ async fn roundtrip_values() -> Result<()> { assert_snapshot!( plan, - @r#" - Values: (Int64(1), Utf8("a"), List([[-213.1, , 5.5, 2.0, 1.0], []]), LargeList([1, 2, 3]), Struct({c0:true,int_field:1,c2:}), List([{struct_field: {string_field: a}}, {struct_field: {string_field: b}}])), (Int64(NULL), Utf8(NULL), List(), LargeList(), Struct({c0:,int_field:,c2:}), List()) - "# + @r#"Values: (Int64(1), Utf8("a"), List([[-213.1, , 5.5, 2.0, 1.0], []]), LargeList([1, 2, 3]), Struct({c0:true,int_field:1,c2:}), List([{struct_field: {string_field: a}}, {struct_field: {string_field: b}}])), (Int64(NULL), Utf8(NULL), List(), LargeList(), Struct({c0:,int_field:,c2:}), List())"# ); Ok(()) } @@ -1485,11 +1483,11 @@ async fn duplicate_column() -> Result<()> { assert_snapshot!( plan, - @r#" + @r" Projection: data.a + Int64(1) AS sum_a, data.a + Int64(1) AS data.a + Int64(1)__temp__0 AS sum_a_2 Projection: data.a + Int64(1) TableScan: data projection=[a] - "# + " ); Ok(()) } diff --git a/datafusion/substrait/tests/cases/serialize.rs b/datafusion/substrait/tests/cases/serialize.rs index 3f9cf5b2f2e51..d0f9511760938 100644 --- a/datafusion/substrait/tests/cases/serialize.rs +++ b/datafusion/substrait/tests/cases/serialize.rs @@ -95,10 +95,10 @@ mod tests { assert_snapshot!( format!("{}", datafusion_plan), - @r#" -Projection: data.b, data.a + data.a, data.a - TableScan: data projection=[a, b] -"# + @r" + Projection: data.b, data.a + data.a, data.a + TableScan: data projection=[a, b] + " , ); @@ -142,11 +142,11 @@ Projection: data.b, data.a + data.a, data.a let datafusion_plan = df.into_optimized_plan()?; assert_snapshot!( datafusion_plan, - @r#" -Projection: data.b, rank() PARTITION BY [data.a] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, data.c - WindowAggr: windowExpr=[[rank() PARTITION BY [data.a] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] - TableScan: data projection=[a, b, c] -"# + @r" + Projection: data.b, rank() PARTITION BY [data.a] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, data.c + WindowAggr: windowExpr=[[rank() PARTITION BY [data.a] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] + TableScan: data projection=[a, b, c] + " , ); diff --git a/datafusion/substrait/tests/cases/substrait_validations.rs b/datafusion/substrait/tests/cases/substrait_validations.rs index c8cc3fe9940ce..9841c736da8c9 100644 --- a/datafusion/substrait/tests/cases/substrait_validations.rs +++ b/datafusion/substrait/tests/cases/substrait_validations.rs @@ -69,10 +69,10 @@ mod tests { assert_snapshot!( plan, - @r#" - Projection: DATA.a, DATA.b - TableScan: DATA - "# + @r" + Projection: DATA.a, DATA.b + TableScan: DATA + " ); Ok(()) } @@ -92,10 +92,10 @@ mod tests { assert_snapshot!( plan, - @r#" - Projection: DATA.a, DATA.b - TableScan: DATA projection=[a, b] - "# + @r" + Projection: DATA.a, DATA.b + TableScan: DATA projection=[a, b] + " ); Ok(()) } @@ -117,10 +117,10 @@ mod tests { assert_snapshot!( plan, - @r#" - Projection: DATA.a, DATA.b - TableScan: DATA projection=[a, b] - "# + @r" + Projection: DATA.a, DATA.b + TableScan: DATA projection=[a, b] + " ); Ok(()) }