Skip to content

Commit

Permalink
Decouple Sql types from JSON serialization
Browse files Browse the repository at this point in the history
The new JSON serialization is not using ObjectMapper to serialize these values anymore.
We want to decouple SPI types from JSON representation to be able to introduce
alternative encoding formats.
  • Loading branch information
wendigo committed Nov 22, 2024
1 parent 210a4f9 commit 2b75fea
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 18 deletions.
48 changes: 48 additions & 0 deletions core/trino-spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,54 @@
<annotation>@com.fasterxml.jackson.annotation.JsonValue</annotation>
<justification>On-the-wire representation shouldn't rely on the Jackson format</justification>
</item>
<item>
<ignore>true</ignore>
<code>java.annotation.removed</code>
<old>method java.lang.String io.trino.spi.type.SqlDate::toString()</old>
<new>method java.lang.String io.trino.spi.type.SqlDate::toString()</new>
<annotation>@com.fasterxml.jackson.annotation.JsonValue</annotation>
<justification>On-the-wire representation shouldn't rely on the Jackson format</justification>
</item>
<item>
<ignore>true</ignore>
<code>java.annotation.removed</code>
<old>method java.lang.String io.trino.spi.type.SqlDecimal::toString()</old>
<new>method java.lang.String io.trino.spi.type.SqlDecimal::toString()</new>
<annotation>@com.fasterxml.jackson.annotation.JsonValue</annotation>
<justification>On-the-wire representation shouldn't rely on the Jackson format</justification>
</item>
<item>
<ignore>true</ignore>
<code>java.annotation.removed</code>
<old>method java.lang.String io.trino.spi.type.SqlTime::toString()</old>
<new>method java.lang.String io.trino.spi.type.SqlTime::toString()</new>
<annotation>@com.fasterxml.jackson.annotation.JsonValue</annotation>
<justification>On-the-wire representation shouldn't rely on the Jackson format</justification>
</item>
<item>
<ignore>true</ignore>
<code>java.annotation.removed</code>
<old>method java.lang.String io.trino.spi.type.SqlTimeWithTimeZone::toString()</old>
<new>method java.lang.String io.trino.spi.type.SqlTimeWithTimeZone::toString()</new>
<annotation>@com.fasterxml.jackson.annotation.JsonValue</annotation>
<justification>On-the-wire representation shouldn't rely on the Jackson format</justification>
</item>
<item>
<ignore>true</ignore>
<code>java.annotation.removed</code>
<old>method java.lang.String io.trino.spi.type.SqlTimestamp::toString()</old>
<new>method java.lang.String io.trino.spi.type.SqlTimestamp::toString()</new>
<annotation>@com.fasterxml.jackson.annotation.JsonValue</annotation>
<justification>On-the-wire representation shouldn't rely on the Jackson format</justification>
</item>
<item>
<ignore>true</ignore>
<code>java.annotation.removed</code>
<old>method java.lang.String io.trino.spi.type.SqlTimestampWithTimeZone::toString()</old>
<new>method java.lang.String io.trino.spi.type.SqlTimestampWithTimeZone::toString()</new>
<annotation>@com.fasterxml.jackson.annotation.JsonValue</annotation>
<justification>On-the-wire representation shouldn't rely on the Jackson format</justification>
</item>
</differences>
</revapi.differences>
</analysisConfiguration>
Expand Down
3 changes: 0 additions & 3 deletions core/trino-spi/src/main/java/io/trino/spi/type/SqlDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package io.trino.spi.type;

import com.fasterxml.jackson.annotation.JsonValue;

import java.time.LocalDate;

public final class SqlDate
Expand Down Expand Up @@ -51,7 +49,6 @@ public boolean equals(Object obj)
return days == other.days;
}

@JsonValue
@Override
public String toString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package io.trino.spi.type;

import com.fasterxml.jackson.annotation.JsonValue;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
Expand Down Expand Up @@ -81,7 +79,6 @@ public int hashCode()
return Objects.hash(unscaledValue, precision, scale);
}

@JsonValue
@Override
public String toString()
{
Expand Down
3 changes: 0 additions & 3 deletions core/trino-spi/src/main/java/io/trino/spi/type/SqlTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package io.trino.spi.type;

import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Objects;

import static io.trino.spi.type.TimeType.MAX_PRECISION;
Expand Down Expand Up @@ -85,7 +83,6 @@ public int hashCode()
return Objects.hash(precision, picos);
}

@JsonValue
@Override
public String toString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package io.trino.spi.type;

import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Objects;

import static io.trino.spi.type.TimeType.MAX_PRECISION;
Expand Down Expand Up @@ -99,7 +97,6 @@ public int hashCode()
return Objects.hash(precision, picos, offsetMinutes);
}

@JsonValue
@Override
public String toString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package io.trino.spi.type;

import com.fasterxml.jackson.annotation.JsonValue;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Objects;
Expand Down Expand Up @@ -149,7 +147,6 @@ public int hashCode()
return Objects.hash(epochMicros, picosOfMicros, precision);
}

@JsonValue
@Override
public String toString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package io.trino.spi.type;

import com.fasterxml.jackson.annotation.JsonValue;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
Expand Down Expand Up @@ -132,7 +130,6 @@ public SqlTimestampWithTimeZone roundTo(int precision)
return newInstanceWithRounding(precision, epochMillis, picosOfMilli, timeZoneKey);
}

@JsonValue
@Override
public String toString()
{
Expand Down

0 comments on commit 2b75fea

Please sign in to comment.