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

Function test_statistics_cache_default

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

Source from the content-addressed store, hash-verified

655
656 #[tokio::test]
657 async fn test_statistics_cache_default() -> Result<(), DataFusionError> {
658 let ctx = SessionContext::new();
659
660 ctx.register_udtf(
661 "statistics_cache",
662 Arc::new(StatisticsCacheFunc::new(
663 ctx.task_ctx().runtime_env().cache_manager.clone(),
664 )),
665 );
666
667 for filename in [
668 "alltypes_plain",
669 "alltypes_tiny_pages",
670 "lz4_raw_compressed_larger",
671 ] {
672 ctx.sql(
673 format!(
674 "create external table {filename}
675 stored as parquet
676 location '../parquet-testing/data/{filename}.parquet'",
677 )
678 .as_str(),
679 )
680 .await?
681 .collect()
682 .await?;
683 }
684
685 let sql = "SELECT split_part(path, '/', -1) as filename, table, file_size_bytes, num_rows, num_columns, table_size_bytes from statistics_cache() order by filename";
686 let df = ctx.sql(sql).await?;
687 let rbs = df.collect().await?;
688 assert_snapshot!(batches_to_string(&rbs),@r"
689 +-----------------------------------+---------------------------+-----------------+--------------+-------------+------------------+
690 | filename | table | file_size_bytes | num_rows | num_columns | table_size_bytes |
691 +-----------------------------------+---------------------------+-----------------+--------------+-------------+------------------+
692 | alltypes_plain.parquet | alltypes_plain | 1851 | Exact(8) | 11 | Absent |
693 | alltypes_tiny_pages.parquet | alltypes_tiny_pages | 454233 | Exact(7300) | 13 | Absent |
694 | lz4_raw_compressed_larger.parquet | lz4_raw_compressed_larger | 380836 | Exact(10000) | 1 | Absent |
695 +-----------------------------------+---------------------------+-----------------+--------------+-------------+------------------+
696 ");
697
698 Ok(())
699 }
700
701 #[tokio::test]
702 async fn test_list_files_cache() -> Result<(), DataFusionError> {

Callers

nothing calls this directly

Calls 8

newFunction · 0.85
collectMethod · 0.80
sqlMethod · 0.80
register_udtfMethod · 0.45
cloneMethod · 0.45
runtime_envMethod · 0.45
task_ctxMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…