Skip to content

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 pydantic-field

name

Parameter name

data_type pydantic-field

data_type

Parameter SQL data type

default_expression pydantic-field

default_expression = None

Optional SQL default expression

comment pydantic-field

comment = None

Optional parameter comment

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:

name pydantic-field

name

Return column name

data_type pydantic-field

data_type

Return column SQL data type

comment pydantic-field

comment = None

Optional return column comment

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 pydantic-field

dependencies

Python package dependencies and wheel references

environment_version pydantic-field

environment_version = None

Python environment version (Databricks currently supports '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: True
  • validate_by_alias: True
  • serialize_by_alias: True

Fields:

origin_file_path pydantic-field

origin_file_path = None

name pydantic-field

name

Function name

catalog pydantic-field

catalog = None

Unity Catalog name

schema_ pydantic-field

schema_ = None

Schema name

language pydantic-field

language = 'SQL'

Function implementation language

temporary pydantic-field

temporary = False

Whether the function is temporary (session scoped)

if_not_exists pydantic-field

if_not_exists = False

Create only if function does not already exist

or_replace pydantic-field

or_replace = True

Use CREATE OR REPLACE semantics

deterministic pydantic-field

deterministic = None

Deterministic characteristic

data_access pydantic-field

data_access = None

Optional SQL data access characteristic

default_collation pydantic-field

default_collation = None

Default collation for SQL functions

description pydantic-field

description = None

Function comment

parameters pydantic-field

parameters

Function parameter definitions

returns_data_type pydantic-field

returns_data_type = None

Scalar return data type

returns_table pydantic-field

returns_table

Table-valued return columns (for RETURNS TABLE)

body pydantic-field

body = ''

Function body text, normalized from inline content or file source

body_path pydantic-field

body_path = None

Optional path to external .sql/.py body file, relative to project root

environment pydantic-field

environment = None

Python environment declaration

tags pydantic-field

tags

Metadata tags

meta pydantic-field

meta

Generic user-defined metadata for filtering and grouping

raw_config pydantic-field

raw_config

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_qualified_name()

Get fully qualified function name.

Source code in src/kelp/models/function.py
def get_qualified_name(self) -> str:
    """Get fully qualified function name."""
    parts = []
    if self.catalog:
        parts.append(self.catalog)
    if self.schema_:
        parts.append(self.schema_)
    parts.append(self.name)
    return ".".join(parts)