feat(typing): add databricks type inference for REGEXP_INSTR, REGEXP_LIKE, REGEXP_SUBSTR, REGR_AVGX#7815
Open
fivetran-amrutabhimsenayachit wants to merge 2 commits into
Open
feat(typing): add databricks type inference for REGEXP_INSTR, REGEXP_LIKE, REGEXP_SUBSTR, REGR_AVGX#7815fivetran-amrutabhimsenayachit wants to merge 2 commits into
fivetran-amrutabhimsenayachit wants to merge 2 commits into
Conversation
…LIKE, REGEXP_SUBSTR, REGR_AVGX
Contributor
SQLGlot Integration Test Results✅ All tests passedComparing: By Dialect
Overallmain: 192428 total, 153523 passed (pass rate: 79.8%) sqlglot:type-inference-batch-2: 180234 total, 142394 passed (pass rate: 79.0%) Transitions: Dialect pair changes: 0 previous results not found, 3 current results not found ✅ All tests passed |
…TR round-trip in databricks
geooo109
reviewed
Jun 30, 2026
| VARCHAR; | ||
|
|
||
| # dialect: databricks | ||
| REGR_AVGX(tbl.double_col, tbl.double_col); |
Collaborator
There was a problem hiding this comment.
Let's also add tests containing the ALL, DISTINCT, andREGR_AVGX(...) OVER (PARTITION BY 1)
Comment on lines
+480
to
+481
| class RegexpSubstr(Expression, Func): | ||
| arg_types = {"this": True, "expression": True} |
Collaborator
There was a problem hiding this comment.
Can you check if we can reuse exp.RegexpExtract for this? The default group should be 0 here. So, check the semantics for regexp_extract vs regexp_substr, if they match (for group 0), we can reuse the existing expression. If they don't match, let's keep this addition and add round-trip tests.
Minimal example:
SELECT regexp_extract('Order: 100-200', '(\\d+)-(\\d+)', 0)
> 100-200
SELECT regexp_substr('Order: 100-200', '(\\d+)-(\\d+)')
> 100 -200
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 REGEXP_INSTR (INT), REGEXP_LIKE (BOOLEAN via fixture), REGEXP_SUBSTR (VARCHAR via parser mapping to RegexpExtract), and REGR_AVGX (DOUBLE), plus fixture coverage for all four functions.
Tickets
Test plan
make style— PASSmake unit— PASS