Skip to content

Commit cf637e7

Browse files
author
QP Hou
authored
collect table stats by default for listing table (#1347)
* collect table stats by default for listing table * add test
1 parent 0df9b99 commit cf637e7

File tree

1 file changed

+18
-1
lines changed
  • datafusion/src/datasource/listing

1 file changed

+18
-1
lines changed

datafusion/src/datasource/listing/table.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl ListingOptions {
7676
file_extension: String::new(),
7777
format,
7878
table_partition_cols: vec![],
79-
collect_stat: false,
79+
collect_stat: true,
8080
target_partitions: 1,
8181
}
8282
}
@@ -303,6 +303,23 @@ mod tests {
303303
Ok(())
304304
}
305305

306+
#[tokio::test]
307+
async fn load_table_stats_by_default() -> Result<()> {
308+
let testdata = crate::test_util::parquet_test_data();
309+
let filename = format!("{}/{}", testdata, "alltypes_plain.parquet");
310+
let opt = ListingOptions::new(Arc::new(ParquetFormat::default()));
311+
let schema = opt
312+
.infer_schema(Arc::new(LocalFileSystem {}), &filename)
313+
.await?;
314+
let table =
315+
ListingTable::new(Arc::new(LocalFileSystem {}), filename, schema, opt);
316+
let exec = table.scan(&None, 1024, &[], None).await?;
317+
assert_eq!(exec.statistics().num_rows, Some(8));
318+
assert_eq!(exec.statistics().total_byte_size, Some(671));
319+
320+
Ok(())
321+
}
322+
306323
#[tokio::test]
307324
async fn read_empty_table() -> Result<()> {
308325
let store = TestObjectStore::new_arc(&[("table/p1=v1/file.avro", 100)]);

0 commit comments

Comments
 (0)