{"title":"dbt","description":"Run dbt models on Altertable and sync project knowledge, lineage, and semantic metadata from a connected repository.","order":330,"askSuggestions":["How do I schedule dbt runs in Altertable?","Which dbt artifacts should I commit for lineage?","Which incremental strategies does the adapter support?"],"navigation":true,"body":{"code":"var Component=(()=>{var u=Object.create;var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var y=(r,n)=>()=>(n||r((n={exports:{}}).exports,n),n.exports),w=(r,n)=>{for(var i in n)d(r,i,{get:n[i],enumerable:!0})},s=(r,n,i,o)=>{if(n&&typeof n==\"object\"||typeof n==\"function\")for(let t of b(n))!f.call(r,t)&&t!==i&&d(r,t,{get:()=>n[t],enumerable:!(o=p(n,t))||o.enumerable});return r};var k=(r,n,i)=>(i=r!=null?u(g(r)):{},s(n||!r||!r.__esModule?d(i,\"default\",{value:r,enumerable:!0}):i,r)),x=r=>s(d({},\"__esModule\",{value:!0}),r);var l=y((A,a)=>{a.exports=_jsx_runtime});var _={};w(_,{default:()=>m,frontmatter:()=>j});var e=k(l()),j={title:\"dbt\",description:\"Run dbt models on Altertable and sync project knowledge, lineage, and semantic metadata from a connected repository.\",order:330,askSuggestions:[\"How do I schedule dbt runs in Altertable?\",\"Which dbt artifacts should I commit for lineage?\",\"Which incremental strategies does the adapter support?\"]};function h(r){let n={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",h3:\"h3\",li:\"li\",ol:\"ol\",p:\"p\",pre:\"pre\",strong:\"strong\",table:\"table\",tbody:\"tbody\",td:\"td\",th:\"th\",thead:\"thead\",tr:\"tr\",ul:\"ul\",...r.components},{CodeSnippet:i,DocsPreviewDocument:o,DocsPreviewSection:t}=n;return i||c(\"CodeSnippet\",!0),o||c(\"DocsPreviewDocument\",!0),t||c(\"DocsPreviewSection\",!0),(0,e.jsxs)(o,{anchors:\"dbt installation configuration profile-example configuration-parameters usage sync-project-knowledge which-files-need-to-be-committed generate-and-refresh-the-artifacts enrich-existing-semantic-models publish-executable-metrics run-dbt-in-a-task sql-dialect metricflow seeds incremental-models persisting-descriptions python-models source-code\",children:[(0,e.jsxs)(t,{sectionId:\"dbt\",sectionTitle:\"dbt\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,e.jsx)(n.h1,{id:\"dbt\",children:\"dbt\"}),`\n`,(0,e.jsxs)(n.p,{children:[(0,e.jsx)(n.a,{href:\"https://www.getdbt.com/\",children:\"dbt\"}),\" helps data teams model and transform analytical data. Use the Altertable adapter to run dbt models directly in your Altertable lakehouse. You can also \",(0,e.jsx)(n.a,{href:\"#sync-project-knowledge\",children:\"connect a dbt repository\"}),\" to make project definitions, lineage, and semantic metadata available to Altertable and its agents.\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"installation\",sectionTitle:\"Installation\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,e.jsx)(n.h2,{id:\"installation\",children:\"Installation\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"For a worked example of organizing raw data, transformations, and marts, follow the \",(0,e.jsx)(n.a,{href:\"/docs/lakehouse/modeling/medallion-architecture\",children:\"medallion architecture guide\"}),\".\"]}),`\n`,(0,e.jsxs)(n.p,{children:[\"The Altertable adapter for dbt is available on PyPI and currently requires Python \",(0,e.jsx)(n.code,{children:\"3.10+\"}),\" with \",(0,e.jsx)(n.code,{children:\"dbt-core >=1.8,<2.0\"}),\".\"]}),`\n`,(0,e.jsx)(n.pre,{children:(0,e.jsx)(n.code,{className:\"language-bash\",children:`pip install dbt-altertable\n`})}),`\n`,(0,e.jsxs)(n.p,{children:[\"If you manage Python dependencies with \",(0,e.jsx)(n.code,{children:\"uv\"}),\", you can install it with:\"]}),`\n`,(0,e.jsx)(n.pre,{children:(0,e.jsx)(n.code,{className:\"language-bash\",children:`uv add dbt-altertable\n`})}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"configuration\",sectionTitle:\"Configuration\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,e.jsx)(n.h2,{id:\"configuration\",children:\"Configuration\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"Add an Altertable profile to your \",(0,e.jsx)(n.code,{children:\"profiles.yml\"}),\" file. By default, dbt looks for profiles in \",(0,e.jsx)(n.code,{children:\"~/.dbt/profiles.yml\"}),\", but you can also place it in your project directory or specify a custom location using the \",(0,e.jsx)(n.code,{children:\"--profiles-dir\"}),\" flag. Learn more about \",(0,e.jsx)(n.a,{href:\"https://docs.getdbt.com/docs/local/profiles.yml\",children:\"dbt profiles\"}),\" in the dbt documentation.\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"profile-example\",sectionTitle:\"Profile Example\",anchors:\"\",ancestors:\"configuration\",index:\"3\",children:[(0,e.jsx)(n.h3,{id:\"profile-example\",children:\"Profile Example\"}),`\n`,(0,e.jsx)(i,{language:\"yaml\",children:`your_project_name:\n  target: dev\n  outputs:\n    dev:\n      type: altertable\n      username: {{LAKEHOUSE_USERNAME}}\n      password: {{LAKEHOUSE_PASSWORD}}\n      database: your_catalog_name\n      schema: your_schema_name\n      compute_size: XL`}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"configuration-parameters\",sectionTitle:\"Configuration Parameters\",anchors:\"\",ancestors:\"configuration\",index:\"4\",children:[(0,e.jsx)(n.h3,{id:\"configuration-parameters\",children:\"Configuration Parameters\"}),`\n`,(0,e.jsxs)(n.ul,{children:[`\n`,(0,e.jsxs)(n.li,{children:[(0,e.jsx)(n.strong,{children:\"type\"}),\": Must be set to \",(0,e.jsx)(n.code,{children:\"altertable\"}),\" (required)\"]}),`\n`,(0,e.jsxs)(n.li,{children:[(0,e.jsx)(n.strong,{children:\"username\"}),\": Your lakehouse username (required) \\u2014 find this in the \",(0,e.jsx)(n.a,{href:\"/docs/administration/lakehouse-credentials\",children:\"Credentials\"}),\" section of the dashboard\"]}),`\n`,(0,e.jsxs)(n.li,{children:[(0,e.jsx)(n.strong,{children:\"password\"}),\": Your lakehouse password (required) \\u2014 find this in the \",(0,e.jsx)(n.a,{href:\"/docs/administration/lakehouse-credentials\",children:\"Credentials\"}),\" section of the dashboard\"]}),`\n`,(0,e.jsxs)(n.li,{children:[(0,e.jsx)(n.strong,{children:\"database\"}),\": The name of your \",(0,e.jsx)(n.a,{href:\"/docs/lakehouse/catalogs\",children:\"Altertable catalog\"}),\" where models will be materialized (required)\"]}),`\n`,(0,e.jsxs)(n.li,{children:[(0,e.jsx)(n.strong,{children:\"schema\"}),\": The schema within your catalog where models will be created (required)\"]}),`\n`,(0,e.jsxs)(n.li,{children:[(0,e.jsx)(n.strong,{children:\"compute_size\"}),\": Optional compute size for your workload. Omit it to use the server default.\"]}),`\n`]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"usage\",sectionTitle:\"Usage\",anchors:\"\",ancestors:\"\",index:\"5\",children:[(0,e.jsx)(n.h2,{id:\"usage\",children:\"Usage\"}),`\n`,(0,e.jsx)(n.p,{children:\"Once configured, you can run dbt commands against Altertable:\"}),`\n`,(0,e.jsx)(n.pre,{children:(0,e.jsx)(n.code,{className:\"language-bash\",children:`# Test your connection\ndbt debug\n\n# Run your models\ndbt run\n\n# Test your models\ndbt test\n\n# Generate and serve documentation\ndbt docs generate\ndbt docs serve\n`})}),`\n`,(0,e.jsxs)(n.p,{children:[\"Learn more about \",(0,e.jsx)(n.a,{href:\"https://docs.getdbt.com/reference/dbt-commands\",children:\"dbt commands\"}),\" in the dbt documentation.\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"sync-project-knowledge\",sectionTitle:\"Sync project knowledge\",anchors:\"\",ancestors:\"\",index:\"6\",children:[(0,e.jsx)(n.h2,{id:\"sync-project-knowledge\",children:\"Sync project knowledge\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"Connect your dbt project as a \",(0,e.jsx)(n.a,{href:\"/docs/agents/knowledge/entries\",children:\"knowledge repository\"}),\". Altertable detects \",(0,e.jsx)(n.code,{children:\"dbt_project.yml\"}),\" at the repository root or in a subdirectory and turns project source files into searchable knowledge entries. A repository can contain multiple dbt projects.\"]}),`\n`,(0,e.jsxs)(n.p,{children:[\"In \",(0,e.jsx)(n.strong,{children:\"Knowledge\"}),\", select \",(0,e.jsx)(n.strong,{children:\"New knowledge\"}),\", choose \",(0,e.jsx)(n.strong,{children:\"Repository\"}),\", and connect your GitHub or GitLab account. Choose the repository and branch, then select \",(0,e.jsx)(n.strong,{children:\"Add repository\"}),\". Leave the branch empty to use the repository's default branch.\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"which-files-need-to-be-committed\",sectionTitle:\"Which files need to be committed?\",anchors:\"\",ancestors:\"sync-project-knowledge\",index:\"7\",children:[(0,e.jsx)(n.h3,{id:\"which-files-need-to-be-committed\",children:\"Which files need to be committed?\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"For Git-based sync, commit your dbt project source files to the connected branch. Include the artifacts below for lineage, model enrichment, and generated metric definitions. \",(0,e.jsx)(n.a,{href:\"mailto:contact@altertable.ai\",children:\"Contact us\"}),\" if you need to sync artifacts from a bucket.\"]}),`\n`,(0,e.jsxs)(n.table,{children:[(0,e.jsx)(n.thead,{children:(0,e.jsxs)(n.tr,{children:[(0,e.jsx)(n.th,{children:\"File\"}),(0,e.jsx)(n.th,{children:\"Purpose\"})]})}),(0,e.jsxs)(n.tbody,{children:[(0,e.jsxs)(n.tr,{children:[(0,e.jsxs)(n.td,{children:[(0,e.jsx)(n.code,{children:\"dbt_project.yml\"}),\" and project source files\"]}),(0,e.jsx)(n.td,{children:\"Detect the project and extract knowledge from SQL, YAML, and documentation.\"})]}),(0,e.jsxs)(n.tr,{children:[(0,e.jsx)(n.td,{children:(0,e.jsx)(n.code,{children:\"target/manifest.json\"})}),(0,e.jsx)(n.td,{children:\"Add model lineage and enrich existing semantic models with dbt metadata.\"})]}),(0,e.jsxs)(n.tr,{children:[(0,e.jsx)(n.td,{children:(0,e.jsx)(n.a,{href:\"https://docs.getdbt.com/reference/artifacts/sl-manifest\",children:(0,e.jsx)(n.code,{children:\"target/semantic_manifest.json\"})})}),(0,e.jsx)(n.td,{children:\"Make generated metric and semantic definitions available as knowledge.\"})]})]})]}),`\n`,(0,e.jsxs)(n.p,{children:[\"Repository sync does not run dbt to generate artifacts. Without a valid \",(0,e.jsx)(n.code,{children:\"manifest.json\"}),\", Altertable still extracts knowledge from the source files, but skips manifest-based lineage and semantic model enrichment.\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"generate-and-refresh-the-artifacts\",sectionTitle:\"Generate and refresh the artifacts\",anchors:\"\",ancestors:\"sync-project-knowledge\",index:\"8\",children:[(0,e.jsx)(n.h3,{id:\"generate-and-refresh-the-artifacts\",children:\"Generate and refresh the artifacts\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"From the directory containing \",(0,e.jsx)(n.code,{children:\"dbt_project.yml\"}),\", install project dependencies and \",(0,e.jsx)(n.a,{href:\"https://docs.getdbt.com/reference/commands/parse\",children:\"parse the project\"}),\". Use the target whose catalog and schema names match the data you want to describe in Altertable. Replace \",(0,e.jsx)(n.code,{children:\"prod\"}),\" with that target's name in your dbt profile:\"]}),`\n`,(0,e.jsx)(n.pre,{children:(0,e.jsx)(n.code,{className:\"language-bash\",children:`dbt deps\ndbt parse --target prod\ngit add -f target/manifest.json target/semantic_manifest.json\ngit commit -m \"docs(dbt): refresh project artifacts\"\ngit push\n`})}),`\n`,(0,e.jsxs)(n.p,{children:[\"Commit both artifacts under \",(0,e.jsx)(n.code,{children:\"target/\"}),\" relative to \",(0,e.jsx)(n.code,{children:\"dbt_project.yml\"}),\".\"]}),`\n`,(0,e.jsxs)(n.p,{children:[\"After pushing, select \",(0,e.jsx)(n.strong,{children:\"Sync now\"}),\" from the repository menu. Regenerate and commit the artifacts when your dbt project changes.\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"enrich-existing-semantic-models\",sectionTitle:\"Enrich existing semantic models\",anchors:\"\",ancestors:\"sync-project-knowledge\",index:\"9\",children:[(0,e.jsx)(n.h3,{id:\"enrich-existing-semantic-models\",children:\"Enrich existing semantic models\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"With a valid \",(0,e.jsx)(n.code,{children:\"manifest.json\"}),\", Altertable can update existing \",(0,e.jsx)(n.a,{href:\"/docs/agents/knowledge/semantic-layer\",children:\"semantic models\"}),\" with dbt descriptions, column metadata, supported measures and dimensions, and relationships derived from entities. It matches each dbt model to an existing Altertable model by catalog, schema, and table name, using the dbt alias when configured. This enrichment does not materialize tables or create missing semantic models.\"]}),`\n`,(0,e.jsx)(n.p,{children:\"Metric definitions remain available as knowledge even when this enrichment cannot import them as native measures. For example, filtered simple metrics are not imported as unfiltered Altertable measures.\"}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"publish-executable-metrics\",sectionTitle:\"Publish executable metrics\",anchors:\"\",ancestors:\"sync-project-knowledge\",index:\"10\",children:[(0,e.jsx)(n.h3,{id:\"publish-executable-metrics\",children:\"Publish executable metrics\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"Repository sync also imports supported dbt metric definitions, validates them against the lakehouse, and publishes semantic views. Inspect the resulting metrics under the repository's project in \",(0,e.jsx)(n.strong,{children:\"Knowledge\"}),\". Agents can discover runnable queries and available dimensions through \",(0,e.jsx)(n.code,{children:\"list_semantic_metrics\"}),\".\"]}),`\n`,(0,e.jsxs)(n.p,{children:[\"Unsupported or unresolved definitions can still be preserved as knowledge. Check the metric's status rather than assuming every imported definition is queryable. See \",(0,e.jsx)(n.a,{href:\"/docs/agents/knowledge/metrics\",children:\"Metrics\"}),\".\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"run-dbt-in-a-task\",sectionTitle:\"Run dbt in a task\",anchors:\"\",ancestors:\"\",index:\"11\",children:[(0,e.jsx)(n.h2,{id:\"run-dbt-in-a-task\",children:\"Run dbt in a task\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"A \",(0,e.jsx)(n.strong,{children:\"dbt task\"}),\" runs a project from a \",(0,e.jsx)(n.a,{href:\"#sync-project-knowledge\",children:\"connected repository\"}),\" in an isolated environment and writes its models to an Altertable catalog. Altertable supplies the dbt profile, so the task needs no \",(0,e.jsx)(n.code,{children:\"profiles.yml\"}),\" or credentials. Creating one requires \",(0,e.jsx)(n.a,{href:\"/docs/administration/access-control\",children:\"permission\"}),\" to manage catalogs.\"]}),`\n`,(0,e.jsxs)(n.p,{children:[\"Open \",(0,e.jsx)(n.strong,{children:\"Tasks \\u2192 New task\"}),\" and choose \",(0,e.jsx)(n.strong,{children:\"dbt task\"}),\" under \",(0,e.jsx)(n.strong,{children:\"Set up manually\"}),\":\"]}),`\n`,(0,e.jsxs)(n.ol,{children:[`\n`,(0,e.jsxs)(n.li,{children:[\"Under \",(0,e.jsx)(n.strong,{children:\"Project\"}),\", select the \",(0,e.jsx)(n.strong,{children:\"Repository\"}),\". Set \",(0,e.jsx)(n.strong,{children:\"Project directory\"}),\" when \",(0,e.jsx)(n.code,{children:\"dbt_project.yml\"}),\" is not at the repository root, and optionally a \",(0,e.jsx)(n.strong,{children:\"Git ref\"}),\".\"]}),`\n`,(0,e.jsxs)(n.li,{children:[\"Under \",(0,e.jsx)(n.strong,{children:\"Command\"}),\", choose \",(0,e.jsx)(n.code,{children:\"build\"}),\", \",(0,e.jsx)(n.code,{children:\"run\"}),\", or \",(0,e.jsx)(n.code,{children:\"source freshness\"}),\", and enter a \",(0,e.jsx)(n.strong,{children:\"Selector\"}),\" such as \",(0,e.jsx)(n.code,{children:\"tag:daily\"}),\".\"]}),`\n`,(0,e.jsxs)(n.li,{children:[\"Under \",(0,e.jsx)(n.strong,{children:\"Destination\"}),\", choose the \",(0,e.jsx)(n.strong,{children:\"Catalog\"}),\" and \",(0,e.jsx)(n.strong,{children:\"Schema\"}),\" to write models to.\"]}),`\n`,(0,e.jsxs)(n.li,{children:[\"Set a \",(0,e.jsx)(n.strong,{children:\"Schedule\"}),\", then select \",(0,e.jsx)(n.strong,{children:\"Create dbt run\"}),\".\"]}),`\n`]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"sql-dialect\",sectionTitle:\"SQL Dialect\",anchors:\"\",ancestors:\"\",index:\"12\",children:[(0,e.jsx)(n.h2,{id:\"sql-dialect\",children:\"SQL Dialect\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"Altertable uses DuckDB as its query engine, so write models with DuckDB-compatible functions, syntax, and data types. The adapter builds on \",(0,e.jsx)(n.code,{children:\"dbt-duckdb\"}),\" and automatically dispatches \",(0,e.jsx)(n.code,{children:\"duckdb__\"}),\" macros from your project and installed packages.\"]}),`\n`,(0,e.jsxs)(n.p,{children:[\"Learn more about \",(0,e.jsx)(n.a,{href:\"https://duckdb.org/docs/sql/introduction\",children:\"DuckDB SQL\"}),\" in the DuckDB documentation.\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"metricflow\",sectionTitle:\"MetricFlow\",anchors:\"\",ancestors:\"\",index:\"13\",children:[(0,e.jsx)(n.h2,{id:\"metricflow\",children:\"MetricFlow\"}),`\n`,(0,e.jsx)(n.p,{children:\"The adapter can run dbt Semantic Layer and MetricFlow workloads by rendering MetricFlow SQL with DuckDB-compatible syntax. Keep your semantic models in dbt as usual, then run MetricFlow against the same Altertable profile.\"}),`\n`,(0,e.jsx)(n.p,{children:\"This works best when your metrics use DuckDB-compatible functions and data types. If a metric relies on warehouse-specific SQL, adapt the expression to DuckDB SQL before running it on Altertable.\"}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"seeds\",sectionTitle:\"Seeds\",anchors:\"\",ancestors:\"\",index:\"14\",children:[(0,e.jsx)(n.h2,{id:\"seeds\",children:\"Seeds\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"By default, \",(0,e.jsx)(n.code,{children:\"dbt seed\"}),\" inserts rows in batches so seeds work reliably across local files and remote execution. When you want a direct DuckDB \",(0,e.jsx)(n.code,{children:\"COPY\"}),\" path for a local seed file, set the seed config \",(0,e.jsx)(n.code,{children:\"fast: true\"}),\".\"]}),`\n`,(0,e.jsx)(n.pre,{children:(0,e.jsx)(n.code,{className:\"language-yaml\",children:`seeds:\n  your_project_name:\n    +fast: true\n`})}),`\n`,(0,e.jsx)(n.p,{children:\"Use the default batched path unless you know the seed file is accessible from the process running dbt.\"}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"incremental-models\",sectionTitle:\"Incremental models\",anchors:\"\",ancestors:\"\",index:\"15\",children:[(0,e.jsx)(n.h2,{id:\"incremental-models\",children:\"Incremental models\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"The adapter supports \",(0,e.jsx)(n.code,{children:\"delete+insert\"}),\", \",(0,e.jsx)(n.code,{children:\"merge\"}),\", and sequential \",(0,e.jsx)(n.code,{children:\"microbatch\"}),\" incremental strategies. With \",(0,e.jsx)(n.code,{children:\"delete+insert\"}),\", configure a stable \",(0,e.jsx)(n.code,{children:\"unique_key\"}),\" so each run deletes matching destination rows before inserting the updated batch:\"]}),`\n`,(0,e.jsx)(n.pre,{children:(0,e.jsx)(n.code,{className:\"language-sql\",children:`{{ config(\n    materialized='incremental',\n    incremental_strategy='delete+insert',\n    unique_key='id'\n) }}\n\nSELECT *\nFROM {{ source('app', 'orders') }}\n{% if is_incremental() %}\nWHERE updated_at > (SELECT max(updated_at) FROM {{ this }})\n{% endif %}\n`})}),`\n`,(0,e.jsx)(n.p,{children:\"Each dbt connection uses an isolated Flight session, so concurrent model work does not share temporary session state.\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"For more information about incremental strategies and adapter configuration, see the \",(0,e.jsx)(n.a,{href:\"https://docs.getdbt.com/docs/build/incremental-models\",children:\"dbt documentation\"}),\" and the \",(0,e.jsx)(n.a,{href:\"https://github.com/altertable-ai/dbt-altertable\",children:\"Altertable dbt adapter\"}),\".\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"persisting-descriptions\",sectionTitle:\"Persisting descriptions\",anchors:\"\",ancestors:\"\",index:\"16\",children:[(0,e.jsx)(n.h2,{id:\"persisting-descriptions\",children:\"Persisting descriptions\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"The adapter supports dbt's \",(0,e.jsx)(n.a,{href:\"https://docs.getdbt.com/reference/resource-configs/persist_docs\",children:(0,e.jsx)(n.code,{children:\"persist_docs\"})}),\" setting for model and column descriptions.\"]}),`\n`,(0,e.jsxs)(n.p,{children:[\"Enable it in \",(0,e.jsx)(n.code,{children:\"dbt_project.yml\"}),\" or on a model:\"]}),`\n`,(0,e.jsx)(n.pre,{children:(0,e.jsx)(n.code,{className:\"language-yaml\",children:`models:\n  your_project_name:\n    +persist_docs:\n      relation: true\n      columns: true\n`})}),`\n`,(0,e.jsxs)(n.p,{children:[\"After \",(0,e.jsx)(n.code,{children:\"dbt run\"}),\", dbt writes model and column descriptions to Altertable with DuckDB \",(0,e.jsx)(n.code,{children:\"COMMENT ON TABLE\"}),\" and \",(0,e.jsx)(n.code,{children:\"COMMENT ON COLUMN\"}),\" statements. View column comments are skipped gracefully when DuckDB cannot apply them.\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"python-models\",sectionTitle:\"Python models\",anchors:\"\",ancestors:\"\",index:\"17\",children:[(0,e.jsx)(n.h2,{id:\"python-models\",children:\"Python models\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"Python table and incremental models run in the dbt process. \",(0,e.jsx)(n.code,{children:\"dbt.ref()\"}),\" and \",(0,e.jsx)(n.code,{children:\"dbt.source()\"}),\" load the entire relation into memory as a \",(0,e.jsx)(n.code,{children:\"pyarrow.Table\"}),\", so size the inputs for that process. Return a value accepted by \",(0,e.jsx)(n.code,{children:\"pyarrow.table()\"}),\", such as a PyArrow table or pandas DataFrame.\"]}),`\n`,(0,e.jsx)(n.pre,{children:(0,e.jsx)(n.code,{className:\"language-python\",children:`def model(dbt, session):\n    dbt.config(materialized=\"table\")\n    return dbt.ref(\"stg_orders\")\n`})}),`\n`,(0,e.jsxs)(n.p,{children:[\"Install dependencies in dbt's Python environment. Use \",(0,e.jsx)(n.code,{children:\"session.cursor().execute(sql).table\"}),\" for SQL results. Reset a pandas index before returning it if it must become an output column. Python models do not support \",(0,e.jsx)(n.code,{children:\"partitioned_by\"}),\" or \",(0,e.jsx)(n.code,{children:\"sorted_by\"}),\".\"]}),`\n`]}),(0,e.jsxs)(t,{sectionId:\"source-code\",sectionTitle:\"Source Code\",anchors:\"\",ancestors:\"\",index:\"18\",children:[(0,e.jsx)(n.h2,{id:\"source-code\",children:\"Source Code\"}),`\n`,(0,e.jsxs)(n.p,{children:[\"The adapter source code is available at \",(0,e.jsx)(n.a,{href:\"https://github.com/altertable-ai/dbt-altertable\",children:\"github.com/altertable-ai/dbt-altertable\"})]})]})]})}function m(r={}){let{wrapper:n}=r.components||{};return n?(0,e.jsx)(n,{...r,children:(0,e.jsx)(h,{...r})}):h(r)}function c(r,n){throw new Error(\"Expected \"+(n?\"component\":\"object\")+\" `\"+r+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return x(_);})();\n;return Component;"},"_id":"docs/lakehouse/modeling/dbt.mdx","_raw":{"sourceFilePath":"docs/lakehouse/modeling/dbt.mdx","sourceFileName":"dbt.mdx","sourceFileDir":"docs/lakehouse/modeling","contentType":"mdx","flattenedPath":"docs/lakehouse/modeling/dbt"},"type":"Docs","path":"/lakehouse/modeling/dbt","level":3,"parent":"lakehouse/modeling"}