diff --git a/docs/layouts/shortcodes/generated/core_configuration.html b/docs/layouts/shortcodes/generated/core_configuration.html
index fc5c04477bc1..3a554731f26a 100644
--- a/docs/layouts/shortcodes/generated/core_configuration.html
+++ b/docs/layouts/shortcodes/generated/core_configuration.html
@@ -1012,7 +1012,7 @@
tag.period-formatter |
with_dashes |
Enum |
- The date format for tag periods.
Possible values:- "with_dashes": Dates and hours with dashes, e.g., 'yyyy-MM-dd HH'
- "without_dashes": Dates and hours without dashes, e.g., 'yyyyMMdd HH'
|
+ The date format for tag periods.
Possible values:- "with_dashes": Dates and hours with dashes, e.g., 'yyyy-MM-dd HH'
- "without_dashes": Dates and hours without dashes, e.g., 'yyyyMMdd HH'
- "without_dashes_and_spaces": Dates and hours without dashes and spaces, e.g., 'yyyyMMddHH'
|
target-file-size |
diff --git a/paimon-common/src/main/java/org/apache/paimon/CoreOptions.java b/paimon-common/src/main/java/org/apache/paimon/CoreOptions.java
index 4aabb8b4d98e..c35e89e82ba7 100644
--- a/paimon-common/src/main/java/org/apache/paimon/CoreOptions.java
+++ b/paimon-common/src/main/java/org/apache/paimon/CoreOptions.java
@@ -2999,7 +2999,10 @@ public InlineElement getDescription() {
/** The period format options for tag creation. */
public enum TagPeriodFormatter implements DescribedEnum {
WITH_DASHES("with_dashes", "Dates and hours with dashes, e.g., 'yyyy-MM-dd HH'"),
- WITHOUT_DASHES("without_dashes", "Dates and hours without dashes, e.g., 'yyyyMMdd HH'");
+ WITHOUT_DASHES("without_dashes", "Dates and hours without dashes, e.g., 'yyyyMMdd HH'"),
+ WITHOUT_DASHES_AND_SPACES(
+ "without_dashes_and_spaces",
+ "Dates and hours without dashes and spaces, e.g., 'yyyyMMddHH'");
private final String value;
private final String description;
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 31e1bd2e283f..2d0df61b6aaf 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
@@ -61,6 +61,15 @@ public interface TagPeriodHandler {
.toFormatter()
.withResolverStyle(ResolverStyle.LENIENT);
+ DateTimeFormatter HOUR_FORMATTER_WITHOUT_DASHES_AND_SPACES =
+ new DateTimeFormatterBuilder()
+ .appendValue(YEAR, 1, 10, SignStyle.NORMAL)
+ .appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NORMAL)
+ .appendValue(DAY_OF_MONTH, 2, 2, SignStyle.NORMAL)
+ .appendValue(HOUR_OF_DAY, 2, 2, SignStyle.NORMAL)
+ .toFormatter()
+ .withResolverStyle(ResolverStyle.LENIENT);
+
DateTimeFormatter MINUTE_FORMATTER =
new DateTimeFormatterBuilder()
.appendValue(YEAR, 1, 10, SignStyle.NORMAL)
@@ -179,6 +188,8 @@ protected DateTimeFormatter formatter() {
return HOUR_FORMATTER;
case WITHOUT_DASHES:
return HOUR_FORMATTER_WITHOUT_DASHES;
+ case WITHOUT_DASHES_AND_SPACES:
+ return HOUR_FORMATTER_WITHOUT_DASHES_AND_SPACES;
default:
throw new IllegalArgumentException("Unsupported date format type");
}
@@ -207,6 +218,7 @@ protected DateTimeFormatter formatter() {
case WITH_DASHES:
return DAY_FORMATTER;
case WITHOUT_DASHES:
+ case WITHOUT_DASHES_AND_SPACES:
return DAY_FORMATTER_WITHOUT_DASHES;
default:
throw new IllegalArgumentException("Unsupported date format type");
diff --git a/paimon-core/src/test/java/org/apache/paimon/tag/TagAutoManagerTest.java b/paimon-core/src/test/java/org/apache/paimon/tag/TagAutoManagerTest.java
index 4dfa802f8122..407e42d5affa 100644
--- a/paimon-core/src/test/java/org/apache/paimon/tag/TagAutoManagerTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/tag/TagAutoManagerTest.java
@@ -291,6 +291,23 @@ public void testTagHourlyPeriodFormatter() {
assertThat(tagManager.allTagNames()).contains("20230718 11", "20230718 12");
}
+ @Test
+ public void testTagHourlyPeriodFormatterWithoutDashesAndSpaces() {
+ Options options = new Options();
+ options.set(TAG_AUTOMATIC_CREATION, TagCreationMode.WATERMARK);
+ options.set(TAG_CREATION_PERIOD, TagCreationPeriod.HOURLY);
+ options.set(TAG_PERIOD_FORMATTER, TagPeriodFormatter.WITHOUT_DASHES_AND_SPACES);
+ FileStoreTable table = this.table.copy(options.toMap());
+ TableCommitImpl commit = table.newCommit(commitUser).ignoreEmptyCommit(false);
+ TagManager tagManager = table.store().newTagManager();
+
+ commit.commit(new ManifestCommittable(0, utcMills("2023-07-18T12:12:00")));
+ assertThat(tagManager.allTagNames()).containsOnly("2023071811");
+
+ commit.commit(new ManifestCommittable(1, utcMills("2023-07-18T13:13:00")));
+ assertThat(tagManager.allTagNames()).contains("2023071811", "2023071812");
+ }
+
@Test
public void testOnlyExpireAutoCreatedTag() {
Options options = new Options();