From 9a9dede7e4ecd3f1b0d282cb0b6d9f63740af25a Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Thu, 3 Jan 2019 01:20:41 +0100 Subject: [PATCH 1/2] Remove unsupported types on write path in JDBC connectors These types are not supported in `com.facebook.presto.plugin.jdbc.JdbcPageSink#appendColumn`, so cannot be written. Attempt to support these types must be well test-covered on per-database basis, so they should not be supported in a generic way anyway. --- .../com/facebook/presto/plugin/jdbc/BaseJdbcClient.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/BaseJdbcClient.java b/presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/BaseJdbcClient.java index 7096fa0adc3f..5ea5567b94fb 100644 --- a/presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/BaseJdbcClient.java +++ b/presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/BaseJdbcClient.java @@ -58,10 +58,6 @@ import static com.facebook.presto.spi.type.IntegerType.INTEGER; import static com.facebook.presto.spi.type.RealType.REAL; import static com.facebook.presto.spi.type.SmallintType.SMALLINT; -import static com.facebook.presto.spi.type.TimeType.TIME; -import static com.facebook.presto.spi.type.TimeWithTimeZoneType.TIME_WITH_TIME_ZONE; -import static com.facebook.presto.spi.type.TimestampType.TIMESTAMP; -import static com.facebook.presto.spi.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE; import static com.facebook.presto.spi.type.TinyintType.TINYINT; import static com.facebook.presto.spi.type.VarbinaryType.VARBINARY; import static com.facebook.presto.spi.type.Varchars.isVarcharType; @@ -88,10 +84,6 @@ public class BaseJdbcClient .put(REAL, "real") .put(VARBINARY, "varbinary") .put(DATE, "date") - .put(TIME, "time") - .put(TIME_WITH_TIME_ZONE, "time with timezone") - .put(TIMESTAMP, "timestamp") - .put(TIMESTAMP_WITH_TIME_ZONE, "timestamp with timezone") .build(); protected final String connectorId; From cd54d570385cea566bd2acb64ed54833d0861201 Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Thu, 3 Jan 2019 02:17:09 +0100 Subject: [PATCH 2/2] Remove unsupported types on read path in JDBC connectors No JDBC-based connector supports TIMESTAMP WITH TIME ZONE or TIME WITH TIME ZONE, so no need to support predicate push down for these types. --- .../com/facebook/presto/plugin/jdbc/QueryBuilder.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/QueryBuilder.java b/presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/QueryBuilder.java index b035fd46ab1b..6bc020313d80 100644 --- a/presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/QueryBuilder.java +++ b/presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/QueryBuilder.java @@ -26,9 +26,7 @@ import com.facebook.presto.spi.type.RealType; import com.facebook.presto.spi.type.SmallintType; import com.facebook.presto.spi.type.TimeType; -import com.facebook.presto.spi.type.TimeWithTimeZoneType; import com.facebook.presto.spi.type.TimestampType; -import com.facebook.presto.spi.type.TimestampWithTimeZoneType; import com.facebook.presto.spi.type.TinyintType; import com.facebook.presto.spi.type.Type; import com.facebook.presto.spi.type.VarcharType; @@ -46,7 +44,6 @@ import java.util.ArrayList; import java.util.List; -import static com.facebook.presto.spi.type.DateTimeEncoding.unpackMillisUtc; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Strings.isNullOrEmpty; @@ -158,15 +155,9 @@ else if (typeAndValue.getType().equals(DateType.DATE)) { else if (typeAndValue.getType().equals(TimeType.TIME)) { statement.setTime(i + 1, new Time((long) typeAndValue.getValue())); } - else if (typeAndValue.getType().equals(TimeWithTimeZoneType.TIME_WITH_TIME_ZONE)) { - statement.setTime(i + 1, new Time(unpackMillisUtc((long) typeAndValue.getValue()))); - } else if (typeAndValue.getType().equals(TimestampType.TIMESTAMP)) { statement.setTimestamp(i + 1, new Timestamp((long) typeAndValue.getValue())); } - else if (typeAndValue.getType().equals(TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE)) { - statement.setTimestamp(i + 1, new Timestamp(unpackMillisUtc((long) typeAndValue.getValue()))); - } else if (typeAndValue.getType() instanceof VarcharType) { statement.setString(i + 1, ((Slice) typeAndValue.getValue()).toStringUtf8()); } @@ -193,9 +184,7 @@ private static boolean isAcceptedType(Type type) validType.equals(BooleanType.BOOLEAN) || validType.equals(DateType.DATE) || validType.equals(TimeType.TIME) || - validType.equals(TimeWithTimeZoneType.TIME_WITH_TIME_ZONE) || validType.equals(TimestampType.TIMESTAMP) || - validType.equals(TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE) || validType instanceof VarcharType || validType instanceof CharType; }