()
| 2808 | // Test issue: https://github.com/apache/datafusion/issues/13873 |
| 2809 | #[tokio::test] |
| 2810 | async fn write_csv_with_order() -> Result<()> { |
| 2811 | let tmp_dir = TempDir::new()?; |
| 2812 | let schema = Arc::new(Schema::new(vec![ |
| 2813 | Field::new("a", DataType::Int32, true), |
| 2814 | Field::new("b", DataType::Int32, true), |
| 2815 | ])); |
| 2816 | |
| 2817 | let ctx = SessionContext::new(); |
| 2818 | let write_df = ctx.read_batch(RecordBatch::try_new( |
| 2819 | schema.clone(), |
| 2820 | vec![ |
| 2821 | Arc::new(Int32Array::from(vec![1, 5, 7, 3, 2])), |
| 2822 | Arc::new(Int32Array::from(vec![2, 3, 4, 5, 6])), |
| 2823 | ], |
| 2824 | )?)?; |
| 2825 | |
| 2826 | let test_path = tmp_dir.path().join("test.csv"); |
| 2827 | |
| 2828 | write_df |
| 2829 | .clone() |
| 2830 | .write_csv( |
| 2831 | test_path.to_str().unwrap(), |
| 2832 | DataFrameWriteOptions::new().with_sort_by(vec![col("a").sort(true, true)]), |
| 2833 | None, |
| 2834 | ) |
| 2835 | .await?; |
| 2836 | |
| 2837 | let ctx = SessionContext::new(); |
| 2838 | ctx.register_csv( |
| 2839 | "data", |
| 2840 | test_path.to_str().unwrap(), |
| 2841 | CsvReadOptions::new().schema(&schema), |
| 2842 | ) |
| 2843 | .await?; |
| 2844 | |
| 2845 | let df = ctx.sql("SELECT * FROM data").await?; |
| 2846 | let results = df.collect().await?; |
| 2847 | |
| 2848 | assert_snapshot!( |
| 2849 | batches_to_string(&results), |
| 2850 | @r" |
| 2851 | +---+---+ |
| 2852 | | a | b | |
| 2853 | +---+---+ |
| 2854 | | 1 | 2 | |
| 2855 | | 2 | 6 | |
| 2856 | | 3 | 5 | |
| 2857 | | 5 | 3 | |
| 2858 | | 7 | 4 | |
| 2859 | +---+---+ |
| 2860 | " |
| 2861 | ); |
| 2862 | Ok(()) |
| 2863 | } |
| 2864 | |
| 2865 | // Test issue: https://github.com/apache/datafusion/issues/13873 |
| 2866 | #[tokio::test] |
nothing calls this directly
no test coverage detected
searching dependent graphs…