YadsSpec¶
YadsSpec
dataclass
¶
Canonical yads specification.
Represents a complete table definition including columns, constraints, storage properties, partitioning, and metadata. Instances are immutable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Fully qualified table name (e.g., "catalog.database.table"). |
required |
version
|
int
|
Registry-assigned monotonic integer version for tracking changes. |
required |
yads_spec_version
|
str
|
Version of the yads specification format itself. |
YADS_SPEC_VERSION
|
columns
|
list[Column]
|
List of Column objects defining the table structure. |
_empty_columns()
|
description
|
str | None
|
Optional human-readable description of the table. |
None
|
external
|
bool
|
Whether to generate |
False
|
storage
|
Storage | None
|
Storage configuration including format and properties. |
None
|
partitioned_by
|
list[TransformedColumnReference]
|
List of partition columns. |
_empty_partitions()
|
table_constraints
|
list[TableConstraint]
|
List of table-level constraints (e.g., composite keys). |
_empty_table_constraints()
|
metadata
|
dict[str, Any]
|
Additional metadata as key-value pairs. |
_empty_metadata()
|
Raises:
| Type | Description |
|---|---|
SpecValidationError
|
If the spec contains validation errors such as duplicate column names, undefined partition columns, or invalid constraint references. |
Source code in src/yads/spec.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
column_names
cached
property
¶
Set of all column names defined in the spec.
constrained_columns
cached
property
¶
Set of column names that have any constraints defined.
generated_columns
cached
property
¶
Mapping of generated column names to their source columns with format:
{generated_column_name: source_column_name}.
nullable_columns
cached
property
¶
Set of column names that allow NULL values.
partition_column_names
cached
property
¶
Set of column names referenced as partition columns.
to_dict()
¶
Serialize this spec into the canonical dictionary format.
Source code in src/yads/spec.py
297 298 299 300 301 | |
Field
dataclass
¶
A named, typed data field with optional constraints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Field identifier. |
required |
type
|
YadsType
|
Logical yads type of the field. |
required |
description
|
str | None
|
Optional human-friendly description. |
None
|
metadata
|
dict[str, Any]
|
Arbitrary key-value metadata for consumers. |
_empty_metadata()
|
constraints
|
list[ColumnConstraint]
|
Column-level constraints such as nullability or checks. |
_empty_constraints()
|
Source code in src/yads/spec.py
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 | |
constraint_types
cached
property
¶
Set of constraint types applied to this field.
has_constraints
cached
property
¶
True if this field has any constraints defined.
has_metadata
cached
property
¶
True if the field has any metadata defined.
is_nullable
cached
property
¶
True if this field allows NULL values.
Column
dataclass
¶
Bases: Field
Table column extending Field with generation support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Column name. |
required |
type
|
YadsType
|
Logical yads type of the column. |
required |
description
|
str | None
|
Optional human-friendly description. |
None
|
metadata
|
dict[str, Any]
|
Arbitrary key-value metadata for consumers. |
_empty_metadata()
|
constraints
|
list[ColumnConstraint]
|
Column-level constraints such as nullability or checks. |
_empty_constraints()
|
generated_as
|
TransformedColumnReference | None
|
Optional expression defining a generated/computed column. |
None
|
Source code in src/yads/spec.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
constraint_types
cached
property
¶
Set of constraint types applied to this field.
has_constraints
cached
property
¶
True if this field has any constraints defined.
has_metadata
cached
property
¶
True if the field has any metadata defined.
is_generated
cached
property
¶
True if this column is a generated/computed column.
is_nullable
cached
property
¶
True if this field allows NULL values.
TransformedColumnReference
dataclass
¶
Reference to a column with an optional transformation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
Name of the referenced column. |
required |
transform
|
str | None
|
Transformation function applied to the column, if any. |
None
|
transform_args
|
list[Any]
|
Arguments passed to the transformation. |
_empty_any_list()
|
Source code in src/yads/spec.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
Storage
dataclass
¶
Physical storage properties for a table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str | None
|
Storage format (e.g., "parquet", "delta"). |
None
|
location
|
str | None
|
Optional URI/path to the stored data. |
None
|
tbl_properties
|
dict[str, str]
|
Format-specific storage properties. |
_empty_tbl_properties()
|
Source code in src/yads/spec.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
from_dict(data)
¶
Build a YadsSpec from a normalized dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, Any]
|
Canonical spec dictionary to deserialize. |
required |
Returns:
| Type | Description |
|---|---|
YadsSpec
|
A fully validated |
Source code in src/yads/spec.py
18 19 20 21 22 23 24 25 26 27 28 29 | |