This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 7bfb13f132 [core] Support enums without spaces in TagPeriodFormatter
(#5165)
7bfb13f132 is described below
commit 7bfb13f132c9171fe26506ecf83447290aaedd33
Author: chenxinwei <[email protected]>
AuthorDate: Mon Mar 3 16:37:42 2025 +0800
[core] Support enums without spaces in TagPeriodFormatter (#5165)
---
.../shortcodes/generated/core_configuration.html | 2 +-
.../src/main/java/org/apache/paimon/CoreOptions.java | 5 ++++-
.../java/org/apache/paimon/tag/TagPeriodHandler.java | 12 ++++++++++++
.../java/org/apache/paimon/tag/TagAutoManagerTest.java | 17 +++++++++++++++++
4 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/docs/layouts/shortcodes/generated/core_configuration.html
b/docs/layouts/shortcodes/generated/core_configuration.html
index 8e845b5a23..93bbb012cc 100644
--- a/docs/layouts/shortcodes/generated/core_configuration.html
+++ b/docs/layouts/shortcodes/generated/core_configuration.html
@@ -1024,7 +1024,7 @@ If the data size allocated for the sorting task is
uneven,which may lead to perf
<td><h5>tag.period-formatter</h5></td>
<td style="word-wrap: break-word;">with_dashes</td>
<td><p>Enum</p></td>
- <td>The date format for tag periods.<br /><br />Possible
values:<ul><li>"with_dashes": Dates and hours with dashes, e.g., 'yyyy-MM-dd
HH'</li><li>"without_dashes": Dates and hours without dashes, e.g., 'yyyyMMdd
HH'</li></ul></td>
+ <td>The date format for tag periods.<br /><br />Possible
values:<ul><li>"with_dashes": Dates and hours with dashes, e.g., 'yyyy-MM-dd
HH'</li><li>"without_dashes": Dates and hours without dashes, e.g., 'yyyyMMdd
HH'</li><li>"without_dashes_and_spaces": Dates and hours without dashes and
spaces, e.g., 'yyyyMMddHH'</li></ul></td>
</tr>
<tr>
<td><h5>target-file-size</h5></td>
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 da06d63ec6..a41c478724 100644
--- a/paimon-common/src/main/java/org/apache/paimon/CoreOptions.java
+++ b/paimon-common/src/main/java/org/apache/paimon/CoreOptions.java
@@ -3036,7 +3036,10 @@ public class CoreOptions implements Serializable {
/** 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 31e1bd2e28..2d0df61b6a 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 @@ public interface TagPeriodHandler {
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 @@ public interface TagPeriodHandler {
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 4dfa802f81..407e42d5af 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 class TagAutoManagerTest extends
PrimaryKeyTableTestBase {
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();