Skip to content

fix(mssql): map bare Stddev to stdev, not stdevp - #12083

Open
Maksim-Burtsev wants to merge 1 commit into
ibis-project:mainfrom
Maksim-Burtsev:fix-mssql-stdev
Open

fix(mssql): map bare Stddev to stdev, not stdevp#12083
Maksim-Burtsev wants to merge 1 commit into
ibis-project:mainfrom
Maksim-Burtsev:fix-mssql-stdev

Conversation

@Maksim-Burtsev

Copy link
Copy Markdown

Closes #12057.

sqlglot.transpile("SELECT STDEV([x]) FROM [t]", read=MSSQL, write=MSSQL) returns
STDEVP — sample in, population out. sge.Variance three lines below already maps
to var, the sample function, so this reads as a typo rather than a decision.

Our own compilation never emits a bare Stddev (it goes through stddev_samp /
stddev_pop), so only raw SQL through Backend.sql() was affected. Test round-trips
the four functions through the dialect, no backend needed.

Oracle's Stddev and MySQL's Variance look like the same mismatch. Left alone —
tell me if you want them in a follow-up.

T-SQL STDEV is the sample deviation and STDEVP the population one, so
round-tripping raw SQL through Backend.sql() silently changed which
statistic was computed. sge.Variance three lines below already maps to
the sample function.

Our own compilation never emits a bare Stddev, it goes through
stddev_samp/stddev_pop, so only raw SQL was affected.
@github-actions github-actions Bot added tests Issues or PRs related to tests sql Backends that generate SQL labels Aug 20, 2026
@deepyaman deepyaman added the maybe-ai Apply to low-effort autonomous PRs to automatically close them. label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maybe-ai Apply to low-effort autonomous PRs to automatically close them. sql Backends that generate SQL tests Issues or PRs related to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: MSSQL dialect rewrites STDEV (sample) to STDEVP (population) when round-tripping SQL through Backend.sql()

2 participants