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

Function test_list_files_cache

datafusion-cli/src/main.rs:702–794  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

700
701 #[tokio::test]
702 async fn test_list_files_cache() -> Result<(), DataFusionError> {
703 let list_files_cache = Arc::new(DefaultListFilesCache::new(
704 1024,
705 Some(Duration::from_secs(1)),
706 ));
707
708 let rt = RuntimeEnvBuilder::new()
709 .with_cache_manager(
710 CacheManagerConfig::default()
711 .with_list_files_cache(Some(list_files_cache)),
712 )
713 .build_arc()
714 .unwrap();
715
716 let ctx = SessionContext::new_with_config_rt(SessionConfig::default(), rt);
717
718 ctx.register_object_store(
719 &Url::parse("mem://test_table").unwrap(),
720 Arc::new(InMemory::new()),
721 );
722
723 ctx.register_udtf(
724 "list_files_cache",
725 Arc::new(ListFilesCacheFunc::new(
726 ctx.task_ctx().runtime_env().cache_manager.clone(),
727 )),
728 );
729
730 ctx.sql(
731 "CREATE EXTERNAL TABLE src_table
732 STORED AS PARQUET
733 LOCATION '../parquet-testing/data/alltypes_plain.parquet'",
734 )
735 .await?
736 .collect()
737 .await?;
738
739 ctx.sql("COPY (SELECT * FROM src_table) TO 'mem://test_table/0.parquet' STORED AS PARQUET").await?.collect().await?;
740
741 ctx.sql("COPY (SELECT * FROM src_table) TO 'mem://test_table/1.parquet' STORED AS PARQUET").await?.collect().await?;
742
743 ctx.sql(
744 "CREATE EXTERNAL TABLE test_table
745 STORED AS PARQUET
746 LOCATION 'mem://test_table/'
747 ",
748 )
749 .await?
750 .collect()
751 .await?;
752
753 let sql = "SELECT metadata_size_bytes, expires_in, metadata_list FROM list_files_cache()";
754 let df = ctx
755 .sql(sql)
756 .await?
757 .unnest_columns(&["metadata_list"])?
758 .with_column_renamed("metadata_list", "metadata")?
759 .unnest_columns(&["metadata"])?;

Callers

nothing calls this directly

Calls 15

newFunction · 0.85
build_arcMethod · 0.80
with_cache_managerMethod · 0.80
with_list_files_cacheMethod · 0.80
collectMethod · 0.80
sqlMethod · 0.80
unnest_columnsMethod · 0.80
with_column_renamedMethod · 0.80
select_columnsMethod · 0.80
with_columnMethod · 0.80
colFunction · 0.50
litFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…