Repository navigation
Conversation
sqlglot parses T-SQL STDEV (sample) into sge.Stddev, but the MSSQL generator rendered that node as STDEVP (population). Same-dialect round-trips through Table.sql() therefore changed the statistic. StddevPop already maps to STDEVP; Variance already maps to the sample function, so this matches that pattern. Closes #12057
Contributor
|
This was marked as potentially AI generated and will be closed now. If this is an error, please provide additional details, make sure to read the docs about contributing and AI. |
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.
Summary
Closes #12057.
The MSSQL dialect mapped bare
sge.StddevtoSTDEVP(population). sqlglot parses T-SQLSTDEV— the sample function — into that node, so a same-dialect re-render silently changed the statistic.sge.StddevPopalready rendersSTDEVP, and three lines belowsge.Variancealready maps to the sampleVAR, so this looks like a typo rather than an intentional choice. Vanilla sqlglot'stsqldialect already round-tripsSTDEVcorrectly.Reproduction path
Backend.sql(query)withoutdialect=returns early and does not transpile. The path that does hit this isTable.sql()/add_query_to_expr, which re-renders unconditionally:Ibis's own
t.x.std(how="sample"|"pop")compilation already went throughStddevSamp/StddevPopand was unaffected; the tests lock that in.Test plan
pytest ibis/backends/sql/tests/test_compiler.py::test_mssql_stdev_roundtrips_as_sample -o addopts=pytest ibis/backends/sql/tests/test_compiler.py::test_mssql_std_how_emits_distinct_functions -o addopts=stdevp