feat(optimizer)!: type annotation for databricks REGR_SXX, REGR_SXY, REGR_SYY#7851
Open
fivetran-amrutabhimsenayachit wants to merge 3 commits into
Open
feat(optimizer)!: type annotation for databricks REGR_SXX, REGR_SXY, REGR_SYY#7851fivetran-amrutabhimsenayachit wants to merge 3 commits into
fivetran-amrutabhimsenayachit wants to merge 3 commits into
Conversation
Contributor
SQLGlot Integration Test Results✅ All tests passedComparing: Overallmain: 192416 total, 153532 passed (pass rate: 79.8%) sqlglot:type-inference-batch-4: 180222 total, 142385 passed (pass rate: 79.0%) Transitions: Dialect pair changes: 0 previous results not found, 3 current results not found ✅ All tests passed |
geooo109
reviewed
Jul 10, 2026
geooo109
reviewed
Jul 10, 2026
Comment on lines
+120
to
+134
| def regrsxx_sql(self, expression: exp.RegrSxx) -> str: | ||
| x = expression.expression | ||
| if isinstance(x, exp.Distinct): | ||
| return self.func( | ||
| "REGR_SXX", exp.Distinct(expressions=[expression.this]), *x.expressions | ||
| ) | ||
| return self.func("REGR_SXX", expression.this, x) | ||
|
|
||
| def regrsyy_sql(self, expression: exp.RegrSyy) -> str: | ||
| x = expression.expression | ||
| if isinstance(x, exp.Distinct): | ||
| return self.func( | ||
| "REGR_SYY", exp.Distinct(expressions=[expression.this]), *x.expressions | ||
| ) | ||
| return self.func("REGR_SYY", expression.this, x) |
Collaborator
There was a problem hiding this comment.
Let's refactor here:
def _regr_sql(self, expression: exp.RegrAvgx | exp.RegrSxx | exp.RegrSyy) -> str:
name = expression.sql_name()
x = expression.expression
if isinstance(x, exp.Distinct):
return self.func(name, exp.Distinct(expressions=[expression.this]), *x.expressions)
return self.func(name, expression.this, x)
Then we can resue this ^ for all the 3 cases.
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
Adds Databricks type inference support for REGR_SXX (DOUBLE), REGR_SXY (DOUBLE), and REGR_SYY (DOUBLE), including a parser fix to handle the DISTINCT modifier correctly for these two-argument aggregates.
Tickets
Test plan
make style— PASSmake unit— PASS (1342 tests, 0 failures)test_annotate_funcsfixture — PASS