[fix](agg) Fix distinct aggregate argument grouping and strategy selection (#65368) ### What problem does this PR solve? Problem Summary: The Nereids distinct aggregate planning logic had several correctness issues: 1. `CheckMultiDistinct` determined distinct groups from all aggregate arguments instead of the semantic DISTINCT arguments. This incorrectly treated separators and ORDER BY expressions as deduplication keys and mishandled aggregates whose DISTINCT argument sets were equivalent but ordered differently, such as `COUNT(DISTINCT a, b)` and `COUNT(DISTINCT b, a)`. 2. `GROUP_CONCAT` accepted a column expression as its separator. During distinct aggregate rewriting, this extra input could incorrectly participate in deduplication even though DISTINCT semantics only apply to the value argument. 3. Forced `agg_phase=3/4` could override `GROUP_CONCAT(DISTINCT ... ORDER BY ...)`'s requirement to use the multi-distinct implementation. Conversely, early logical splitting could prevent forced three/four-phase aggregation from being honored. 4. `AggregateUtils#getDistinctNamedExpr` collected all aggregate arguments rather than only semantic DISTINCT arguments. This PR: - Compares DISTINCT aggregates by their semantic DISTINCT argument groups. - Treats equivalent argument sets as one distinct group. - Requires the separator of `GROUP_CONCAT` and `MULTI_DISTINCT_GROUP_CONCAT` to be a constant. - Introduces explicit strategy selection between logical splitting, multi-distinct aggregation, and Cascades multi-phase splitting. - Preserves `mustUseMultiDistinctAgg()` when `agg_phase` is forced. - Lets `agg_phase=3/4` retain the original DISTINCT aggregate for Cascades phase planning. - Rejects queries that combine `GROUP_CONCAT(DISTINCT ... ORDER BY ...)` with a multi-argument `COUNT(DISTINCT ...)`, because their required aggregation strategies are incompatible. - Uses `AggregateFunction#getDistinctArguments()` when collecting distinct deduplication keys. ### Release note `GROUP_CONCAT` and `MULTI_DISTINCT_GROUP_CONCAT` now require the separator argument to be a constant. Queries combining `GROUP_CONCAT(DISTINCT ... ORDER BY ...)` with a multi-argument `COUNT(DISTINCT ...)` are rejected with a clear analysis error.
English • العربية • বাংলা • Deutsch • Español • فارسی • Français • हिन्दी • Bahasa Indonesia • Italiano • 日本語 • 한국어 • Polski • Português • Română • Русский • Slovenščina • ไทย • Türkçe • Українська • Tiếng Việt • 简体中文 • 繁體中文
Apache Doris is an open-source, real-time analytics and search database built on MPP architecture. It provides fast SQL analytics, lakehouse query acceleration, and hybrid search across structured, text, and vector data.
Explore the official website for the latest product overview, use cases, ecosystem updates, blogs, and user stories. For version updates, see all release notes.
| Use Case | What it provides |
|---|---|
| Customer-Facing Analytics | Ship sub-second interactive analytics to external users. |
| Data Warehousing | Build one real-time warehouse across business domains. |
| Observability | Analyze high-throughput logs, events, and metrics with SQL. |
| Doris for AI | Use vector, text, JSON, and structured search in one SQL engine. |
Apache Doris is built around three core capabilities. The website is the source of truth for detailed product descriptions and examples.
| Capability | What it provides |
|---|---|
| Real-Time Analytics | Streaming ingestion, incremental transformation, and sub-second queries under high concurrency. |
| Lakehouse Analytics | Fast SQL analytics over open table formats such as Iceberg, Delta Lake, and Hudi. |
| Hybrid Search | SQL-native analytics across JSON, full-text, and vector data for AI and search workloads. |
Doris sits at the center of the modern data stack. It connects upstream databases, streaming systems, and lakehouse storage with downstream BI, AI, analytics, and observability tools.
For the latest ecosystem coverage, visit the official website and the connection and integration documentation.
Apache Doris supports both compute-storage coupled and compute-storage decoupled deployments. In decoupled mode, stateless compute groups run over shared object storage, so you can scale compute on demand and isolate workloads.
Learn more in the deployment guide and deployment mode guide.
| Resource | What it provides |
|---|---|
| Community Report | Weekly updates on community activity, merged PRs, contributors, and feature progress. |
| Roadmap 2026 | The 2026 planning discussion for AI and hybrid search, query engine, storage, and data lake work. |
Doris provides connectors and tools for common data engineering workflows.
Apache Doris is used in production by thousands of companies worldwide across internet services, finance, retail, logistics, manufacturing, energy, telecommunications, AI, and other industries.
Apache Doris graduated from the Apache Incubator and became an Apache Top-Level Project in June 2022. Thanks to all community contributors who help build Doris.
Note Some licenses of the third-party dependencies are not compatible with Apache 2.0 License. So you need to disable some Doris features to comply with Apache 2.0 License. For details, refer to the
thirdparty/LICENSE.txt