-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Partial Parsing support for function nodes #12074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
QMalcolm
wants to merge
4
commits into
main
Choose a base branch
from
qmalcolm--12072-support-for-partial-parsing-functions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
49bce54
Explicitly support functions during partial parsing
QMalcolm 7b4646e
Emit a `Note` event when partial parsing is skipped due to there bein…
QMalcolm b035da7
Begin testing partial parsing support of function nodes
QMalcolm 458bdaf
Add changie doc
QMalcolm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| kind: Features | ||
| body: Support partial parsing for function nodes | ||
| time: 2025-10-06T14:03:52.258104-05:00 | ||
| custom: | ||
| Author: QMalcolm | ||
| Issue: "12072" |
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import pytest | ||
|
|
||
| from dbt.artifacts.resources import FunctionArgument, FunctionReturns | ||
| from dbt.contracts.graph.manifest import Manifest | ||
| from dbt.tests.util import run_dbt, write_file | ||
| from dbt_common.events.types import Note | ||
| from tests.functional.partial_parsing.fixtures import ( | ||
| my_func_sql, | ||
| my_func_yml, | ||
| updated_my_func_sql, | ||
| updated_my_func_yml, | ||
| ) | ||
| from tests.utils import EventCatcher | ||
|
|
||
|
|
||
| class TestPartialParsingFunctions: | ||
| @pytest.fixture(scope="class") | ||
| def functions(self): | ||
| return { | ||
| "my_func.sql": my_func_sql, | ||
| "my_func.yml": my_func_yml, | ||
| } | ||
|
|
||
| def test_pp_functions(self, project): | ||
| # initial run | ||
| manifest = run_dbt(["parse"]) | ||
| assert isinstance(manifest, Manifest) | ||
| assert len(manifest.functions) == 1 | ||
| function = manifest.functions["function.test.my_func"] | ||
| assert function.raw_code == "value * 2" | ||
| assert function.description == "Doubles an integer" | ||
| assert function.arguments == [ | ||
| FunctionArgument(name="value", data_type="int", description="An integer to be doubled") | ||
| ] | ||
| assert function.returns == FunctionReturns(data_type="int") | ||
|
|
||
| # update sql | ||
| write_file(updated_my_func_sql, project.project_root, "functions", "my_func.sql") | ||
| manifest = run_dbt(["parse"]) | ||
| assert isinstance(manifest, Manifest) | ||
| assert len(manifest.functions) == 1 | ||
| function = manifest.functions["function.test.my_func"] | ||
| assert function.raw_code == "number * 2.0" | ||
| assert function.description == "Doubles an integer" | ||
| assert function.arguments == [ | ||
| FunctionArgument(name="value", data_type="int", description="An integer to be doubled") | ||
| ] | ||
| assert function.returns == FunctionReturns(data_type="int") | ||
|
|
||
| # update yml | ||
| write_file(updated_my_func_yml, project.project_root, "functions", "my_func.yml") | ||
| manifest = run_dbt(["parse"]) | ||
| assert isinstance(manifest, Manifest) | ||
| assert len(manifest.functions) == 1 | ||
| function = manifest.functions["function.test.my_func"] | ||
| assert function.raw_code == "number * 2.0" | ||
| assert function.description == "Doubles a float" | ||
| assert function.arguments == [ | ||
| FunctionArgument(name="number", data_type="float", description="A float to be doubled") | ||
| ] | ||
| assert function.returns == FunctionReturns(data_type="float") | ||
|
|
||
| # if we parse again, partial parsing should be skipped | ||
| note_catcher = EventCatcher(Note) | ||
| manifest = run_dbt(["parse"], callbacks=[note_catcher.catch]) | ||
| assert isinstance(manifest, Manifest) | ||
| assert len(manifest.functions) == 1 | ||
| assert len(note_catcher.caught_events) == 1 | ||
| assert ( | ||
| note_catcher.caught_events[0].info.msg == "Nothing changed, skipping partial parsing." | ||
| ) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the number of parameters has changed, is that something that's detected at parse time? Or only compilation time? If it's detected at parse time, then we should schedule referencing nodes in order to get that error. If it's not detected at parse time, this is fine.