-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fixes 32792: let CreateTableRequest carry certification directly #32793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
41e0efc
58638b0
56d4e5c
1fd6ca5
03c28a2
499283a
76b5797
c3416f5
16fbbed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| DataType, | ||
| TableConstraint, | ||
| ) | ||
| from metadata.generated.schema.type.assetCertification import AssetCertification | ||
| from metadata.generated.schema.type.entityReference import EntityReference | ||
| from metadata.generated.schema.type.tagLabel import ( | ||
| LabelType, | ||
|
|
@@ -41,6 +42,19 @@ | |
| ) | ||
|
|
||
|
|
||
| def _certification(tag_fqn: str = "Certification.Bronze") -> AssetCertification: | ||
| return AssetCertification( | ||
| tagLabel=TagLabel( | ||
| tagFQN=tag_fqn, | ||
| source=TagSource.Classification, | ||
| labelType=LabelType.Automated, | ||
| state=State.Confirmed, | ||
| ), | ||
| appliedDate=1700000000000, | ||
| expiryDate=1731536000000, | ||
| ) | ||
|
|
||
|
|
||
| class TestNormalizeWhitespace: | ||
| def test_normalize_whitespace_none(self): | ||
| assert _normalize_whitespace(None) is None | ||
|
|
@@ -470,6 +484,90 @@ def test_hash_excludes_source_hash_field(self): | |
| ) | ||
| assert generate_source_hash(request1) == generate_source_hash(request2) | ||
|
|
||
| def test_hash_changes_with_certification_added(self): | ||
| request1 = CreateTableRequest( | ||
| name="test_table", | ||
| databaseSchema="service.db.schema", | ||
| columns=[Column(name="id", dataType=DataType.INT)], | ||
| ) | ||
| request2 = CreateTableRequest( | ||
| name="test_table", | ||
| databaseSchema="service.db.schema", | ||
| columns=[Column(name="id", dataType=DataType.INT)], | ||
| certification=_certification("Certification.Bronze"), | ||
| ) | ||
| assert generate_source_hash(request1) != generate_source_hash(request2) | ||
|
|
||
| def test_hash_changes_with_certification_value_change(self): | ||
| request1 = CreateTableRequest( | ||
| name="test_table", | ||
| databaseSchema="service.db.schema", | ||
| columns=[Column(name="id", dataType=DataType.INT)], | ||
| certification=_certification("Certification.Bronze"), | ||
| ) | ||
| request2 = CreateTableRequest( | ||
| name="test_table", | ||
| databaseSchema="service.db.schema", | ||
| columns=[Column(name="id", dataType=DataType.INT)], | ||
| certification=_certification("Certification.Gold"), | ||
| ) | ||
| assert generate_source_hash(request1) != generate_source_hash(request2) | ||
|
|
||
| def test_hash_stable_when_certification_omitted(self): | ||
| request1 = CreateTableRequest( | ||
| name="test_table", | ||
| databaseSchema="service.db.schema", | ||
| columns=[Column(name="id", dataType=DataType.INT)], | ||
| ) | ||
| request2 = CreateTableRequest( | ||
| name="test_table", | ||
| databaseSchema="service.db.schema", | ||
| columns=[Column(name="id", dataType=DataType.INT)], | ||
| certification=None, | ||
| ) | ||
| assert generate_source_hash(request1) == generate_source_hash(request2) | ||
|
|
||
| def test_hash_stable_with_equivalent_certification_payload(self): | ||
| request1 = CreateTableRequest( | ||
| name="test_table", | ||
| databaseSchema="service.db.schema", | ||
| columns=[Column(name="id", dataType=DataType.INT)], | ||
| certification=_certification("Certification.Silver"), | ||
| ) | ||
| request2 = CreateTableRequest( | ||
| name="test_table", | ||
| databaseSchema="service.db.schema", | ||
| columns=[Column(name="id", dataType=DataType.INT)], | ||
| certification=_certification("Certification.Silver"), | ||
| ) | ||
| assert generate_source_hash(request1) == generate_source_hash(request2) | ||
|
|
||
| def test_hash_stable_across_certification_applied_and_expiry_dates(self): | ||
| """appliedDate/expiryDate are always recomputed server-side from | ||
| AssetCertificationSettings when a certification is applied, so a | ||
| connector populating them with a run-time-relative value (e.g. now()) | ||
| must not defeat the bulk fast-path when the certification itself is | ||
| unchanged. Only tagLabel is a real change-detection signal.""" | ||
| tag_label = TagLabel( | ||
| tagFQN="Certification.Gold", | ||
| source=TagSource.Classification, | ||
| labelType=LabelType.Automated, | ||
| state=State.Confirmed, | ||
| ) | ||
| request1 = CreateTableRequest( | ||
| name="test_table", | ||
| databaseSchema="service.db.schema", | ||
| columns=[Column(name="id", dataType=DataType.INT)], | ||
| certification=AssetCertification(tagLabel=tag_label, appliedDate=1700000000000, expiryDate=1731536000000), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checked — both lines are 118 characters, under the 120 limit ( |
||
| ) | ||
| request2 = CreateTableRequest( | ||
| name="test_table", | ||
| databaseSchema="service.db.schema", | ||
| columns=[Column(name="id", dataType=DataType.INT)], | ||
| certification=AssetCertification(tagLabel=tag_label, appliedDate=1800000000000, expiryDate=1999999999999), | ||
| ) | ||
| assert generate_source_hash(request1) == generate_source_hash(request2) | ||
|
|
||
| def test_hash_with_custom_exclude_fields(self): | ||
| request1 = CreateTableRequest( | ||
| name="test_table", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.