Skip to content

Commit de918a6

Browse files
mskyrimMehdi DARDANIahmedabu98
authored
fix(iceberg): Incorrect $partition Metadata in Trino for Iceberg Tables Written via IcebergIO.writeRows with Timestamp Partitioning (#36562)
* fix(iceberg): update month calculation to use ChronoUnit for improved accuracy * fix(tests): update trigger file comment and modification count for IO Iceberg Integration Tests * Update IO_Iceberg_Integration_Tests.json --------- Co-authored-by: Mehdi DARDANI <[email protected]> Co-authored-by: Ahmed Abualsaud <[email protected]>
1 parent d134f24 commit de918a6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"comment": "Modify this file in a trivial way to cause this test suite to run.",
3-
"modification": 3
3+
"modification": 4
44
}

sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/RecordWriterManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ static String getPartitionDataPath(
228228
String transformName =
229229
Preconditions.checkArgumentNotNull(partitionFieldMap.get(name)).transform().toString();
230230
if (Transforms.month().toString().equals(transformName)) {
231-
int month = YearMonth.parse(value).getMonthValue();
232-
value = String.valueOf(month);
231+
long months =
232+
ChronoUnit.MONTHS.between(EPOCH, YearMonth.parse(value).atDay(1).atStartOfDay());
233+
value = String.valueOf(months);
233234
} else if (Transforms.hour().toString().equals(transformName)) {
234235
long hour = ChronoUnit.HOURS.between(EPOCH, LocalDateTime.parse(value, HOUR_FORMATTER));
235236
value = String.valueOf(hour);

0 commit comments

Comments
 (0)