diff --git a/benchmarks/bench.sh b/benchmarks/bench.sh index 419fd5be3ad2b..0a44cf3d7f8b1 100755 --- a/benchmarks/bench.sh +++ b/benchmarks/bench.sh @@ -164,6 +164,7 @@ nlj: Benchmark for simple nested loop joins, testing various hj: Benchmark for simple hash joins, testing various join scenarios smj: Benchmark for simple sort merge joins, testing various join scenarios dict: Benchmark for dictionary-encoded group-by scenarios +array_agg_distinct: 10K-group, two-row-per-group array_agg(DISTINCT) benchmark compile_profile: Compile and execute TPC-H across selected Cargo profiles, reporting timing and binary size @@ -651,6 +652,9 @@ main() { dict) run_dict ;; + array_agg_distinct) + run_array_agg_distinct + ;; compile_profile) run_compile_profile "${PROFILE_ARGS[@]}" ;; @@ -1661,6 +1665,14 @@ run_dict() { debug_run $CARGO_COMMAND --bin dfbench -- dict --iterations 5 -o "${RESULTS_FILE}" ${QUERY_ARG} ${LATENCY_ARG} } +# Runs the data-free high-cardinality array_agg(DISTINCT) SQL benchmark. +run_array_agg_distinct() { + echo "Running array_agg_distinct benchmark..." + debug_run env BENCH_NAME=array_agg_distinct \ + ${QUERY:+BENCH_QUERY="${QUERY}"} \ + bash -c "$SQL_CARGO_COMMAND" +} + compare_benchmarks() { BASE_RESULTS_DIR="${SCRIPT_DIR}/results" diff --git a/benchmarks/sql_benchmarks/array_agg_distinct/array_agg_distinct.suite b/benchmarks/sql_benchmarks/array_agg_distinct/array_agg_distinct.suite new file mode 100644 index 0000000000000..b114854f14f54 --- /dev/null +++ b/benchmarks/sql_benchmarks/array_agg_distinct/array_agg_distinct.suite @@ -0,0 +1,11 @@ +description = "High-cardinality array_agg(DISTINCT) SQL benchmarks" + +query_pattern = "q{QUERY_ID_PADDED}.benchmark" + +[[examples]] +command = "cargo run --release --bin benchmark_runner -- array_agg_distinct" +description = "Run the high-cardinality array_agg(DISTINCT) benchmark." + +[[examples]] +command = "cargo run --release --bin benchmark_runner -- array_agg_distinct --query 1 --iterations 5 --output /tmp/array_agg_distinct.json" +description = "Run five iterations and write comparable JSON results." diff --git a/benchmarks/sql_benchmarks/array_agg_distinct/benchmarks/q01.benchmark b/benchmarks/sql_benchmarks/array_agg_distinct/benchmarks/q01.benchmark new file mode 100644 index 0000000000000..283f7e80f2275 --- /dev/null +++ b/benchmarks/sql_benchmarks/array_agg_distinct/benchmarks/q01.benchmark @@ -0,0 +1,11 @@ +name Q01 +group array_agg_distinct + +expect_plan AggregateExec + +run +-- 10K groups, 2 rows/group, and 2 distinct values/group. `range` is end-exclusive. +-- This is data-free so comparisons isolate grouped array_agg(DISTINCT) execution. +SELECT value / 2 AS k, array_agg(DISTINCT value % 2) AS distinct_values +FROM range(20000) +GROUP BY value / 2;