mkleen commented on PR #25126: URL: https://github.com/apache/datafusion/pull/25126#issuecomment-5634195706
I just checked this against duckdb and they do the same optimization: ``` D explain SELECT g, min(DISTINCT x) FROM t GROUP BY g; ┌─────────────────────────────┐ │┌───────────────────────────┐│ ││ Unoptimized Logical Plan ││ │└───────────────────────────┘│ └─────────────────────────────┘ ┌───────────────────────────┐ │ PROJECTION │ │ ──────────────────── │ │ Expressions: │ │ g │ │ min(DISTINCT x) │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ AGGREGATE │ │ ──────────────────── │ │ Groups: g │ │ │ │ Expressions: │ │ min(DISTINCT x) │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ SEQ_SCAN │ │ ──────────────────── │ │ Table: t │ │ Type: Sequential Scan │ └───────────────────────────┘ ┌─────────────────────────────┐ │┌───────────────────────────┐│ ││ Optimized Logical Plan ││ │└───────────────────────────┘│ └─────────────────────────────┘ ┌───────────────────────────┐ │ PROJECTION │ │ ──────────────────── │ │ Expressions: │ │ g │ │ min(DISTINCT x) │ │ │ │ ~2,322 rows │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ PROJECTION │ │ ──────────────────── │ │ Expressions: │ │__internal_decompress_integ│ │ ral_bigint(#0, 0) │ │ #1 │ │ │ │ ~2,322 rows │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ AGGREGATE │ │ ──────────────────── │ │ Groups: g │ │ Expressions: min(x) │ <- distinct is removed │ │ │ ~2,322 rows │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ PROJECTION │ │ ──────────────────── │ │ Expressions: │ │__internal_compress_integra│ │ l_usmallint(#0, 0) │ │ #1 │ │ │ │ ~4,000,000 rows │ └─────────────┬─────────────┘ ┌─────────────┴─────────────┐ │ SEQ_SCAN │ │ ──────────────────── │ │ Table: t │ │ Type: Sequential Scan │ │ │ │ ~4,000,000 rows │ └───────────────────────────┘ ``` -- 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]
