Skip to content

Commit 9bfae6d

Browse files
authored
Merge pull request #607 from atlanhq/APP-6398
APP-6398: Allow extra fields in `AtlanYamlModel` (`Extra.allow`) to support undefined contract fields
2 parents 2b7ad37 + f583605 commit 9bfae6d

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

pyatlan/model/contract.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class DCTag(AtlanYamlModel):
120120
name: Optional[str] = Field(
121121
default=None, description="Human-readable name of the Atlan tag."
122122
)
123-
propagate: Optional[str] = Field(
123+
propagate: Optional[Union[bool, str]] = Field(
124124
default=None, description="Whether to propagate the tag or not."
125125
)
126126
propagate_through_lineage: Optional[bool] = Field(
@@ -156,6 +156,10 @@ class DCColumn(AtlanYamlModel):
156156
default=None,
157157
description="When true, this column is the primary key for the table.",
158158
)
159+
required: Optional[bool] = Field(
160+
default=None,
161+
description="When true, this column is required for the table.",
162+
)
159163
data_type: Optional[str] = Field(
160164
default=None,
161165
description="Physical data type of values in this column (e.g. varchar(20)).",
@@ -188,7 +192,7 @@ class DCColumn(AtlanYamlModel):
188192
default_factory=list,
189193
description="Enumeration of values that should be considered missing.",
190194
)
191-
not_null: Optional[bool] = Field(
195+
not_null: Optional[Any] = Field(
192196
default=None, description="When true, this column cannot be empty."
193197
)
194198
valid_length: Optional[int] = Field(
@@ -205,6 +209,6 @@ class DCColumn(AtlanYamlModel):
205209
default=None,
206210
description="Minimum length for a string to be considered valid.",
207211
)
208-
unique: Optional[bool] = Field(
212+
unique: Optional[Any] = Field(
209213
default=None, description="When true, this column must have unique values."
210214
)

pyatlan/model/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ class AtlanYamlModel(BaseModel):
146146
"""
147147

148148
class Config:
149-
extra = Extra.ignore
149+
# Allow extra fields for contracts
150+
# if they are not defined in the model
151+
extra = Extra.allow
150152
validate_assignment = True
151153
allow_population_by_field_name = True
152154

tests/integration/test_sql_assets.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,11 @@ def test_contact_init_spec(self, client: AtlanClient):
787787
contract_spec
788788
and contract_spec.dataset # type: ignore[union-attr]
789789
and contract_spec.dataset == TestTable.table.name # type: ignore[union-attr]
790+
# Ensure non-modeled fields are retained correctly
791+
# (enabled by AtlanYamlModel → Config → Extra.allow)
792+
and contract_spec.columns
793+
and len(contract_spec.columns) >= 1
794+
and contract_spec.columns[0].tags == contract_spec.columns[0].terms == []
790795
)
791796
self._assert_table_contract(contract_spec.to_yaml(), TestColumn, is_raw=False) # type: ignore[union-attr]
792797

0 commit comments

Comments
 (0)