Skip to content

Commit 56f464f

Browse files
committed
fix erro on Count(Expr:Wildcard) with DataFrame API
1 parent 146a949 commit 56f464f

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

datafusion/core/tests/dataframe.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,59 @@ use datafusion::{assert_batches_eq, assert_batches_sorted_eq};
3535
use datafusion_expr::expr::{GroupingSet, Sort};
3636
use datafusion_expr::{avg, col, count, lit, max, sum, Expr, ExprSchemable};
3737

38+
#[tokio::test]
39+
async fn count_wildcard() -> Result<()> {
40+
let ctx = SessionContext::new();
41+
42+
let testdata = datafusion::test_util::parquet_test_data();
43+
let df = ctx
44+
.read_parquet(
45+
&format!("{testdata}/alltypes_tiny_pages.parquet"),
46+
ParquetReadOptions::default(),
47+
)
48+
.await?;
49+
50+
let results = df
51+
.clone()
52+
.aggregate(vec![], vec![count(Expr::Wildcard)])?
53+
.explain(false, false)
54+
.unwrap()
55+
.collect()
56+
.await?;
57+
58+
let expected = vec![
59+
"+---------------+---------------------------------------------------+",
60+
"| plan_type | plan |",
61+
"+---------------+---------------------------------------------------+",
62+
"| | |",
63+
"| | EmptyExec: produce_one_row=true |",
64+
"| | TableScan: ?table? projection=[id] |",
65+
"| logical_plan | Aggregate: groupBy=[[]], aggr=[[COUNT(UInt8(1))]] |",
66+
"| physical_plan | ProjectionExec: expr=[7300 as COUNT(UInt8(1))] |",
67+
"+---------------+---------------------------------------------------+",
68+
];
69+
assert_batches_sorted_eq!(expected, &results);
70+
71+
let results = df
72+
.clone()
73+
.aggregate(vec![], vec![count(Expr::Wildcard)])?
74+
.collect()
75+
.await?;
76+
77+
print_batches(&results);
78+
79+
let expected = vec![
80+
"+-----------------+",
81+
"| COUNT(UInt8(1)) |",
82+
"+-----------------+",
83+
"| 7300 |",
84+
"+-----------------+",
85+
];
86+
assert_batches_sorted_eq!(expected, &results);
87+
88+
Ok(())
89+
}
90+
3891
#[tokio::test]
3992
async fn describe() -> Result<()> {
4093
let ctx = SessionContext::new();

0 commit comments

Comments
 (0)