fix(optimizer)!: annotate type for databricks REGR_AVGY, REGR_COUNT, REGR_INTERCEPT, REGR_R2, REGR_SLOPE#7820
Merged
Conversation
3e9a43d to
3bd5b3f
Compare
Contributor
SQLGlot Integration Test Results✅ All tests passedComparing: Overallmain: 192416 total, 153530 passed (pass rate: 79.8%) sqlglot:type-inference-batch-3: 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 2, 2026
780a37e to
d73df08
Compare
geooo109
reviewed
Jul 3, 2026
geooo109
reviewed
Jul 3, 2026
731d1ef to
7a265fb
Compare
geooo109
reviewed
Jul 6, 2026
d0e7e96 to
8df4873
Compare
geooo109
reviewed
Jul 8, 2026
Collaborator
|
In the tests, let's also check where the |
…E] (#7823) `Resolver._get_column_type_from_scope` resolves the element type of an unnested/exploded column by recursing over the sources of each scope. It had no memoization, so when the same CTE is reachable through several paths of the scope graph, its subtree was re-walked once per path. Qualifying a query whose CTEs reconverge on a shared upstream CTE was therefore exponential in the depth of the graph, for a single UNNEST/EXPLODE. On a real query this reached ~3.8M calls (~4s) into the trace. The scope and schema are immutable during qualification, so the type of a column under a given source depends only on `(source, column name)`. Cache the result on that key so each source is walked once, which makes the trace roughly linear in the size of the scope graph. Qualified output is unchanged. Reached through both BigQuery `UNNEST(col)` and Spark/Hive `LATERAL VIEW EXPLODE(col)`. Closes #7821 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…* functions in databricks [CLAUDE]
823a114 to
ca93ea1
Compare
ca93ea1 to
02cbca0
Compare
geooo109
approved these changes
Jul 8, 2026
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_AVGY (DOUBLE), REGR_COUNT (BIGINT), REGR_INTERCEPT (DOUBLE), REGR_R2 (DOUBLE), and REGR_SLOPE (DOUBLE), plus fixture coverage for all five functions.
Issue: REGR_FUNC(DISTINCT col1, col2) raised a parse error in Databricks because the base parser's DISTINCT handler consumed all comma-separated arguments into a single node, leaving the second required argument missing.
Fix: Added a custom parser method in DatabricksParser that reads only the first argument under DISTINCT, then parses the rest normally.
Tickets
Test plan
make style— PASSmake unit— PASS