You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/07 09:12:00 UTC

[GitHub] [arrow-datafusion] Arvamer opened a new issue, #2176: Ignored alias for columns with aggregate function and incorrect results when collecting statistics is enabled

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: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] tustvold closed issue #2176: Ignored alias for columns with aggregate function and incorrect results when collecting statistics is enabled

Posted by GitBox <gi...@apache.org>.
tustvold closed issue #2176: Ignored alias for columns with aggregate function and incorrect results when collecting statistics is enabled
URL: https://github.com/apache/arrow-datafusion/issues/2176


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org