feat(glue): data quality rulesets (#7035)

* feat(glue): data quality rulesets

CreateDataQualityRuleset, GetDataQualityRuleset, UpdateDataQualityRuleset
and DeleteDataQualityRuleset answered InvalidAction, and
ListDataQualityRulesets always returned an empty list, so Terraform's
aws_glue_data_quality_ruleset failed at its first apply.

Rulesets are now stored per account and Region by name, with their
description, DQDL text, target table, security configuration and created
and last modified times, and tagged through the shared tag store by their
dataQualityRuleset ARN. Update replaces only the members the request sets.
List returns them in name order with RuleCount, filtered by name,
description, target table, created and last modified times and tags, and
paged by MaxResults and NextToken. Errors follow the model:
AlreadyExistsException for a duplicate, EntityNotFoundException for an
unknown name, InvalidInputException for a missing or oversized member.

Rulesets are stored, not evaluated.

Closes #6830

* fix(glue): match a ruleset's catalog and take its store from the caller

The ListDataQualityRulesets target table filter compared only TableName and
DatabaseName, so filtering for one catalog also returned a ruleset on the
same table in another. A CatalogId in the filter now has to match too, with
a target table that names no catalog in the account's own.

The package-private GlueService constructor built the ruleset store itself;
it now takes it as an argument, as it does every other store.

* fix(glue): reuse hasTags and AwsJsonTimestamp for ruleset listing

The ruleset tag filter now goes through hasTags, as jobs, crawlers and
triggers do, and the list filter's timestamps through
AwsJsonTimestamp.epochSeconds, so a timestamp sent as a string is refused
with InvalidInputException as the SDKs never send one.

---------

Co-authored-by: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>
This commit is contained in:
DavidandPriamo Germosen authored and GitHub committed 2026-10-30 22:36:13 -04:00
1 parent 3a941bc450
commit 6db78b8ef4
10 files changed
+795 -8

No files matched your search

@@ -0,0 +1,81 @@
package com.floci.test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.glue.GlueClient;
import software.amazon.awssdk.services.glue.model.AlreadyExistsException;
import software.amazon.awssdk.services.glue.model.DataQualityRulesetListDetails;
import software.amazon.awssdk.services.glue.model.EntityNotFoundException;
import software.amazon.awssdk.services.glue.model.GetDataQualityRulesetResponse;
import software.amazon.awssdk.services.glue.model.UpdateDataQualityRulesetResponse;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@DisplayName("Glue data quality rulesets")
class GlueDataQualityRulesetTest {
private static final String NAME = TestFixtures.uniqueName("dq_ruleset");
private static final String RULESET = "Rules = [ RowCount > 0, IsComplete \"id\" ]";
private static GlueClient glue;
@BeforeAll
static void setup() {
glue = TestFixtures.glueClient();
}
@AfterAll
static void cleanup() {
if (glue == null) {
return;
}
try {
glue.deleteDataQualityRuleset(r -> r.name(NAME));
}
catch (Exception ignored) {
// Cleanup is best effort: the name is unique to this run and the emulator is disposable.
}
}
@Test
void sdkRoundTripsADataQualityRuleset() {
Instant before = Instant.now().minusSeconds(60);
assertThat(glue.createDataQualityRuleset(r -> r.name(NAME).description("orders checks").ruleset(RULESET)
.targetTable(t -> t.tableName("orders").databaseName("sales"))
.tags(Map.of("team", "data"))).name()).isEqualTo(NAME);
assertThatThrownBy(() -> glue.createDataQualityRuleset(r -> r.name(NAME).ruleset(RULESET)))
.isInstanceOf(AlreadyExistsException.class);
GetDataQualityRulesetResponse got = glue.getDataQualityRuleset(r -> r.name(NAME));
assertThat(got.ruleset()).isEqualTo(RULESET);
assertThat(got.targetTable().databaseName()).isEqualTo("sales");
assertThat(got.createdOn()).isAfter(before);
assertThat(got.lastModifiedOn()).isEqualTo(got.createdOn());
UpdateDataQualityRulesetResponse updated = glue.updateDataQualityRuleset(r -> r.name(NAME)
.description("orders, nightly"));
assertThat(updated.ruleset()).isEqualTo(RULESET);
assertThat(updated.description()).isEqualTo("orders, nightly");
List<DataQualityRulesetListDetails> listed = glue.listDataQualityRulesets(r -> r
.filter(f -> f.targetTable(t -> t.tableName("orders").databaseName("sales"))
.createdAfter(before))
.tags(Map.of("team", "data"))).rulesets();
assertThat(listed).extracting(DataQualityRulesetListDetails::name).contains(NAME);
DataQualityRulesetListDetails item = listed.stream().filter(d -> d.name().equals(NAME)).findFirst()
.orElseThrow();
assertThat(item.ruleCount()).isEqualTo(2);
assertThat(item.createdOn()).isEqualTo(got.createdOn());
glue.deleteDataQualityRuleset(r -> r.name(NAME));
assertThatThrownBy(() -> glue.getDataQualityRuleset(r -> r.name(NAME)))
.isInstanceOf(EntityNotFoundException.class);
}
}