Arvamer opened a new issue, #2176:
URL: https://github.com/apache/arrow-datafusion/issues/2176
**Describe the bug**
For parquet files, when `collect_stat` is set to `true`, alias for columns
with aggregate function is ignored and for some data types null is returned.
Current master (f0200b0a963bb817a6dad96a0b1fe0d06576004b).
**To Reproduce**
```rust
use std::{sync::Arc, thread};
use anyhow::Result;
use datafusion::{
datasource::{
file_format::parquet::{ParquetFormat, DEFAULT_PARQUET_EXTENSION},
listing::ListingOptions,
},
logical_plan::{col, max},
prelude::SessionContext,
};
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let threads = thread::available_parallelism()?.get();
let options = ListingOptions {
file_extension: DEFAULT_PARQUET_EXTENSION.to_owned(),
format: Arc::new(ParquetFormat::default()),
table_partition_cols: vec![],
collect_stat: false,
target_partitions: threads,
};
let path = "data.parquet";
let ctx = SessionContext::new();
ctx.register_listing_table("data", path, options, None)
.await?;
let data = ctx.table("data")?;
data.show().await?;
data.aggregate(vec![], vec![max(col("day")).alias("max_day")])?
.show()
.await?;
data.aggregate(vec![], vec![max(col("txt")).alias("max_txt")])?
.show()
.await?;
data.aggregate(vec![], vec![max(col("int")).alias("max_int")])?
.show()
.await?;
Ok(())
}
```
```
+------------+-----+-----+
| day | txt | int |
+------------+-----+-----+
| 2022-01-02 | abc | 11 |
| 2022-01-03 | abb | 10 |
| 2022-01-01 | bbb | 12 |
+------------+-----+-----+
+----------+
| MAX(day) |
+----------+
| |
+----------+
+----------+
| MAX(txt) |
+----------+
| |
+----------+
+----------+
| MAX(int) |
+----------+
| 12 |
+----------+
```
**Expected behavior**
Queries should return:
```
+------------+
| max_day |
+------------+
| 2022-01-03 |
+------------+
+---------+
| max_txt |
+---------+
| bbb |
+---------+
+---------+
| max_int |
+---------+
| 12 |
+---------+
```
[reproduction.zip](https://github.com/apache/arrow-datafusion/files/8441367/reproduction.zip)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]