Repository: apache/iceberg (language: python)

Issue:
Fix some `long` casting issues
These locations popped up in IntelliJ, and the suggested fixes looked correct, so raising this PR.


Discussion / hints:

Fix patch:
diff --git a/flink/v1.17/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java b/flink/v1.17/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java
index ad4310a6d195..a5f2bb738960 100644
--- a/flink/v1.17/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java
+++ b/flink/v1.17/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java
@@ -422,7 +422,7 @@ public TimestampData read(TimestampData ignored) {
       long value = readLong();
       return TimestampData.fromLocalDateTime(
           Instant.ofEpochSecond(
-                  Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000)
+                  Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L)
               .atOffset(ZoneOffset.UTC)
               .toLocalDateTime());
     }
@@ -444,7 +444,7 @@ public TimestampData read(TimestampData ignored) {
       long value = readLong();
       return TimestampData.fromInstant(
           Instant.ofEpochSecond(
-              Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000));
+              Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L));
     }
 
     @Override
@@ -517,7 +517,7 @@ private static class LossyMicrosToMillisTimeReader
     @Override
     public Integer read(Integer reuse) {
       // Discard microseconds since Flink uses millisecond unit for TIME type.
-      return (int) Math.floorDiv(column.nextLong(), 1000);
+      return (int) Math.floorDiv(column.nextLong(), 1000L);
     }
   }
 
diff --git a/flink/v1.18/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java b/flink/v1.18/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java
index ad4310a6d195..a5f2bb738960 100644
--- a/flink/v1.18/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java
+++ b/flink/v1.18/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java
@@ -422,7 +422,7 @@ public TimestampData read(TimestampData ignored) {
       long value = readLong();
       return TimestampData.fromLocalDateTime(
           Instant.ofEpochSecond(
-                  Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000)
+                  Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L)
               .atOffset(ZoneOffset.UTC)
               .toLocalDateTime());
     }
@@ -444,7 +444,7 @@ public TimestampData read(TimestampData ignored) {
       long value = readLong();
       return TimestampData.fromInstant(
           Instant.ofEpochSecond(
-              Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000));
+              Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L));
     }
 
     @Override
@@ -517,7 +517,7 @@ private static class LossyMicrosToMillisTimeReader
     @Override
     public Integer read(Integer reuse) {
       // Discard microseconds since Flink uses millisecond unit for TIME type.
-      return (int) Math.floorDiv(column.nextLong(), 1000);
+      return (int) Math.floorDiv(column.nextLong(), 1000L);
     }
   }
 
diff --git a/flink/v1.19/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java b/flink/v1.19/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java
index d0a1974636be..a5f2bb738960 100644
--- a/flink/v1.19/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java
+++ b/flink/v1.19/flink/src/main/java/org/apache/iceberg/flink/data/FlinkParquetReaders.java
@@ -422,7 +422,7 @@ public TimestampData read(TimestampData ignored) {
       long value = readLong();
       return TimestampData.fromLocalDateTime(
           Instant.ofEpochSecond(
-                  Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000L)
+                  Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L)
               .atOffset(ZoneOffset.UTC)
               .toLocalDateTime());
     }
@@ -444,7 +444,7 @@ public TimestampData read(TimestampData ignored) {
       long value = readLong();
       return TimestampData.fromInstant(
           Instant.ofEpochSecond(
-              Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000L));
+              Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L));
     }
 
     @Override
@@ -517,7 +517,7 @@ private static class LossyMicrosToMillisTimeReader
     @Override
     public Integer read(Integer reuse) {
       // Discard microseconds since Flink uses millisecond unit for TIME type.
-      return (int) Math.floorDiv(column.nextLong(), 1000);
+      return (int) Math.floorDiv(column.nextLong(), 1000L);
     }
   }
 


Test patch:
diff --git a/flink/v1.17/flink/src/test/java/org/apache/iceberg/flink/source/assigner/TestWatermarkBasedSplitAssigner.java b/flink/v1.17/flink/src/test/java/org/apache/iceberg/flink/source/assigner/TestWatermarkBasedSplitAssigner.java
index e1fc63fda918..6c0cbb733320 100644
--- a/flink/v1.17/flink/src/test/java/org/apache/iceberg/flink/source/assigner/TestWatermarkBasedSplitAssigner.java
+++ b/flink/v1.17/flink/src/test/java/org/apache/iceberg/flink/source/assigner/TestWatermarkBasedSplitAssigner.java
@@ -123,7 +123,7 @@ protected List<IcebergSourceSplit> createSplits(
                         .mapToObj(
                             fileNum ->
                                 RandomGenericData.generate(
-                                    SCHEMA, 2, splitNum * filesPerSplit + fileNum))
+                                    SCHEMA, 2, (long) splitNum * filesPerSplit + fileNum))
                         .collect(Collectors.toList())))
         .collect(Collectors.toList());
   }
diff --git a/flink/v1.18/flink/src/test/java/org/apache/iceberg/flink/source/assigner/TestWatermarkBasedSplitAssigner.java b/flink/v1.18/flink/src/test/java/org/apache/iceberg/flink/source/assigner/TestWatermarkBasedSplitAssigner.java
index e1fc63fda918..6c0cbb733320 100644
--- a/flink/v1.18/flink/src/test/java/org/apache/iceberg/flink/source/assigner/TestWatermarkBasedSplitAssigner.java
+++ b/flink/v1.18/flink/src/test/java/org/apache/iceberg/flink/source/assigner/TestWatermarkBasedSplitAssigner.java
@@ -123,7 +123,7 @@ protected List<IcebergSourceSplit> createSplits(
                         .mapToObj(
                             fileNum ->
                                 RandomGenericData.generate(
-                                    SCHEMA, 2, splitNum * filesPerSplit + fileNum))
+                                    SCHEMA, 2, (long) splitNum * filesPerSplit + fileNum))
                         .collect(Collectors.toList())))
         .collect(Collectors.toList());
   }