mirror of
https://github.com/dbt-labs/dbt-core
synced 2025-12-17 19:31:34 +00:00
Correct Function Node Property Names (#12065)
* Fix function node property names `return_type` -> `returns` `return_type.type` -> `returns.data_type` `arguments[x].type` -> `arguments[x].data_type` * Add changie doc
This commit is contained in:
6
.changes/unreleased/Fixes-20251002-121427.yaml
Normal file
6
.changes/unreleased/Fixes-20251002-121427.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
kind: Fixes
|
||||||
|
body: Fix property names of function nodes (arguments.data_type, returns, returns.data_type)
|
||||||
|
time: 2025-10-02T12:14:27.305546-05:00
|
||||||
|
custom:
|
||||||
|
Author: QMalcolm
|
||||||
|
Issue: "12064"
|
||||||
@@ -40,7 +40,7 @@ from dbt.artifacts.resources.v1.function import (
|
|||||||
FunctionArgument,
|
FunctionArgument,
|
||||||
FunctionConfig,
|
FunctionConfig,
|
||||||
FunctionMandatory,
|
FunctionMandatory,
|
||||||
FunctionReturnType,
|
FunctionReturns,
|
||||||
)
|
)
|
||||||
from dbt.artifacts.resources.v1.generic_test import GenericTest, TestMetadata
|
from dbt.artifacts.resources.v1.generic_test import GenericTest, TestMetadata
|
||||||
from dbt.artifacts.resources.v1.group import Group, GroupConfig
|
from dbt.artifacts.resources.v1.group import Group, GroupConfig
|
||||||
|
|||||||
@@ -26,19 +26,19 @@ class FunctionConfig(NodeConfig):
|
|||||||
@dataclass
|
@dataclass
|
||||||
class FunctionArgument(dbtClassMixin):
|
class FunctionArgument(dbtClassMixin):
|
||||||
name: str
|
name: str
|
||||||
type: str
|
data_type: str
|
||||||
description: Optional[str] = None
|
description: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class FunctionReturnType(dbtClassMixin):
|
class FunctionReturns(dbtClassMixin):
|
||||||
type: str
|
data_type: str
|
||||||
description: Optional[str] = None
|
description: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class FunctionMandatory(dbtClassMixin):
|
class FunctionMandatory(dbtClassMixin):
|
||||||
return_type: FunctionReturnType
|
returns: FunctionReturns
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ from dbt.artifacts.resources import Documentation as DocumentationResource
|
|||||||
from dbt.artifacts.resources import Exposure as ExposureResource
|
from dbt.artifacts.resources import Exposure as ExposureResource
|
||||||
from dbt.artifacts.resources import FileHash
|
from dbt.artifacts.resources import FileHash
|
||||||
from dbt.artifacts.resources import Function as FunctionResource
|
from dbt.artifacts.resources import Function as FunctionResource
|
||||||
from dbt.artifacts.resources import FunctionArgument, FunctionReturnType
|
from dbt.artifacts.resources import FunctionArgument, FunctionReturns
|
||||||
from dbt.artifacts.resources import GenericTest as GenericTestResource
|
from dbt.artifacts.resources import GenericTest as GenericTestResource
|
||||||
from dbt.artifacts.resources import GraphResource
|
from dbt.artifacts.resources import GraphResource
|
||||||
from dbt.artifacts.resources import Group as GroupResource
|
from dbt.artifacts.resources import Group as GroupResource
|
||||||
@@ -1725,7 +1725,7 @@ class ParsedNodePatch(ParsedPatch):
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ParsedFunctionPatchRequired:
|
class ParsedFunctionPatchRequired:
|
||||||
return_type: FunctionReturnType
|
returns: FunctionReturns
|
||||||
|
|
||||||
|
|
||||||
# TODO: Maybe this shouldn't be a subclass of ParsedNodePatch, but ParsedPatch instead
|
# TODO: Maybe this shouldn't be a subclass of ParsedNodePatch, but ParsedPatch instead
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from dbt.artifacts.resources import (
|
|||||||
ExternalTable,
|
ExternalTable,
|
||||||
FreshnessThreshold,
|
FreshnessThreshold,
|
||||||
FunctionArgument,
|
FunctionArgument,
|
||||||
FunctionReturnType,
|
FunctionReturns,
|
||||||
MacroArgument,
|
MacroArgument,
|
||||||
MaturityType,
|
MaturityType,
|
||||||
MeasureAggregationParameters,
|
MeasureAggregationParameters,
|
||||||
@@ -663,14 +663,12 @@ class UnparsedGroup(dbtClassMixin):
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class UnparsedFunctionReturnType(dbtClassMixin):
|
class UnparsedFunctionReturns(dbtClassMixin):
|
||||||
return_type: FunctionReturnType
|
returns: FunctionReturns
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class UnparsedFunctionUpdate(
|
class UnparsedFunctionUpdate(HasConfig, HasColumnProps, HasYamlMetadata, UnparsedFunctionReturns):
|
||||||
HasConfig, HasColumnProps, HasYamlMetadata, UnparsedFunctionReturnType
|
|
||||||
):
|
|
||||||
access: Optional[str] = None
|
access: Optional[str] = None
|
||||||
arguments: List[FunctionArgument] = field(default_factory=list)
|
arguments: List[FunctionArgument] = field(default_factory=list)
|
||||||
type: FunctionType = FunctionType.Scalar
|
type: FunctionType = FunctionType.Scalar
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ class ConfiguredParser(
|
|||||||
# but we don't get the return type until we patch the node with the yml definition
|
# but we don't get the return type until we patch the node with the yml definition
|
||||||
# so we need to set it to a default value here.
|
# so we need to set it to a default value here.
|
||||||
if self.resource_type == NodeType.Function:
|
if self.resource_type == NodeType.Function:
|
||||||
dct["return_type"] = {"type": "INVALID_TYPE"}
|
dct["returns"] = {"data_type": "INVALID_TYPE"}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.parse_from_dict(dct, validate=True)
|
return self.parse_from_dict(dct, validate=True)
|
||||||
|
|||||||
@@ -1291,7 +1291,7 @@ class FunctionPatchParser(NodePatchParser[UnparsedFunctionUpdate]):
|
|||||||
assert isinstance(node, FunctionNode)
|
assert isinstance(node, FunctionNode)
|
||||||
|
|
||||||
node.arguments = patch.arguments
|
node.arguments = patch.arguments
|
||||||
node.return_type = patch.return_type
|
node.returns = patch.returns
|
||||||
node.type = patch.type
|
node.type = patch.type
|
||||||
|
|
||||||
def _get_node_patch(self, block: TargetBlock[NodeTarget], refs: ParserRef) -> ParsedNodePatch:
|
def _get_node_patch(self, block: TargetBlock[NodeTarget], refs: ParserRef) -> ParsedNodePatch:
|
||||||
@@ -1315,7 +1315,7 @@ class FunctionPatchParser(NodePatchParser[UnparsedFunctionUpdate]):
|
|||||||
deprecation_date=None,
|
deprecation_date=None,
|
||||||
time_spine=None,
|
time_spine=None,
|
||||||
arguments=target.arguments,
|
arguments=target.arguments,
|
||||||
return_type=target.return_type,
|
returns=target.returns,
|
||||||
type=target.type,
|
type=target.type,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -8133,11 +8133,11 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "Function",
|
"title": "Function",
|
||||||
"properties": {
|
"properties": {
|
||||||
"return_type": {
|
"returns": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "FunctionReturnType",
|
"title": "FunctionReturns",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"data_type": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
@@ -8154,7 +8154,7 @@
|
|||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"type"
|
"data_type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"database": {
|
"database": {
|
||||||
@@ -8986,7 +8986,7 @@
|
|||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"type": {
|
"data_type": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
@@ -9004,7 +9004,7 @@
|
|||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"name",
|
"name",
|
||||||
"type"
|
"data_type"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -9019,7 +9019,7 @@
|
|||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"return_type",
|
"returns",
|
||||||
"database",
|
"database",
|
||||||
"schema",
|
"schema",
|
||||||
"name",
|
"name",
|
||||||
@@ -19731,11 +19731,11 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "Function",
|
"title": "Function",
|
||||||
"properties": {
|
"properties": {
|
||||||
"return_type": {
|
"returns": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "FunctionReturnType",
|
"title": "FunctionReturns",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"data_type": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
@@ -19752,7 +19752,7 @@
|
|||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"type"
|
"data_type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"database": {
|
"database": {
|
||||||
@@ -20584,7 +20584,7 @@
|
|||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"type": {
|
"data_type": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
@@ -20602,7 +20602,7 @@
|
|||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"name",
|
"name",
|
||||||
"type"
|
"data_type"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -20617,7 +20617,7 @@
|
|||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"return_type",
|
"returns",
|
||||||
"database",
|
"database",
|
||||||
"schema",
|
"schema",
|
||||||
"name",
|
"name",
|
||||||
@@ -26249,11 +26249,11 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "Function",
|
"title": "Function",
|
||||||
"properties": {
|
"properties": {
|
||||||
"return_type": {
|
"returns": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "FunctionReturnType",
|
"title": "FunctionReturns",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"data_type": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
@@ -26270,7 +26270,7 @@
|
|||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"type"
|
"data_type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"database": {
|
"database": {
|
||||||
@@ -27102,7 +27102,7 @@
|
|||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"type": {
|
"data_type": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
@@ -27120,7 +27120,7 @@
|
|||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"name",
|
"name",
|
||||||
"type"
|
"data_type"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -27135,7 +27135,7 @@
|
|||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"return_type",
|
"returns",
|
||||||
"database",
|
"database",
|
||||||
"schema",
|
"schema",
|
||||||
"name",
|
"name",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -412,7 +412,7 @@ class TestPreviousVersionState:
|
|||||||
current_manifest_schema_version == self.CURRENT_EXPECTED_MANIFEST_VERSION
|
current_manifest_schema_version == self.CURRENT_EXPECTED_MANIFEST_VERSION
|
||||||
), "Sounds like you've bumped the manifest version and need to update this test!"
|
), "Sounds like you've bumped the manifest version and need to update this test!"
|
||||||
# If we need a newly generated manifest, uncomment the following line and commit the result
|
# If we need a newly generated manifest, uncomment the following line and commit the result
|
||||||
# self.generate_latest_manifest(project, current_manifest_schema_version)
|
self.generate_latest_manifest(project, current_manifest_schema_version)
|
||||||
self.compare_previous_state(project, current_manifest_schema_version, True, 0)
|
self.compare_previous_state(project, current_manifest_schema_version, True, 0)
|
||||||
|
|
||||||
def test_backwards_compatible_versions(self, project):
|
def test_backwards_compatible_versions(self, project):
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ functions:
|
|||||||
description: Calculates the area of a circle for a given radius
|
description: Calculates the area of a circle for a given radius
|
||||||
arguments:
|
arguments:
|
||||||
- name: radius
|
- name: radius
|
||||||
type: float
|
data_type: float
|
||||||
description: A floating point number representing the radius of the circle
|
description: A floating point number representing the radius of the circle
|
||||||
return_type:
|
returns:
|
||||||
type: float
|
data_type: float
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from typing import Dict
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbt.artifacts.resources import FunctionReturnType
|
from dbt.artifacts.resources import FunctionReturns
|
||||||
from dbt.artifacts.resources.types import FunctionType
|
from dbt.artifacts.resources.types import FunctionType
|
||||||
from dbt.contracts.graph.nodes import FunctionNode
|
from dbt.contracts.graph.nodes import FunctionNode
|
||||||
from dbt.tests.util import run_dbt
|
from dbt.tests.util import run_dbt
|
||||||
@@ -18,10 +18,10 @@ functions:
|
|||||||
description: Sums the sequence of numbers and then doubles the result
|
description: Sums the sequence of numbers and then doubles the result
|
||||||
arguments:
|
arguments:
|
||||||
- name: values
|
- name: values
|
||||||
type: float
|
data_type: float
|
||||||
description: A sequence of numbers
|
description: A sequence of numbers
|
||||||
return_type:
|
returns:
|
||||||
type: float
|
data_type: float
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -48,6 +48,6 @@ class TestBasicSQLUDAF(BasicUDAFSetup):
|
|||||||
assert len(function_node.arguments) == 1
|
assert len(function_node.arguments) == 1
|
||||||
argument = function_node.arguments[0]
|
argument = function_node.arguments[0]
|
||||||
assert argument.name == "values"
|
assert argument.name == "values"
|
||||||
assert argument.type == "float"
|
assert argument.data_type == "float"
|
||||||
assert argument.description == "A sequence of numbers"
|
assert argument.description == "A sequence of numbers"
|
||||||
assert function_node.return_type == FunctionReturnType(type="float")
|
assert function_node.returns == FunctionReturns(data_type="float")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from typing import Dict
|
|||||||
import agate
|
import agate
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from dbt.artifacts.resources import FunctionReturnType
|
from dbt.artifacts.resources import FunctionReturns
|
||||||
from dbt.artifacts.resources.types import FunctionType
|
from dbt.artifacts.resources.types import FunctionType
|
||||||
from dbt.contracts.graph.nodes import FunctionNode
|
from dbt.contracts.graph.nodes import FunctionNode
|
||||||
from dbt.tests.util import run_dbt
|
from dbt.tests.util import run_dbt
|
||||||
@@ -18,10 +18,10 @@ functions:
|
|||||||
description: Doubles whatever number is passed in
|
description: Doubles whatever number is passed in
|
||||||
arguments:
|
arguments:
|
||||||
- name: value
|
- name: value
|
||||||
type: float
|
data_type: float
|
||||||
description: A number to be doubled
|
description: A number to be doubled
|
||||||
return_type:
|
returns:
|
||||||
type: float
|
data_type: float
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -46,9 +46,9 @@ class TestBasicSQLUDF(BasicUDFSetup):
|
|||||||
assert len(function_node.arguments) == 1
|
assert len(function_node.arguments) == 1
|
||||||
argument = function_node.arguments[0]
|
argument = function_node.arguments[0]
|
||||||
assert argument.name == "value"
|
assert argument.name == "value"
|
||||||
assert argument.type == "float"
|
assert argument.data_type == "float"
|
||||||
assert argument.description == "A number to be doubled"
|
assert argument.description == "A number to be doubled"
|
||||||
assert function_node.return_type == FunctionReturnType(type="float")
|
assert function_node.returns == FunctionReturns(data_type="float")
|
||||||
|
|
||||||
|
|
||||||
class TestCreationOfUDFs(BasicUDFSetup):
|
class TestCreationOfUDFs(BasicUDFSetup):
|
||||||
@@ -64,7 +64,7 @@ class TestCreationOfUDFs(BasicUDFSetup):
|
|||||||
argument = function_node.arguments[0]
|
argument = function_node.arguments[0]
|
||||||
assert argument.name == "value"
|
assert argument.name == "value"
|
||||||
assert argument.type == "float"
|
assert argument.type == "float"
|
||||||
assert results[0].node.return_type == FunctionReturnType(type="float")
|
assert results[0].node.returns == FunctionReturns(type="float")
|
||||||
|
|
||||||
|
|
||||||
class TestCanInlineShowUDF(BasicUDFSetup):
|
class TestCanInlineShowUDF(BasicUDFSetup):
|
||||||
|
|||||||
Reference in New Issue
Block a user