diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/ColumnIdentity.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/ColumnIdentity.java index 035cb560eb740..ee1f2998488a3 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/ColumnIdentity.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/ColumnIdentity.java @@ -126,10 +126,6 @@ public static ColumnIdentity createColumnIdentity(Types.NestedField column) public static ColumnIdentity createColumnIdentity(String name, int id, org.apache.iceberg.types.Type fieldType) { - if (fieldType.equals(Types.TimestampType.withZone())) { - throw new UnsupportedOperationException(format("Iceberg column type %s is not supported", fieldType)); - } - if (!fieldType.isNestedType()) { return new ColumnIdentity(id, name, PRIMITIVE, ImmutableList.of()); } diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java index 03537f8a3c518..75b6cdebe6c70 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java @@ -138,6 +138,7 @@ import static com.facebook.presto.iceberg.IcebergUtil.tryGetProperties; import static com.facebook.presto.iceberg.IcebergUtil.tryGetSchema; import static com.facebook.presto.iceberg.IcebergUtil.validateTableMode; +import static com.facebook.presto.iceberg.IcebergUtil.verifyTypeSupported; import static com.facebook.presto.iceberg.PartitionFields.getPartitionColumnName; import static com.facebook.presto.iceberg.PartitionFields.getTransformTerm; import static com.facebook.presto.iceberg.PartitionFields.toPartitionFields; @@ -674,6 +675,8 @@ public ConnectorInsertTableHandle beginInsert(ConnectorSession session, Connecto Table icebergTable = getIcebergTable(session, table.getSchemaTableName()); validateTableMode(session, icebergTable); + verifyTypeSupported(icebergTable.schema()); + return beginIcebergTableInsert(table, icebergTable); } diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java index d54193ef47718..a429064195546 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java @@ -122,6 +122,7 @@ import static com.facebook.presto.iceberg.IcebergUtil.populateTableProperties; import static com.facebook.presto.iceberg.IcebergUtil.toHiveColumns; import static com.facebook.presto.iceberg.IcebergUtil.tryGetProperties; +import static com.facebook.presto.iceberg.IcebergUtil.verifyTypeSupported; import static com.facebook.presto.iceberg.PartitionFields.parsePartitionFields; import static com.facebook.presto.iceberg.util.StatisticsUtil.calculateAndSetTableSize; import static com.facebook.presto.iceberg.util.StatisticsUtil.mergeHiveStatistics; @@ -268,6 +269,8 @@ public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, Con Schema schema = toIcebergSchema(tableMetadata.getColumns()); + verifyTypeSupported(schema); + PartitionSpec partitionSpec = parsePartitionFields(schema, getPartitioning(tableMetadata.getProperties())); MetastoreContext metastoreContext = getMetastoreContext(session); diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergNativeMetadata.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergNativeMetadata.java index 5f418beb93beb..3f2f1d1ecaded 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergNativeMetadata.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergNativeMetadata.java @@ -50,6 +50,7 @@ import static com.facebook.presto.iceberg.IcebergUtil.getColumns; import static com.facebook.presto.iceberg.IcebergUtil.getNativeIcebergTable; import static com.facebook.presto.iceberg.IcebergUtil.populateTableProperties; +import static com.facebook.presto.iceberg.IcebergUtil.verifyTypeSupported; import static com.facebook.presto.iceberg.PartitionFields.parsePartitionFields; import static com.facebook.presto.iceberg.util.IcebergPrestoModelConverters.toIcebergNamespace; import static com.facebook.presto.iceberg.util.IcebergPrestoModelConverters.toIcebergTableIdentifier; @@ -164,6 +165,8 @@ public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, Con Schema schema = toIcebergSchema(tableMetadata.getColumns()); + verifyTypeSupported(schema); + PartitionSpec partitionSpec = parsePartitionFields(schema, getPartitioning(tableMetadata.getProperties())); FileFormat fileFormat = getFileFormat(tableMetadata.getProperties()); diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java index 2a03ba92882b5..b7f34acec4b54 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java @@ -417,6 +417,13 @@ public static void validateTableMode(ConnectorSession session, org.apache.iceber } } + public static void verifyTypeSupported(Schema schema) + { + if (schema.columns().stream().anyMatch(column -> Types.TimestampType.withZone().equals(column.type()))) { + throw new PrestoException(NOT_SUPPORTED, format("Iceberg column type %s is not supported", Types.TimestampType.withZone())); + } + } + public static Map createIcebergViewProperties(ConnectorSession session, String prestoVersion) { return ImmutableMap.builder() diff --git a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergDistributedSmokeTestBase.java b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergDistributedSmokeTestBase.java index c586579937732..3249a6e1cb16f 100644 --- a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergDistributedSmokeTestBase.java +++ b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergDistributedSmokeTestBase.java @@ -89,6 +89,7 @@ public void testTimestamp() public void testTimestampWithTimeZone() { assertQueryFails("CREATE TABLE test_timestamp_with_timezone (x timestamp with time zone)", "Iceberg column type timestamptz is not supported"); + assertQueryFails("CREATE TABLE test_timestamp_with_timezone (x) AS SELECT TIMESTAMP '1969-12-01 00:00:00.000000 UTC'", "Iceberg column type timestamptz is not supported"); assertUpdate("CREATE TABLE test_timestamp_with_timezone (x timestamp)"); assertQueryFails("ALTER TABLE test_timestamp_with_timezone ADD COLUMN y timestamp with time zone", "Iceberg column type timestamptz is not supported"); dropTable(getSession(), "test_timestamp_with_timezone");