Repository navigation
Add STDDEV as case-insensitive alias of stddevPop - #105120
Merged
Merged
Conversation
PostgreSQL/SQL-standard `STDDEV` is the standard short form for the population standard deviation. ClickHouse already exposes the related synonyms `STDDEV_POP`, `STDDEV_SAMP`, `STD`; add `STDDEV` to spare PostgreSQL-dialect workloads a rewrite when querying ClickHouse. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [032191b] Summary: ✅ AI ReviewSummaryThe PR adds Final VerdictStatus: ✅ Approve |
alexey-milovidov
added a commit
that referenced
this pull request
May 16, 2026
Recent compatibility PRs added case-insensitive aliases and parser sugar that make several of the SQLStorm rewrites unnecessary: - `STDDEV` -> `stddevPop` (#105120) - `array_to_string` -> `arrayStringConcat` (#105121) - `REGEXP_SUBSTR` -> `regexpExtract` (#105122) - `CARDINALITY` -> `length` (#105123) - `unnest()` function -> `arrayJoin()` (#105124) - `STRING_AGG` -> `groupConcat` (#105125) - `date_part(unit,e)` -> `EXTRACT(unit FROM e)` (#105127) - `expr OP ANY/ALL(array_literal)` (#105129) `ARRAY_AGG`, `TRANSLATE`, and `EXTRACT(EPOCH|DOW|... FROM ...)` were already supported by ClickHouse before these PRs. Removed the corresponding rewrite calls and helper functions (`rewrite_string_agg`, `rewrite_array_agg`, `rewrite_date_part`, `rewrite_stddev`, `rewrite_extract_epoch`, the EXTRACT(DOW) inline rewrite, `rewrite_any_comparison`, and the trailing `unnest(...) -> arrayJoin(...)` substitution). Also dropped the unreferenced no-op helpers (`rewrite_extract_unit`, `rewrite_fetch_offset`, `rewrite_interval`, `rewrite_cast_timestamp`, `rewrite_current_timestamp`, `rewrite_bool_literals`, `rewrite_ilike`, `rewrite_no_supertype`). The PostgreSQL `LATERAL` / `CROSS JOIN UNNEST(...)` table-source forms, `arrayJoin(...)` in JOIN position, PG-specific casts, `AT TIME ZONE`, `STRING_AGGDistinct` (a mangled-name artifact), and the still-unsupported function rewrites (`string_to_array`, `regexp_split_to_array`, `RANDOM`, `TO_TIMESTAMP`, `ARRAY_LENGTH`, `SPLIT_PART`, `age`) are still rewritten. Net change: -329 lines from rewrite_queries.py and -75 lines from the tests (the `TestRewriteAnyComparison` class is removed since the rewrite it covered no longer exists). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
PostgreSQL, Oracle, BigQuery, Snowflake, and DuckDB all treat `STDDEV` as the sample standard deviation (`STDDEV_SAMP`, denominator `n - 1`), not the population one. Mapping it to `stddevPop` would silently change results for PostgreSQL-dialect queries (e.g., the SQLStorm corpus) that this alias was added to support. Re-point `STDDEV` to `stddevSamp` and update the test accordingly. `STD` stays mapped to `stddevPop` because that matches MySQL semantics. Addresses #105120 (comment) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
m-selmi
approved these changes
May 18, 2026
Contributor
LLVM Coverage Report
Changed lines: 100.00% (5/5) · Uncovered code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PostgreSQL/SQL-standard
STDDEVis the standard short form for the sample standard deviation (denominatorn - 1). PostgreSQL, Oracle, BigQuery, Snowflake, and DuckDB all alias it toSTDDEV_SAMP. This PR addsSTDDEVas a case-insensitive alias ofstddevSampso that PostgreSQL-dialect queries (e.g., the SQLStorm corpus) do not need rewriting and do not silently change results.ClickHouse already exposes
STDDEV_POP,STDDEV_SAMP, andSTD(the MySQL-style population alias), so this is purely additive.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added
STDDEVas a case-insensitive alias ofstddevSampfor PostgreSQL/SQL-standard compatibility.Documentation entry for user-facing changes
Version info
26.5.1.786