Skip to content

Commit

Permalink
[core] Delete tag not failed if tag not exists (#4292)
Browse files Browse the repository at this point in the history
  • Loading branch information
askwang authored Oct 9, 2024
1 parent eed7896 commit ba98f31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ public void deleteTag(
List<TagCallback> callbacks) {
checkArgument(
!StringUtils.isNullOrWhitespaceOnly(tagName), "Tag name '%s' is blank.", tagName);
checkArgument(tagExists(tagName), "Tag '%s' doesn't exist.", tagName);
if (!tagExists(tagName)) {
LOG.warn("Tag '{}' doesn't exist.", tagName);
return;
}

Snapshot taggedSnapshot = taggedSnapshot(tagName);
List<Snapshot> taggedSnapshots;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1425,10 +1425,7 @@ public void testDeleteTag() throws Exception {
table.createTag("tag1", 1);
table.deleteTag("tag1");

assertThatThrownBy(() -> table.deleteTag("tag1"))
.satisfies(
anyCauseMatches(
IllegalArgumentException.class, "Tag 'tag1' doesn't exist."));
assertThat(table.tagManager().tags().containsValue("tag1")).isFalse();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,12 @@ class CreateAndDeleteTagProcedureTest extends PaimonSparkTestBase with StreamTes
}
}
}

test("Paimon Procedure: delete tag not failed if tag not exists") {
spark.sql("CREATE TABLE T (id STRING, name STRING) USING PAIMON")

checkAnswer(
spark.sql("CALL paimon.sys.delete_tag(table => 'test.T', tag => 'test_tag')"),
Row(true) :: Nil)
}
}

0 comments on commit ba98f31

Please sign in to comment.