Repository: prestodb/presto
Issue: Fix SHOW CREATE TABLE for Raptor

`RaptorMetadata.getTableMetadata()` does not include table properties, so`SHOW CREATE TABLE` does not include them.

We want to make as few database calls as possible. These are the properties we need:
- `ordering`: could be added to `TableColumn`
- `temporal_column`: could be added to `TableColumn`
- `bucket_count`: already in `RaptorTableHandle`
- `bucketed_on`: could be added to `TableColumn`
- `distribution_name`: could be added to `RaptorTableHandle` along with `distributionId` (seems ugly to put it in the handle, but the handle already has the schema/table name just for this metadata call)


Changed files:
presto-raptor/src/test/java/com/facebook/presto/raptor/TestRaptorIntegrationSmokeTest.java
presto-raptor/src/main/java/com/facebook/presto/raptor/RaptorTableHandle.java
presto-raptor/src/test/java/com/facebook/presto/raptor/storage/organization/TestCompactionSetCreator.java
presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/MetadataDao.java
presto-raptor/src/test/java/com/facebook/presto/raptor/storage/organization/TestShardOrganizationManager.java
presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/TableColumn.java
presto-raptor/src/test/java/com/facebook/presto/raptor/metadata/TestRaptorMetadata.java
presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/Table.java
presto-raptor/src/main/java/com/facebook/presto/raptor/RaptorMetadata.java

diff --git a/presto-raptor/src/main/java/com/facebook/presto/raptor/RaptorMetadata.java b/presto-raptor/src/main/java/com/facebook/presto/raptor/RaptorMetadata.java
index dd0d772d46..073c7b61c3 100644
--- a/presto-raptor/src/main/java/com/facebook/presto/raptor/RaptorMetadata.java
+++ b/presto-raptor/src/main/java/com/facebook/presto/raptor/RaptorMetadata.java
@@ -39,6 +39,7 @@ import com.facebook.presto.spi.Constraint;
 import com.facebook.presto.spi.PrestoException;
 import com.facebook.presto.spi.SchemaTableName;
 import com.facebook.presto.spi.SchemaTablePrefix;
+import com.facebook.presto.spi.TableNotFoundException;
 import com.facebook.presto.spi.ViewNotFoundException;
 import com.facebook.presto.spi.connector.ConnectorMetadata;
 import com.facebook.presto.spi.connector.ConnectorPartitioningHandle;
@@ -65,6 +66,8 @@ import java.util.Optional;
 import java.util.OptionalInt;
 import java.util.OptionalLong;
 import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Predicate;
@@ -83,6 +86,8 @@ import static com.facebook.presto.raptor.RaptorSessionProperties.getOneSplitPerB
 import static com.facebook.presto.raptor.RaptorTableProperties.BUCKETED_ON_PROPERTY;
 import static com.facebook.presto.raptor.RaptorTableProperties.BUCKET_COUNT_PROPERTY;
 import static com.facebook.presto.raptor.RaptorTableProperties.DISTRIBUTION_NAME_PROPERTY;
+import static com.facebook.presto.raptor.RaptorTableProperties.ORDERING_PROPERTY;
+import static com.facebook.presto.raptor.RaptorTableProperties.TEMPORAL_COLUMN_PROPERTY;
 import static com.facebook.presto.raptor.RaptorTableProperties.getBucketColumns;
 import static com.facebook.presto.raptor.RaptorTableProperties.getBucketCount;
 import static com.facebook.presto.raptor.RaptorTableProperties.getDistributionName;
@@ -175,6 +180,7 @@ public class RaptorMetadata
                 tableName.getTableName(),
                 table.getTableId(),
                 table.getDistributionId(),
+                table.getDistributionName(),
                 table.getBucketCount(),
                 OptionalLong.empty(),
                 Optional.ofNullable(sampleWeightColumnHandle),
@@ -186,17 +192,41 @@ public class RaptorMetadata
     {
         RaptorTableHandle handle = checkType(tableHandle, RaptorTableHandle.class, "tableHandle");
         SchemaTableName tableName = new SchemaTableName(handle.getSchemaName(), handle.getTableName());
-        List<ColumnMetadata> columns = dao.listTableColumns(handle.getTableId()).stream()
+        List<TableColumn> tableColumns = dao.listTableColumns(handle.getTableId());
+        if (tableColumns.isEmpty()) {
+            throw new TableNotFoundException(tableName);
+        }
+
+        ImmutableMap.Builder<String, Object> properties = ImmutableMap.builder();
+        SortedMap<Integer, String> bucketing = new TreeMap<>();
+        SortedMap<Integer, String> ordering = new TreeMap<>();
+
+        for (TableColumn column : tableColumns) {
+            if (column.isTemporal()) {
+                properties.put(TEMPORAL_COLUMN_PROPERTY, column.getColumnName());
+            }
+            column.getBucketOrdinal().ifPresent(bucketOrdinal -> bucketing.put(bucketOrdinal, column.getColumnName()));
+            column.getSortOrdinal().ifPresent(sortOrdinal -> ordering.put(sortOrdinal, column.getColumnName()));
+        }
+
+        if (!bucketing.isEmpty()) {
+            properties.put(BUCKETED_ON_PROPERTY, ImmutableList.copyOf(bucketing.values()));
+        }
+        if (!ordering.isEmpty()) {
+            properties.put(ORDERING_PROPERTY, ImmutableList.copyOf(ordering.values()));
+        }
+
+        handle.getBucketCount().ifPresent(bucketCount -> properties.put(BUCKET_COUNT_PROPERTY, bucketCount));
+        handle.getDistributionName().ifPresent(distributionName -> properties.put(DISTRIBUTION_NAME_PROPERTY, distributionName));
+
+        List<ColumnMetadata> columns = tableColumns.stream()
                 .map(TableColumn::toColumnMetadata)
                 .filter(isSampleWeightColumn().negate())
                 .collect(toCollection(ArrayList::new));
-        if (columns.isEmpty()) {
-            throw new PrestoException(RAPTOR_ERROR, "Table does not have any columns: " + tableName);
-        }
 
         columns.add(hiddenColumn(SHARD_UUID_COLUMN_NAME, SHARD_UUID_COLUMN_TYPE));
         columns.add(hiddenColumn(BUCKET_NUMBER_COLUMN_NAME, INTEGER));
-        return new ConnectorTableMetadata(tableName, columns);
+        return new ConnectorTableMetadata(tableName, columns, properties.build());
     }
 
     @Override
@@ -694,6 +724,7 @@ public class RaptorMetadata
                 handle.getTableName(),
                 handle.getTableId(),
                 handle.getDistributionId(),
+                handle.getDistributionName(),
                 handle.getBucketCount(),
                 OptionalLong.of(transactionId),
                 handle.getSampleWeightColumnHandle(),
diff --git a/presto-raptor/src/main/java/com/facebook/presto/raptor/RaptorTableHandle.java b/presto-raptor/src/main/java/com/facebook/presto/raptor/RaptorTableHandle.java
index eb07641671..14893812cc 100644
--- a/presto-raptor/src/main/java/com/facebook/presto/raptor/RaptorTableHandle.java
+++ b/presto-raptor/src/main/java/com/facebook/presto/raptor/RaptorTableHandle.java
@@ -35,6 +35,7 @@ public final class RaptorTableHandle
     private final String tableName;
     private final long tableId;
     private final OptionalLong distributionId;
+    private final Optional<String> distributionName;
     private final OptionalInt bucketCount;
     private final OptionalLong transactionId;
     private final Optional<RaptorColumnHandle> sampleWeightColumnHandle;
@@ -47,6 +48,7 @@ public final class RaptorTableHandle
             @JsonProperty("tableName") String tableName,
             @JsonProperty("tableId") long tableId,
             @JsonProperty("distributionId") OptionalLong distributionId,
+            @JsonProperty("distributionName") Optional<String> distributionName,
             @JsonProperty("bucketCount") OptionalInt bucketCount,
             @JsonProperty("transactionId") OptionalLong transactionId,
             @JsonProperty("sampleWeightColumnHandle") Optional<RaptorColumnHandle> sampleWeightColumnHandle,
@@ -60,6 +62,7 @@ public final class RaptorTableHandle
         this.tableId = tableId;
 
         this.sampleWeightColumnHandle = requireNonNull(sampleWeightColumnHandle, "sampleWeightColumnHandle is null");
+        this.distributionName = requireNonNull(distributionName, "distributionName is null");
         this.distributionId = requireNonNull(distributionId, "distributionId is null");
         this.bucketCount = requireNonNull(bucketCount, "bucketCount is null");
         this.transactionId = requireNonNull(transactionId, "transactionId is null");
@@ -97,6 +100,12 @@ public final class RaptorTableHandle
         return distributionId;
     }
 
+    @JsonProperty
+    public Optional<String> getDistributionName()
+    {
+        return distributionName;
+    }
+
     @JsonProperty
     public OptionalInt getBucketCount()
     {
diff --git a/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/MetadataDao.java b/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/MetadataDao.java
index 03129a950e..46896a6584 100644
--- a/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/MetadataDao.java
+++ b/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/MetadataDao.java
@@ -27,7 +27,10 @@ import java.util.Set;
 public interface MetadataDao
 {
     String TABLE_COLUMN_SELECT = "" +
-            "SELECT t.schema_name, t.table_name, c.column_id, c.column_name, c.data_type\\n" +
+            "SELECT t.schema_name, t.table_name,\\n" +
+            "  c.column_id, c.column_name, c.data_type,\\n" +
+            "  c.bucket_ordinal_position, c.sort_ordinal_position,\\n" +
+            "  t.temporal_column_id = c.column_id AS temporal\\n" +
             "FROM tables t\\n" +
             "JOIN columns c ON (t.table_id = c.table_id)\\n";
 
@@ -38,7 +41,7 @@ public interface MetadataDao
     @Mapper(TableMapper.class)
     Table getTableInformation(@Bind("tableId") long tableId);
 
-    @SqlQuery("SELECT t.table_id, t.distribution_id, d.bucket_count, t.temporal_column_id\\n" +
+    @SqlQuery("SELECT t.table_id, t.distribution_id, d.distribution_name, d.bucket_count, t.temporal_column_id\\n" +
             "FROM tables t\\n" +
             "LEFT JOIN distributions d ON (t.distribution_id = d.distribution_id)\\n" +
             "WHERE t.schema_name = :schemaName\\n" +
diff --git a/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/Table.java b/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/Table.java
index 0bb855737f..26077c42af 100644
--- a/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/Table.java
+++ b/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/Table.java
@@ -18,6 +18,7 @@ import org.skife.jdbi.v2.tweak.ResultSetMapper;
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.Optional;
 import java.util.OptionalInt;
 import java.util.OptionalLong;
 
@@ -30,13 +31,15 @@ public final class Table
 {
     private final long tableId;
     private final OptionalLong distributionId;
+    private final Optional<String> distributionName;
     private final OptionalInt bucketCount;
     private final OptionalLong temporalColumnId;
 
-    public Table(long tableId, OptionalLong distributionId, OptionalInt bucketCount, OptionalLong temporalColumnId)
+    public Table(long tableId, OptionalLong distributionId, Optional<String> distributionName, OptionalInt bucketCount, OptionalLong temporalColumnId)
     {
         this.tableId = tableId;
         this.distributionId = requireNonNull(distributionId, "distributionId is null");
+        this.distributionName = requireNonNull(distributionName, "distributionName is null");
         this.bucketCount = requireNonNull(bucketCount, "bucketCount is null");
         this.temporalColumnId = requireNonNull(temporalColumnId, "temporalColumnId is null");
     }
@@ -51,6 +54,11 @@ public final class Table
         return distributionId;
     }
 
+    public Optional<String> getDistributionName()
+    {
+        return distributionName;
+    }
+
     public OptionalInt getBucketCount()
     {
         return bucketCount;
@@ -83,6 +91,7 @@ public final class Table
             return new Table(
                     r.getLong("table_id"),
                     getOptionalLong(r, "distribution_id"),
+                    Optional.ofNullable(r.getString("distribution_name")),
                     getOptionalInt(r, "bucket_count"),
                     getOptionalLong(r, "temporal_column_id"));
         }
diff --git a/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/TableColumn.java b/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/TableColumn.java
index 8da00a4e08..a53f575f37 100644
--- a/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/TableColumn.java
+++ b/presto-raptor/src/main/java/com/facebook/presto/raptor/metadata/TableColumn.java
@@ -24,7 +24,9 @@ import javax.inject.Inject;
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.OptionalInt;
 
+import static com.facebook.presto.raptor.util.DatabaseUtil.getOptionalInt;
 import static com.facebook.presto.spi.type.TypeSignature.parseTypeSignature;
 import static com.google.common.base.MoreObjects.toStringHelper;
 import static com.google.common.base.Preconditions.checkArgument;
@@ -36,13 +38,19 @@ public class TableColumn
     private final String columnName;
     private final Type dataType;
     private final long columnId;
+    private final OptionalInt bucketOrdinal;
+    private final OptionalInt sortOrdinal;
+    private final boolean temporal;
 
-    public TableColumn(SchemaTableName table, String columnName, Type dataType, long columnId)
+    public TableColumn(SchemaTableName table, String columnName, Type dataType, long columnId, OptionalInt bucketOrdinal, OptionalInt sortOrdinal, boolean temporal)
     {
         this.table = requireNonNull(table, "table is null");
         this.columnName = requireNonNull(columnName, "columnName is null");
         this.dataType = requireNonNull(dataType, "dataType is null");
         this.columnId = columnId;
+        this.bucketOrdinal = requireNonNull(bucketOrdinal, "bucketOrdinal is null");
+        this.sortOrdinal = requireNonNull(sortOrdinal, "sortOrdinal is null");
+        this.temporal = temporal;
     }
 
     public SchemaTableName getTable()
@@ -65,6 +73,21 @@ public class TableColumn
         return columnId;
     }
 
+    public OptionalInt getBucketOrdinal()
+    {
+        return bucketOrdinal;
+    }
+
+    public OptionalInt getSortOrdinal()
+    {
+        return sortOrdinal;
+    }
+
+    public boolean isTemporal()
+    {
+        return temporal;
+    }
+
     @Override
     public String toString()
     {
@@ -113,7 +136,10 @@ public class TableColumn
                     table,
                     r.getString("column_name"),
                     type,
-                    r.getLong("column_id"));
+                    r.getLong("column_id"),
+                    getOptionalInt(r, "bucket_ordinal_position"),
+                    getOptionalInt(r, "sort_ordinal_position"),
+                    r.getBoolean("temporal"));
         }
     }
 }
diff --git a/presto-raptor/src/test/java/com/facebook/presto/raptor/TestRaptorIntegrationSmokeTest.java b/presto-raptor/src/test/java/com/facebook/presto/raptor/TestRaptorIntegrationSmokeTest.java
index 301b23ebe1..93c8362c45 100644
--- a/presto-raptor/src/test/java/com/facebook/presto/raptor/TestRaptorIntegrationSmokeTest.java
+++ b/presto-raptor/src/test/java/com/facebook/presto/raptor/TestRaptorIntegrationSmokeTest.java
@@ -346,7 +346,15 @@ public class TestRaptorIntegrationSmokeTest
                         "   c2 double,\\n" +
                         "   \\"c 3\\" varchar,\\n" +
                         "   \\"c'4\\" array(bigint),\\n" +
-                        "   c5 map(bigint, varchar)\\n" +
+                        "   c5 map(bigint, varchar),\\n" +
+                        "   c6 bigint,\\n" +
+                        "   c7 timestamp\\n" +
+                        ")\\n" +
+                        "WITH (\\n" +
+                        "   bucket_count = 32,\\n" +
+                        "   bucketed_on = ARRAY['c1','c6'],\\n" +
+                        "   ordering = ARRAY['c6','c1'],\\n" +
+                        "   temporal_column = 'c7'\\n" +
                         ")",
                 getSession().getCatalog().get(), getSession().getSchema().get(), "test_show_create_table");
         assertUpdate(createTableSql);
diff --git a/presto-raptor/src/test/java/com/facebook/presto/raptor/metadata/TestRaptorMetadata.java b/presto-raptor/src/test/java/com/facebook/presto/raptor/metadata/TestRaptorMetadata.java
index 7ece09444c..4ab99af548 100644
--- a/presto-raptor/src/test/java/com/facebook/presto/raptor/metadata/TestRaptorMetadata.java
+++ b/presto-raptor/src/test/java/com/facebook/presto/raptor/metadata/TestRaptorMetadata.java
@@ -204,8 +204,8 @@ public class TestRaptorMetadata
         // verify sort columns
         List<TableColumn> sortColumns = metadataDao.listSortColumns(tableId);
         assertTableColumnsEqual(sortColumns, ImmutableList.of(
-                new TableColumn(DEFAULT_TEST_ORDERS, "orderdate", DATE, 4),
-                new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2)));
+                new TableColumn(DEFAULT_TEST_ORDERS, "orderdate", DATE, 4, OptionalInt.empty(), OptionalInt.of(0), true),
+                new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2, OptionalInt.empty(), OptionalInt.of(1), false)));
 
         // verify temporal column
         assertEquals(metadataDao.getTemporalColumnId(tableId), Long.valueOf(4));
@@ -231,8 +231,8 @@ public class TestRaptorMetadata
         MetadataDao metadataDao = dbi.onDemand(MetadataDao.class);
 
         assertTableColumnsEqual(metadataDao.listBucketColumns(tableId), ImmutableList.of(
-                new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2),
-                new TableColumn(DEFAULT_TEST_ORDERS, "orderkey", BIGINT, 1)));
+                new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2, OptionalInt.of(0), OptionalInt.empty(), false),
+                new TableColumn(DEFAULT_TEST_ORDERS, "orderkey", BIGINT, 1, OptionalInt.of(1), OptionalInt.empty(), false)));
 
         assertEquals(raptorTableHandle.getBucketCount(), OptionalInt.of(16));
 
@@ -274,8 +274,8 @@ public class TestRaptorMetadata
         MetadataDao metadataDao = dbi.onDemand(MetadataDao.class);
 
         assertTableColumnsEqual(metadataDao.listBucketColumns(tableId), ImmutableList.of(
-                new TableColumn(DEFAULT_TEST_ORDERS, "orderkey", BIGINT, 1),
-                new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2)));
+                new TableColumn(DEFAULT_TEST_ORDERS, "orderkey", BIGINT, 1, OptionalInt.of(0), OptionalInt.empty(), false),
+                new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2, OptionalInt.of(1), OptionalInt.empty(), false)));
 
         assertEquals(raptorTableHandle.getBucketCount(), OptionalInt.of(32));
 
@@ -306,7 +306,7 @@ public class TestRaptorMetadata
         assertEquals(raptorTableHandle.getTableId(), 1);
 
         assertTableColumnsEqual(metadataDao.listBucketColumns(tableId), ImmutableList.of(
-                new TableColumn(DEFAULT_TEST_ORDERS, "orderkey", BIGINT, 1)));
+                new TableColumn(DEFAULT_TEST_ORDERS, "orderkey", BIGINT, 1, OptionalInt.of(0), OptionalInt.empty(), false)));
 
         assertEquals(raptorTableHandle.getBucketCount(), OptionalInt.of(16));
 
@@ -329,7 +329,7 @@ public class TestRaptorMetadata
         assertEquals(tableId, 2);
 
         assertTableColumnsEqual(metadataDao.listBucketColumns(tableId), ImmutableList.of(
-                new TableColumn(DEFAULT_TEST_LINEITEMS, "orderkey", BIGINT, 1)));
+                new TableColumn(DEFAULT_TEST_LINEITEMS, "orderkey", BIGINT, 1, OptionalInt.of(0), OptionalInt.empty(), false)));
 
         assertEquals(raptorTableHandle.getBucketCount(), OptionalInt.of(16));
 
@@ -386,8 +386,8 @@ public class TestRaptorMetadata
         // verify sort columns
         List<TableColumn> sortColumns = metadataDao.listSortColumns(tableId);
         assertTableColumnsEqual(sortColumns, ImmutableList.of(
-                new TableColumn(DEFAULT_TEST_ORDERS, "orderdate", DATE, 4),
-                new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2)));
+                new TableColumn(DEFAULT_TEST_ORDERS, "orderdate", DATE, 4, OptionalInt.empty(), OptionalInt.of(0), false),
+                new TableColumn(DEFAULT_TEST_ORDERS, "custkey", BIGINT, 2, OptionalInt.empty(), OptionalInt.of(1), false)));
 
         // verify temporal column is not set
         assertEquals(metadataDao.getTemporalColumnId(tableId), null);
@@ -723,6 +723,9 @@ public class TestRaptorMetadata
         assertEquals(actual.getColumnId(), expected.getColumnId());
         assertEquals(actual.getColumnName(), expected.getColumnName());
         assertEquals(actual.getDataType(), expected.getDataType());
+        assertEquals(actual.getBucketOrdinal(), expected.getBucketOrdinal());
+        assertEquals(actual.getSortOrdinal(), expected.getSortOrdinal());
+        assertEquals(actual.isTemporal(), expected.isTemporal());
     }
 
     private static void assertTableColumnsEqual(List<TableColumn> actual, List<TableColumn> expected)
diff --git a/presto-raptor/src/test/java/com/facebook/presto/raptor/storage/organization/TestCompactionSetCreator.java b/presto-raptor/src/test/java/com/facebook/presto/raptor/storage/organization/TestCompactionSetCreator.java
index 1c180a4f3f..b4e55569db 100644
--- a/presto-raptor/src/test/java/com/facebook/presto/raptor/storage/organization/TestCompactionSetCreator.java
+++ b/presto-raptor/src/test/java/com/facebook/presto/raptor/storage/organization/TestCompactionSetCreator.java
@@ -39,10 +39,10 @@ public class TestCompactionSetCreator
 {
     private static final long MAX_SHARD_ROWS = 100;
     private static final DataSize MAX_SHARD_SIZE = new DataSize(100, DataSize.Unit.BYTE);
-    private static final Table tableInfo = new Table(1L, OptionalLong.empty(), OptionalInt.empty(), OptionalLong.empty());
-    private static final Table temporalTableInfo = new Table(1L, OptionalLong.empty(), OptionalInt.empty(), OptionalLong.of(1));
-    private static final Table bucketedTableInfo = new Table(1L, OptionalLong.empty(), OptionalInt.of(3), OptionalLong.empty());
-    private static final Table bucketedTemporalTableInfo = new Table(1L, OptionalLong.empty(), OptionalInt.of(3), OptionalLong.of(1));
+    private static final Table tableInfo = new Table(1L, OptionalLong.empty(), Optional.empty(), OptionalInt.empty(), OptionalLong.empty());
+    private static final Table temporalTableInfo = new Table(1L, OptionalLong.empty(), Optional.empty(), OptionalInt.empty(), OptionalLong.of(1));
+    private static final Table bucketedTableInfo = new Table(1L, OptionalLong.empty(), Optional.empty(), OptionalInt.of(3), OptionalLong.empty());
+    private static final Table bucketedTemporalTableInfo = new Table(1L, OptionalLong.empty(), Optional.empty(), OptionalInt.of(3), OptionalLong.of(1));
 
     private final CompactionSetCreator compactionSetCreator = new CompactionSetCreator(MAX_SHARD_SIZE, MAX_SHARD_ROWS);
 
diff --git a/presto-raptor/src/test/java/com/facebook/presto/raptor/storage/organization/TestShardOrganizationManager.java b/presto-raptor/src/test/java/com/facebook/presto/raptor/storage/organization/TestShardOrganizationManager.java
index 36dfdb031b..c3be167003 100644
--- a/presto-raptor/src/test/java/com/facebook/presto/raptor/storage/organization/TestShardOrganizationManager.java
+++ b/presto-raptor/src/test/java/com/facebook/presto/raptor/storage/organization/TestShardOrganizationManager.java
@@ -56,8 +56,8 @@ public class TestShardOrganizationManager
     private MetadataDao metadataDao;
     private ShardOrganizerDao organizerDao;
 
-    private static final Table tableInfo = new Table(1L, OptionalLong.empty(), OptionalInt.empty(), OptionalLong.empty());
-    private static final Table temporalTableInfo = new Table(1L, OptionalLong.empty(), OptionalInt.empty(), OptionalLong.of(1));
+    private static final Table tableInfo = new Table(1L, OptionalLong.empty(), Optional.empty(), OptionalInt.empty(), OptionalLong.empty());
+    private static final Table temporalTableInfo = new Table(1L, OptionalLong.empty(), Optional.empty(), OptionalInt.empty(), OptionalLong.of(1));
 
     private static final List<Type> types = ImmutableList.of(BIGINT, VARCHAR, DATE, TIMESTAMP);