Skip to content

Conversation

@ebyhr
Copy link
Contributor

@ebyhr ebyhr commented Oct 17, 2025

Iceberg throws exceptions if JSON contains default values on timestamp nanos:

Caused by: java.lang.ArithmeticException: long overflow
	at java.base/java.lang.Math.multiplyExact(Math.java:1035)
	at org.apache.iceberg.util.DateTimeUtil.microsToNanos(DateTimeUtil.java:101)
	at org.apache.iceberg.expressions.Literals$TimestampLiteral.to(Literals.java:447)
	at org.apache.iceberg.expressions.Literals$LongLiteral.to(Literals.java:306)
	at org.apache.iceberg.types.Types$NestedField.castDefault(Types.java:890)
	at org.apache.iceberg.types.Types$NestedField.<init>(Types.java:882)
	at org.apache.iceberg.types.Types$NestedField$Builder.build(Types.java:850)
	at org.apache.iceberg.SchemaParser.structFromJson(SchemaParser.java:242)
	at org.apache.iceberg.SchemaParser.typeFromJson(SchemaParser.java:186)
	at org.apache.iceberg.SchemaParser.fromJson(SchemaParser.java:277)
	at org.apache.iceberg.util.JsonUtil.parse(JsonUtil.java:104)
	at org.apache.iceberg.SchemaParser.lambda$fromJson$1(SchemaParser.java:296)
	at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2704)
	at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1932)
	at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2702)
	at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2684)
	at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:112)
	at com.github.benmanes.caffeine.cache.LocalManualCache.get(LocalManualCache.java:63)
	at org.apache.iceberg.SchemaParser.fromJson(SchemaParser.java:296)

@github-actions github-actions bot added the core label Oct 17, 2025
@nastra nastra added this to the Iceberg 1.10.1 milestone Oct 17, 2025
if (json.has(defaultField)) {
return Expressions.lit(SingleValueParser.fromJson(type, json.get(defaultField)));
Object value = SingleValueParser.fromJson(type, json.get(defaultField));
if (type instanceof Types.TimestampNanoType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add some comments here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants