This is an automated email from the ASF dual-hosted git repository. yuzelin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git
The following commit(s) were added to refs/heads/master by this push: new 6b22fad9a [core] Fix modify tag period exception (#2275) 6b22fad9a is described below commit 6b22fad9a410ded881a5cb11c2ab9e9cc1b33dea Author: monster <60029759+monsterchenz...@users.noreply.github.com> AuthorDate: Tue Nov 7 19:17:39 2023 +0800 [core] Fix modify tag period exception (#2275) --- .../org/apache/paimon/tag/TagPeriodHandler.java | 1 + .../org/apache/paimon/tag/TagAutoCreationTest.java | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/paimon-core/src/main/java/org/apache/paimon/tag/TagPeriodHandler.java b/paimon-core/src/main/java/org/apache/paimon/tag/TagPeriodHandler.java index bf7af0497..106b0d974 100644 --- a/paimon-core/src/main/java/org/apache/paimon/tag/TagPeriodHandler.java +++ b/paimon-core/src/main/java/org/apache/paimon/tag/TagPeriodHandler.java @@ -141,6 +141,7 @@ public interface TagPeriodHandler { @Override public LocalDateTime tagToTime(String tag) { + tag = tag.split(" ")[0]; return LocalDate.parse(tag, formatter()).atStartOfDay(); } } diff --git a/paimon-core/src/test/java/org/apache/paimon/tag/TagAutoCreationTest.java b/paimon-core/src/test/java/org/apache/paimon/tag/TagAutoCreationTest.java index 5ce5ba9c5..53dd6aed2 100644 --- a/paimon-core/src/test/java/org/apache/paimon/tag/TagAutoCreationTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/tag/TagAutoCreationTest.java @@ -188,6 +188,33 @@ public class TagAutoCreationTest extends PrimaryKeyTableTestBase { commit.close(); } + @Test + public void testModifyTagPeriod() { + Options options = new Options(); + options.set(TAG_AUTOMATIC_CREATION, TagCreationMode.WATERMARK); + options.set(TAG_CREATION_PERIOD, TagCreationPeriod.HOURLY); + options.set(SINK_WATERMARK_TIME_ZONE, ZoneId.systemDefault().toString()); + FileStoreTable table; + TableCommitImpl commit; + TagManager tagManager; + table = this.table.copy(options.toMap()); + commit = table.newCommit(commitUser).ignoreEmptyCommit(false); + tagManager = table.store().newTagManager(); + + // test first create + commit.commit(new ManifestCommittable(0, localZoneMills("2023-07-18T12:00:09"))); + assertThat(tagManager.tags().values()).containsOnly("2023-07-18 11"); + + options.set(TAG_CREATION_PERIOD, TagCreationPeriod.DAILY); + table = table.copy(options.toMap()); + commit = table.newCommit(commitUser).ignoreEmptyCommit(false); + tagManager = table.store().newTagManager(); + + // test newCommit create + commit.commit(new ManifestCommittable(0, utcMills("2023-07-20T12:00:01"))); + assertThat(tagManager.tags().values()).contains("2023-07-18 11", "2023-07-19"); + } + private long localZoneMills(String timestamp) { return LocalDateTime.parse(timestamp) .atZone(ZoneId.systemDefault())