translator
Custom dbt translator that enriches assets with organization specific metadata.
The translator hooks into Dagster's dbt integration to map naming conventions and
custom meta fields to Dagster concepts such as asset keys, groups, and automation
conditions. Each override documents the required dbt metadata shape and the Dagster
structure returned.
CustomDagsterDbtTranslator
Bases: DagsterDbtTranslator
Overrides methods of the standard translator.
Holds a set of methods that derive Dagster asset definition metadata given a representation of a dbt resource (models, tests, sources, etc). Methods are overridden to customize the implementation.
See parent class for details on the purpose of each override
Source code in data_foundation/defs/dbt/translator.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
get_asset_key(dbt_resource_props)
Derive the Dagster asset key from dbt metadata or naming conventions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dbt_resource_props
|
Mapping[str, Any]
|
Dictionary representing the dbt node. |
required |
Returns:
| Type | Description |
|---|---|
AssetKey
|
dagster.AssetKey: Asset key built either from explicit metadata or inferred from the resource name, schema, and processing step. |
Source code in data_foundation/defs/dbt/translator.py
get_automation_condition(dbt_resource_props)
Translate organization-specific automation defaults for dbt resources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dbt_resource_props
|
Mapping[str, Any]
|
dbt node dictionary that may include explicit automation
directives under |
required |
Returns:
| Type | Description |
|---|---|
AutomationCondition | None
|
dagster.AutomationCondition | None: The resolved automation condition, or
|
Source code in data_foundation/defs/dbt/translator.py
get_group_name(dbt_resource_props)
Extract the asset group from the dbt resource naming convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dbt_resource_props
|
Mapping[str, Any]
|
dbt node dictionary used to extract the schema portion of the resource name. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The schema name used as the Dagster asset group or |
Source code in data_foundation/defs/dbt/translator.py
get_partitions_def(dbt_resource_props)
Inspect dbt metadata for partition configuration and map to Dagster types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dbt_resource_props
|
Mapping[str, Any]
|
dbt node dictionary whose |
required |
Returns:
| Type | Description |
|---|---|
PartitionsDefinition | None
|
dagster.PartitionsDefinition | None: A concrete partitions definition when
metadata is provided, otherwise |
Source code in data_foundation/defs/dbt/translator.py
get_tags(dbt_resource_props)
Augment the base translator's tags with organization-specific entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dbt_resource_props
|
Mapping[str, Any]
|
dbt node dictionary used by the parent implementation to build the default tag mapping. |
required |
Returns:
| Type | Description |
|---|---|
Mapping[str, str]
|
Mapping[str, str]: Tag dictionary that can be surfaced on Dagster assets for discovery and documentation purposes. |