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

Function read_empty_table

datafusion/core/src/datasource/listing/table.rs:374–415  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

372
373 #[tokio::test]
374 async fn read_empty_table() -> Result<()> {
375 let ctx = SessionContext::new();
376 let path = String::from("table/p1=v1/file.json");
377 register_test_store(&ctx, &[(&path, 100)]);
378
379 let format = JsonFormat::default();
380 let ext = format.get_ext();
381
382 let opt = ListingOptions::new(Arc::new(format))
383 .with_file_extension(ext)
384 .with_table_partition_cols(vec![(String::from("p1"), DataType::Utf8)])
385 .with_target_partitions(4);
386
387 let table_path = ListingTableUrl::parse("test:///table/")?;
388 let file_schema =
389 Arc::new(Schema::new(vec![Field::new("a", DataType::Boolean, false)]));
390 let config = ListingTableConfig::new(table_path)
391 .with_listing_options(opt)
392 .with_schema(file_schema);
393 let table = ListingTable::try_new(config)?;
394
395 assert_eq!(
396 columns(&table.schema()),
397 vec!["a".to_owned(), "p1".to_owned()]
398 );
399
400 // this will filter out the only file in the store
401 let filter = Expr::not_eq(col("p1"), lit("v1"));
402
403 let scan = table
404 .scan(&ctx.state(), None, &[filter], None)
405 .await
406 .expect("Empty execution plan");
407
408 assert!(scan.is::<EmptyExec>());
409 assert_eq!(
410 columns(&scan.schema()),
411 vec!["a".to_owned(), "p1".to_owned()]
412 );
413
414 Ok(())
415 }
416
417 async fn load_table(
418 ctx: &SessionContext,

Callers

nothing calls this directly

Calls 12

newFunction · 0.85
register_test_storeFunction · 0.85
with_file_extensionMethod · 0.80
with_listing_optionsMethod · 0.80
colFunction · 0.50
litFunction · 0.50
get_extMethod · 0.45
with_schemaMethod · 0.45
scanMethod · 0.45
stateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…