Skip to content

Commit

Permalink
extend test to all file formats
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 12, 2022
1 parent 20b0857 commit dfe86ef
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions polars/polars-lazy/src/tests/projection_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,27 @@ fn test_join_suffix_and_drop() -> Result<()> {
}

#[test]
fn test_union_and_aggscan() -> Result<()> {
fn test_union_and_agg_projections() -> Result<()> {
init_files();
// a union vstacks columns and aggscan optimization determines columns to aggregate in a
// hashmap, if that doesn't set them sorted the vstack will panic.
let glob = "../../examples/aggregate_multiple_files_in_chunks/datasets/*.parquet";
let lf = LazyFrame::scan_parquet(glob.into(), Default::default())?;

let lf = lf.filter(col("category").eq(lit("vegetables"))).select([
col("fats_g").sum().alias("sum"),
col("fats_g").cast(DataType::Float64).mean().alias("mean"),
]);

let out = lf.collect()?;
assert_eq!(out.shape(), (1, 2));
let lf1 = LazyFrame::scan_parquet(glob.into(), Default::default())?;
let glob = "../../examples/aggregate_multiple_files_in_chunks/datasets/*.ipc";
let lf2 = LazyFrame::scan_ipc(glob.into(), Default::default())?;
let glob = "../../examples/aggregate_multiple_files_in_chunks/datasets/*.csv";
let lf3 = LazyCsvReader::new(glob.into()).finish()?;

for lf in [lf1, lf2, lf3] {
let lf = lf.filter(col("category").eq(lit("vegetables"))).select([
col("fats_g").sum().alias("sum"),
col("fats_g").cast(DataType::Float64).mean().alias("mean"),
col("fats_g").min().alias("min"),
]);

let out = lf.collect()?;
assert_eq!(out.shape(), (1, 3));
}

Ok(())
}

0 comments on commit dfe86ef

Please sign in to comment.