Skip to content

Commit

Permalink
Disable timestamp with time zone type on create & alter table for ice…
Browse files Browse the repository at this point in the history
…berg tables.
  • Loading branch information
gupteaj authored and tdcmeehan committed Oct 26, 2023
1 parent a00fdc6 commit 9bce03a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public static ColumnIdentity createColumnIdentity(Types.NestedField column)
String name = column.name();
org.apache.iceberg.types.Type fieldType = column.type();

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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,16 @@ public void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle
if (!column.isNullable()) {
throw new PrestoException(NOT_SUPPORTED, "This connector does not support add column with non null");
}

org.apache.iceberg.types.Type columnType = toIcebergType(column.getType());

if (columnType.equals(Types.TimestampType.withZone())) {
throw new PrestoException(NOT_SUPPORTED, format("Iceberg column type %s is not supported", columnType));
}

IcebergTableHandle handle = (IcebergTableHandle) tableHandle;
Table icebergTable = getIcebergTable(session, handle.getSchemaTableName());
icebergTable.updateSchema().addColumn(column.getName(), toIcebergType(column.getType()), column.getComment()).commit();
icebergTable.updateSchema().addColumn(column.getName(), columnType, column.getComment()).commit();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ public void testTimestamp()
dropTable(getSession(), "test_timestamp");
}

@Test
public void testTimestampWithTimeZone()
{
assertQueryFails("CREATE TABLE test_timestamp_with_timezone (x timestamp with time zone)", "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");
}

@Test
@Override
public void testDescribeTable()
Expand Down

0 comments on commit 9bce03a

Please sign in to comment.