File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
main/java/org/apache/iceberg
test/java/org/apache/iceberg Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,14 @@ private static Type typeFromJson(JsonNode json) {
197197
198198 private static Literal <?> defaultFromJson (String defaultField , Type type , JsonNode json ) {
199199 if (json .has (defaultField )) {
200- return Expressions .lit (SingleValueParser .fromJson (type , json .get (defaultField )));
200+ Object value = SingleValueParser .fromJson (type , json .get (defaultField ));
201+ if (type instanceof Types .TimestampNanoType ) {
202+ // Call Expressions.nanos instead of Expressions.lit to prevent overflow
203+ // https://github.com/apache/iceberg/issues/13160
204+ return Expressions .nanos ((long ) value );
205+ }
206+
207+ return Expressions .lit (value );
201208 }
202209
203210 return null ;
Original file line number Diff line number Diff line change 2828import java .util .UUID ;
2929import java .util .stream .Stream ;
3030import org .apache .iceberg .data .DataTestBase ;
31+ import org .apache .iceberg .expressions .Expressions ;
3132import org .apache .iceberg .expressions .Literal ;
3233import org .apache .iceberg .relocated .com .google .common .collect .Lists ;
3334import org .apache .iceberg .relocated .com .google .common .collect .Sets ;
@@ -116,9 +117,16 @@ private static Stream<Arguments> primitiveTypesAndDefaults() {
116117 Arguments .of (
117118 Types .TimestampType .withZone (),
118119 Literal .of (DateTimeUtil .isoTimestamptzToMicros ("2024-12-17T23:59:59.999999+00:00" ))),
120+ Arguments .of (
121+ Types .TimestampNanoType .withZone (),
122+ Expressions .nanos (
123+ DateTimeUtil .isoTimestamptzToNanos ("2024-12-17T23:59:59.123456789+00:00" ))),
119124 Arguments .of (
120125 Types .TimestampType .withoutZone (),
121126 Literal .of (DateTimeUtil .isoTimestampToMicros ("2024-12-17T23:59:59.999999" ))),
127+ Arguments .of (
128+ Types .TimestampNanoType .withoutZone (),
129+ Expressions .nanos (DateTimeUtil .isoTimestampToNanos ("2024-12-17T23:59:59.123456789" ))),
122130 Arguments .of (Types .StringType .get (), Literal .of ("iceberg" )),
123131 Arguments .of (Types .UUIDType .get (), Literal .of (UUID .randomUUID ())),
124132 Arguments .of (
You can’t perform that action at this time.
0 commit comments