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

Function test_csv_serializer

datafusion/core/src/datasource/file_format/csv.rs:645–666  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

643
644 #[tokio::test]
645 async fn test_csv_serializer() -> Result<()> {
646 let ctx = SessionContext::new();
647 let df = ctx
648 .read_csv(
649 &format!("{}/csv/aggregate_test_100.csv", arrow_test_data()),
650 CsvReadOptions::default().has_header(true),
651 )
652 .await?;
653 let batches = df
654 .select_columns(&["c2", "c3"])?
655 .limit(0, Some(10))?
656 .collect()
657 .await?;
658 let batch = concat_batches(&batches[0].schema(), &batches)?;
659 let serializer = CsvSerializer::new();
660 let bytes = serializer.serialize(batch, true)?;
661 assert_eq!(
662 "c2,c3\n2,1\n5,-40\n1,29\n1,-85\n5,-82\n4,-111\n3,104\n3,13\n1,38\n4,-38\n",
663 String::from_utf8(bytes.into()).unwrap()
664 );
665 Ok(())
666 }
667
668 #[tokio::test]
669 async fn test_csv_serializer_no_header() -> Result<()> {

Callers

nothing calls this directly

Calls 8

newFunction · 0.85
read_csvMethod · 0.80
collectMethod · 0.80
select_columnsMethod · 0.80
has_headerMethod · 0.45
limitMethod · 0.45
schemaMethod · 0.45
serializeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…