()
| 2865 | // Test issue: https://github.com/apache/datafusion/issues/13873 |
| 2866 | #[tokio::test] |
| 2867 | async fn write_json_with_order() -> Result<()> { |
| 2868 | let tmp_dir = TempDir::new()?; |
| 2869 | let schema = Arc::new(Schema::new(vec![ |
| 2870 | Field::new("a", DataType::Int32, true), |
| 2871 | Field::new("b", DataType::Int32, true), |
| 2872 | ])); |
| 2873 | |
| 2874 | let ctx = SessionContext::new(); |
| 2875 | let write_df = ctx.read_batch(RecordBatch::try_new( |
| 2876 | schema.clone(), |
| 2877 | vec![ |
| 2878 | Arc::new(Int32Array::from(vec![1, 5, 7, 3, 2])), |
| 2879 | Arc::new(Int32Array::from(vec![2, 3, 4, 5, 6])), |
| 2880 | ], |
| 2881 | )?)?; |
| 2882 | |
| 2883 | let test_path = tmp_dir.path().join("test.json"); |
| 2884 | |
| 2885 | write_df |
| 2886 | .clone() |
| 2887 | .write_json( |
| 2888 | test_path.to_str().unwrap(), |
| 2889 | DataFrameWriteOptions::new().with_sort_by(vec![col("a").sort(true, true)]), |
| 2890 | None, |
| 2891 | ) |
| 2892 | .await?; |
| 2893 | |
| 2894 | let ctx = SessionContext::new(); |
| 2895 | ctx.register_json( |
| 2896 | "data", |
| 2897 | test_path.to_str().unwrap(), |
| 2898 | JsonReadOptions::default().schema(&schema), |
| 2899 | ) |
| 2900 | .await?; |
| 2901 | |
| 2902 | let df = ctx.sql("SELECT * FROM data").await?; |
| 2903 | let results = df.collect().await?; |
| 2904 | |
| 2905 | assert_snapshot!( |
| 2906 | batches_to_string(&results), |
| 2907 | @r" |
| 2908 | +---+---+ |
| 2909 | | a | b | |
| 2910 | +---+---+ |
| 2911 | | 1 | 2 | |
| 2912 | | 2 | 6 | |
| 2913 | | 3 | 5 | |
| 2914 | | 5 | 3 | |
| 2915 | | 7 | 4 | |
| 2916 | +---+---+ |
| 2917 | " |
| 2918 | ); |
| 2919 | Ok(()) |
| 2920 | } |
| 2921 | |
| 2922 | // Test issue: https://github.com/apache/datafusion/issues/13873 |
| 2923 | #[tokio::test] |
nothing calls this directly
no test coverage detected
searching dependent graphs…