Skip to content

Commit a088be2

Browse files
authored
Merge branch 'master' into iceberg-1.7.0-upgrade
2 parents 5002ccf + 7b23e53 commit a088be2

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/RandomRecordGenerator.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.time.LocalDate;
3434
import java.time.LocalDateTime;
3535
import java.time.OffsetDateTime;
36+
import java.time.ZoneOffset;
3637
import java.util.ArrayList;
3738
import java.util.HashMap;
3839
import java.util.HashSet;
@@ -45,6 +46,12 @@
4546

4647
public class RandomRecordGenerator {
4748

49+
private static final LocalDate BASE_DATE = LocalDate.of(2026, 1, 1);
50+
private static final LocalDateTime BASE_LOCAL_DATE_TIME =
51+
LocalDateTime.of(2026, 1, 1, 12, 0, 0, 123_456_000);
52+
private static final OffsetDateTime BASE_OFFSET_DATE_TIME =
53+
OffsetDateTime.of(BASE_LOCAL_DATE_TIME, ZoneOffset.UTC);
54+
4855
private final Random random;
4956

5057
private final Schema primary;
@@ -120,7 +127,6 @@ public List<Record> scatter(int[] primaries) {
120127

121128
public Record randomRecord(int primaryValue) {
122129
Record record = GenericRecord.create(schema);
123-
Random random = new Random();
124130
List<Types.NestedField> columns = schema.columns();
125131
Map<Integer, Object> partitionValue = null;
126132
if (partitionValues != null) {
@@ -148,7 +154,6 @@ public Record randomRecord(int primaryValue) {
148154

149155
public Record randomRecord() {
150156
Record record = GenericRecord.create(schema);
151-
Random random = new Random();
152157
List<Types.NestedField> columns = schema.columns();
153158
Map<Integer, Object> partitionValue = null;
154159
if (partitionValues != null) {
@@ -170,7 +175,7 @@ private Object generateObject(Type type) {
170175
case INTEGER:
171176
return random.nextInt();
172177
case STRING:
173-
return UUID.randomUUID().toString();
178+
return new UUID(random.nextLong(), random.nextLong()).toString();
174179
case LONG:
175180
return random.nextLong();
176181
case FLOAT:
@@ -180,13 +185,17 @@ private Object generateObject(Type type) {
180185
case BOOLEAN:
181186
return random.nextBoolean();
182187
case DATE:
183-
return LocalDate.now().minusDays(random.nextInt(10000));
188+
return BASE_DATE.minusDays(random.nextInt(10000));
184189
case TIMESTAMP:
185190
Types.TimestampType timestampType = (Types.TimestampType) type;
186191
if (timestampType.shouldAdjustToUTC()) {
187-
return OffsetDateTime.now().minusDays(random.nextInt(10000));
192+
return BASE_OFFSET_DATE_TIME
193+
.minusDays(random.nextInt(10000))
194+
.plusNanos(random.nextInt(1_000_000) * 1_000L);
188195
} else {
189-
return LocalDateTime.now().minusDays(random.nextInt(10000));
196+
return BASE_LOCAL_DATE_TIME
197+
.minusDays(random.nextInt(10000))
198+
.plusNanos(random.nextInt(1_000_000) * 1_000L);
190199
}
191200
case DECIMAL:
192201
Types.DecimalType decimalType = (Types.DecimalType) type;

amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/TestKeyedContinuousOptimizing.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
@RunWith(Parameterized.class)
4949
public class TestKeyedContinuousOptimizing extends TableTestBase {
5050

51+
private static final long DATA_SEED = 1L;
52+
5153
@ClassRule public static TestHMS TEST_HMS = new TestHMS();
5254

5355
public TestKeyedContinuousOptimizing(
@@ -102,7 +104,7 @@ public void run() throws Exception {
102104
partitionCount,
103105
primaryUpperBound,
104106
writeTargetFileSize,
105-
null);
107+
DATA_SEED);
106108

107109
// init checker
108110
DataConcurrencyChecker dataConcurrencyChecker = new DataConcurrencyChecker(view);

amoro-ams/src/test/java/org/apache/amoro/server/optimizing/flow/TestUnKeyedContinuousOptimizing.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
@RunWith(Parameterized.class)
4949
public class TestUnKeyedContinuousOptimizing extends TableTestBase {
5050

51+
private static final long DATA_SEED = 1L;
52+
5153
@ClassRule public static TestHMS TEST_HMS = new TestHMS();
5254

5355
public TestUnKeyedContinuousOptimizing(
@@ -97,7 +99,7 @@ public void run() throws Exception {
9799
// Need move file to hive scene
98100

99101
UnKeyedTableDataView view =
100-
new UnKeyedTableDataView(table, partitionCount, writeTargetFileSize, null);
102+
new UnKeyedTableDataView(table, partitionCount, writeTargetFileSize, DATA_SEED);
101103

102104
// init checker
103105
DataConcurrencyChecker dataConcurrencyChecker = new DataConcurrencyChecker(view);

amoro-common/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,18 @@
194194
</java>
195195
</configuration>
196196
</plugin>
197+
<plugin>
198+
<groupId>org.apache.maven.plugins</groupId>
199+
<artifactId>maven-checkstyle-plugin</artifactId>
200+
<configuration>
201+
<excludes>src/main/gen-java/**</excludes>
202+
</configuration>
203+
</plugin>
204+
205+
<plugin>
206+
<groupId>org.apache.maven.plugins</groupId>
207+
<artifactId>maven-surefire-plugin</artifactId>
208+
</plugin>
197209
</plugins>
198210
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
199211
</build>

0 commit comments

Comments
 (0)