MCPcopy Create free account
hub / github.com/influxdata/influxdb / test_constant_split_multi_exprs

Function test_constant_split_multi_exprs

core/iox_query/src/exec/split.rs:757–853  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

755
756 #[tokio::test]
757 async fn test_constant_split_multi_exprs() {
758 // test that it works with a constant expression
759 test_helpers::maybe_start_logging();
760 let batch0 = RecordBatch::try_from_iter(vec![(
761 "int_col",
762 Arc::new(Int64Array::from(vec![1, 2, 3])) as ArrayRef,
763 )])
764 .unwrap();
765
766 // Test 1: 3 streams but all data is sent to the second one
767 let input = make_input(vec![vec![batch0.clone()]]);
768 // use `false` & `true` to send all outputs to second stream
769 let split_expr1 = df_physical_expr(&input, lit(false));
770 let split_expr2 = df_physical_expr(&input, lit(true));
771 let split_exec: Arc<dyn ExecutionPlan> =
772 Arc::new(StreamSplitExec::new(input, vec![split_expr1, split_expr2]));
773
774 let output0 = test_collect_partition(Arc::clone(&split_exec), 0).await;
775 let expected = vec!["+---------+", "| int_col |", "+---------+", "+---------+"];
776 assert_batches_sorted_eq!(&expected, &output0);
777
778 let output1 = test_collect_partition(Arc::clone(&split_exec), 1).await;
779 let expected = vec![
780 "+---------+",
781 "| int_col |",
782 "+---------+",
783 "| 1 |",
784 "| 2 |",
785 "| 3 |",
786 "+---------+",
787 ];
788 assert_batches_sorted_eq!(&expected, &output1);
789
790 let output2 = test_collect_partition(split_exec, 2).await;
791 let expected = vec!["+---------+", "| int_col |", "+---------+", "+---------+"];
792 assert_batches_sorted_eq!(&expected, &output2);
793
794 // -----------------------
795 // Test 2: 3 streams but all data is sent to the last one
796 let input = make_input(vec![vec![batch0.clone()]]);
797
798 // use `false` & `false` to send all outputs to third stream
799 let split_expr1 = df_physical_expr(&input, lit(false));
800 let split_expr2 = df_physical_expr(&input, lit(false));
801 let split_exec: Arc<dyn ExecutionPlan> =
802 Arc::new(StreamSplitExec::new(input, vec![split_expr1, split_expr2]));
803
804 let output0 = test_collect_partition(Arc::clone(&split_exec), 0).await;
805 let expected = vec!["+---------+", "| int_col |", "+---------+", "+---------+"];
806 assert_batches_sorted_eq!(&expected, &output0);
807
808 let output1 = test_collect_partition(Arc::clone(&split_exec), 1).await;
809 let expected = vec!["+---------+", "| int_col |", "+---------+", "+---------+"];
810 assert_batches_sorted_eq!(&expected, &output1);
811
812 let output2 = test_collect_partition(Arc::clone(&split_exec), 2).await;
813 let expected = vec![
814 "+---------+",

Callers

nothing calls this directly

Calls 5

maybe_start_loggingFunction · 0.85
make_inputFunction · 0.85
df_physical_exprFunction · 0.85
litFunction · 0.85
test_collect_partitionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…