MCPcopy Create free account
hub / github.com/apache/datafusion / write_parquet_with_order

Function write_parquet_with_order

datafusion/core/tests/dataframe/mod.rs:2752–2806  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2750// Test issue: https://github.com/apache/datafusion/issues/13873
2751#[tokio::test]
2752async fn write_parquet_with_order() -> Result<()> {
2753 let tmp_dir = TempDir::new()?;
2754 let schema = Arc::new(Schema::new(vec![
2755 Field::new("a", DataType::Int32, true),
2756 Field::new("b", DataType::Int32, true),
2757 ]));
2758
2759 let ctx = SessionContext::new();
2760 let write_df = ctx.read_batch(RecordBatch::try_new(
2761 schema.clone(),
2762 vec![
2763 Arc::new(Int32Array::from(vec![1, 5, 7, 3, 2])),
2764 Arc::new(Int32Array::from(vec![2, 3, 4, 5, 6])),
2765 ],
2766 )?)?;
2767
2768 let test_path = tmp_dir.path().join("test.parquet");
2769
2770 write_df
2771 .clone()
2772 .write_parquet(
2773 test_path.to_str().unwrap(),
2774 DataFrameWriteOptions::new().with_sort_by(vec![col("a").sort(true, true)]),
2775 None,
2776 )
2777 .await?;
2778
2779 let ctx = SessionContext::new();
2780 ctx.register_parquet(
2781 "data",
2782 test_path.to_str().unwrap(),
2783 ParquetReadOptions::default(),
2784 )
2785 .await?;
2786
2787 let df = ctx.sql("SELECT * FROM data").await?;
2788 let results = df.collect().await?;
2789
2790 assert_snapshot!(
2791 batches_to_string(&results),
2792 @r"
2793 +---+---+
2794 | a | b |
2795 +---+---+
2796 | 1 | 2 |
2797 | 2 | 6 |
2798 | 3 | 5 |
2799 | 5 | 3 |
2800 | 7 | 4 |
2801 +---+---+
2802 "
2803 );
2804
2805 Ok(())
2806}
2807
2808// Test issue: https://github.com/apache/datafusion/issues/13873
2809#[tokio::test]

Callers

nothing calls this directly

Calls 10

newFunction · 0.85
read_batchMethod · 0.80
with_sort_byMethod · 0.80
sqlMethod · 0.80
collectMethod · 0.80
cloneMethod · 0.45
joinMethod · 0.45
pathMethod · 0.45
write_parquetMethod · 0.45
register_parquetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…