nathanb9 commented on code in PR #22322:
URL: https://github.com/apache/datafusion/pull/22322#discussion_r3274978748


##########
datafusion/core/benches/multi_group_by.rs:
##########
@@ -0,0 +1,219 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Benchmarks for multi-column GROUP BY performance.
+//!
+//! Tests the performance of grouping across different cardinality
+//! scenarios and column counts. Uses Parquet files so that column
+//! statistics (min/max) are available to the optimizer for heuristic
+//! decisions about GroupValues implementation selection.
+//!
+//! The benchmark pre-plans the query and only measures execution time
+//! (excludes planning and I/O setup overhead).
+
+use arrow::array::{ArrayRef, Int32Array, RecordBatch};
+use arrow::datatypes::{DataType, Field, Schema};
+use criterion::{Criterion, criterion_group, criterion_main};
+use datafusion::prelude::{SessionConfig, SessionContext};
+use parking_lot::Mutex;
+use parquet::arrow::ArrowWriter;
+use parquet::file::properties::WriterProperties;
+use rand::rngs::StdRng;
+use rand::{Rng, SeedableRng};
+use std::hint::black_box;
+use std::sync::Arc;
+use tempfile::NamedTempFile;
+use tokio::runtime::Runtime;
+
+const NUM_ROWS: usize = 1_000_000;
+const BATCH_SIZE: usize = 8192;
+
+fn build_group_by_sql(num_cols: usize) -> String {
+    let cols: Vec<String> = (0..num_cols).map(|i| 
format!("col_{i}")).collect();
+    let col_list = cols.join(", ");
+    format!("SELECT {col_list} FROM t GROUP BY {col_list}")
+}
+
+fn generate_parquet_file(num_cols: usize, cardinality: usize) -> NamedTempFile 
{
+    let mut rng = StdRng::seed_from_u64(42);
+    let fields: Vec<Field> = (0..num_cols)

Review Comment:
   > but this benchmark never exercises the row-based path, so it cannot really 
validate the claimed crossover point.
   
   Yes, the way I benchmarked is by making code change to enforce one or the 
other and run them separately.
   



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to