{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "4b8cb87a", "metadata": {}, "source": [ "# Documentation of tables\n", "You can add documentation to schemas as follows:" ] }, { "cell_type": "code", "execution_count": 1, "id": "d2e1e850", "metadata": {}, "outputs": [], "source": [ "from typing import Annotated\n", "from pyspark.sql.types import DateType, StringType\n", "from typedspark import Column, ColumnMeta, Schema\n", "\n", "\n", "class Person(Schema):\n", " \"\"\"Dimension table that contains information about a person.\"\"\"\n", "\n", " person_id: Annotated[\n", " Column[StringType],\n", " ColumnMeta(comment=\"Unique person id\"),\n", " ]\n", " gender: Annotated[Column[StringType], ColumnMeta(comment=\"Gender of the person\")]\n", " birthdate: Annotated[Column[DateType], ColumnMeta(comment=\"Date of birth of the person\")]\n", " job_id: Annotated[Column[StringType], ColumnMeta(comment=\"Id of the job\")]" ] }, { "attachments": {}, "cell_type": "markdown", "id": "302ad462", "metadata": {}, "source": [ "If you use Databricks and Delta Live Tables, you can make the documentation appear in the Databricks UI by using the following Delta Live Table definition:\n", "\n", "```python\n", "@dlt.table(**Person.get_dlt_kwargs())\n", "def table_definition() -> DataSet[Person]:\n", " # your table definition here\n", "```\n" ] }, { "cell_type": "markdown", "id": "17c2b1a6", "metadata": {}, "source": [] } ], "metadata": { "kernelspec": { "display_name": "typedspark", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 5 }