kelp.models.function¶
Reference for the function configuration model.
kelp.models.function.FunctionParameter
pydantic-model
¶
Bases: BaseModel
Function parameter definition.
Show JSON schema:
{
"description": "Function parameter definition.",
"properties": {
"name": {
"description": "Parameter name",
"title": "Name",
"type": "string"
},
"data_type": {
"description": "Parameter SQL data type",
"title": "Data Type",
"type": "string"
},
"default_expression": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional SQL default expression",
"title": "Default Expression"
},
"comment": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional parameter comment",
"title": "Comment"
}
},
"required": [
"name",
"data_type"
],
"title": "FunctionParameter",
"type": "object"
}
Fields:
-
name(str) -
data_type(str) -
default_expression(str | None) -
comment(str | None)
kelp.models.function.FunctionReturnColumn
pydantic-model
¶
Bases: BaseModel
Column definition for table-valued function return schema.
Show JSON schema:
{
"description": "Column definition for table-valued function return schema.",
"properties": {
"name": {
"description": "Return column name",
"title": "Name",
"type": "string"
},
"data_type": {
"description": "Return column SQL data type",
"title": "Data Type",
"type": "string"
},
"comment": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional return column comment",
"title": "Comment"
}
},
"required": [
"name",
"data_type"
],
"title": "FunctionReturnColumn",
"type": "object"
}
Fields:
kelp.models.function.FunctionEnvironment
pydantic-model
¶
Bases: BaseModel
Environment clause for Python functions.
Show JSON schema:
{
"description": "Environment clause for Python functions.",
"properties": {
"dependencies": {
"description": "Python package dependencies and wheel references",
"items": {
"type": "string"
},
"title": "Dependencies",
"type": "array"
},
"environment_version": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Python environment version (Databricks currently supports 'None')",
"title": "Environment Version"
}
},
"title": "FunctionEnvironment",
"type": "object"
}
Fields:
-
dependencies(list[str]) -
environment_version(str | None)
kelp.models.function.KelpFunction
pydantic-model
¶
Bases: BaseModel
Function definition in Unity Catalog.
This model validates function metadata and body source location, while leaving SQL/Python body parsing to Databricks at execution time.
Show JSON schema:
{
"$defs": {
"FunctionEnvironment": {
"description": "Environment clause for Python functions.",
"properties": {
"dependencies": {
"description": "Python package dependencies and wheel references",
"items": {
"type": "string"
},
"title": "Dependencies",
"type": "array"
},
"environment_version": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Python environment version (Databricks currently supports 'None')",
"title": "Environment Version"
}
},
"title": "FunctionEnvironment",
"type": "object"
},
"FunctionParameter": {
"description": "Function parameter definition.",
"properties": {
"name": {
"description": "Parameter name",
"title": "Name",
"type": "string"
},
"data_type": {
"description": "Parameter SQL data type",
"title": "Data Type",
"type": "string"
},
"default_expression": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional SQL default expression",
"title": "Default Expression"
},
"comment": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional parameter comment",
"title": "Comment"
}
},
"required": [
"name",
"data_type"
],
"title": "FunctionParameter",
"type": "object"
},
"FunctionReturnColumn": {
"description": "Column definition for table-valued function return schema.",
"properties": {
"name": {
"description": "Return column name",
"title": "Name",
"type": "string"
},
"data_type": {
"description": "Return column SQL data type",
"title": "Data Type",
"type": "string"
},
"comment": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional return column comment",
"title": "Comment"
}
},
"required": [
"name",
"data_type"
],
"title": "FunctionReturnColumn",
"type": "object"
}
},
"description": "Function definition in Unity Catalog.\n\nThis model validates function metadata and body source location, while leaving\nSQL/Python body parsing to Databricks at execution time.",
"properties": {
"name": {
"description": "Function name",
"title": "Name",
"type": "string"
},
"catalog": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Unity Catalog name",
"title": "Catalog"
},
"schema": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Schema name",
"title": "Schema"
},
"language": {
"default": "SQL",
"description": "Function implementation language",
"enum": [
"SQL",
"PYTHON"
],
"title": "Language",
"type": "string"
},
"temporary": {
"default": false,
"description": "Whether the function is temporary (session scoped)",
"title": "Temporary",
"type": "boolean"
},
"if_not_exists": {
"default": false,
"description": "Create only if function does not already exist",
"title": "If Not Exists",
"type": "boolean"
},
"or_replace": {
"default": true,
"description": "Use CREATE OR REPLACE semantics",
"title": "Or Replace",
"type": "boolean"
},
"deterministic": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Deterministic characteristic",
"title": "Deterministic"
},
"data_access": {
"anyOf": [
{
"enum": [
"CONTAINS SQL",
"READS SQL DATA"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional SQL data access characteristic",
"title": "Data Access"
},
"default_collation": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Default collation for SQL functions",
"title": "Default Collation"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Function comment",
"title": "Description"
},
"parameters": {
"description": "Function parameter definitions",
"items": {
"$ref": "#/$defs/FunctionParameter"
},
"title": "Parameters",
"type": "array"
},
"returns_data_type": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Scalar return data type",
"title": "Returns Data Type"
},
"returns_table": {
"description": "Table-valued return columns (for RETURNS TABLE)",
"items": {
"$ref": "#/$defs/FunctionReturnColumn"
},
"title": "Returns Table",
"type": "array"
},
"body": {
"default": "",
"description": "Function body text, normalized from inline content or file source",
"title": "Body",
"type": "string"
},
"body_path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional path to external .sql/.py body file, relative to project root",
"title": "Body Path"
},
"environment": {
"anyOf": [
{
"$ref": "#/$defs/FunctionEnvironment"
},
{
"type": "null"
}
],
"default": null,
"description": "Python environment declaration"
},
"tags": {
"additionalProperties": {
"type": "string"
},
"description": "Metadata tags",
"title": "Tags",
"type": "object"
},
"meta": {
"additionalProperties": true,
"description": "Generic user-defined metadata for filtering and grouping",
"title": "Meta",
"type": "object"
}
},
"required": [
"name"
],
"title": "KelpFunction",
"type": "object"
}
Config:
validate_by_name:Truevalidate_by_alias:Trueserialize_by_alias:True
Fields:
-
origin_file_path(SkipJsonSchema[str] | None) -
name(str) -
catalog(str | None) -
schema_(str | None) -
language(Literal['SQL', 'PYTHON']) -
temporary(bool) -
if_not_exists(bool) -
or_replace(bool) -
deterministic(bool | None) -
data_access(Literal['CONTAINS SQL', 'READS SQL DATA'] | None) -
default_collation(str | None) -
description(str | None) -
parameters(list[FunctionParameter]) -
returns_data_type(str | None) -
returns_table(list[FunctionReturnColumn]) -
body(str) -
body_path(str | None) -
environment(FunctionEnvironment | None) -
tags(dict[str, str]) -
meta(dict[str, Any]) -
raw_config(SkipJsonSchema[dict])
body_path
pydantic-field
¶
Optional path to external .sql/.py body file, relative to project root
model_config
class-attribute
instance-attribute
¶
model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=True,
serialize_by_alias=True,
)
get_qualified_name
¶
Get fully qualified function name.