Skip to content

Commit e3bc083

Browse files
authored
fix: Remove StorageType from ClpTableHandle since it will now be a cluster-level property. (#18)
1 parent 2f33875 commit e3bc083

File tree

4 files changed

+9
-46
lines changed

4 files changed

+9
-46
lines changed

presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpTableHandle.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,12 @@ public class ClpTableHandle
2727
{
2828
private final SchemaTableName schemaTableName;
2929
private final String tablePath;
30-
private final StorageType storageType;
3130

3231
@JsonCreator
33-
public ClpTableHandle(
34-
@JsonProperty("schemaTableName") SchemaTableName schemaTableName,
35-
@JsonProperty("tablePath") String tablePath,
36-
@JsonProperty("storageType") StorageType storageType)
32+
public ClpTableHandle(@JsonProperty("schemaTableName") SchemaTableName schemaTableName, @JsonProperty("tablePath") String tablePath)
3733
{
3834
this.schemaTableName = schemaTableName;
3935
this.tablePath = tablePath;
40-
this.storageType = storageType;
4136
}
4237

4338
@JsonProperty
@@ -52,16 +47,10 @@ public String getTablePath()
5247
return tablePath;
5348
}
5449

55-
@JsonProperty
56-
public StorageType getStorageType()
57-
{
58-
return storageType;
59-
}
60-
6150
@Override
6251
public int hashCode()
6352
{
64-
return Objects.hash(schemaTableName, tablePath, storageType);
53+
return Objects.hash(schemaTableName, tablePath);
6554
}
6655

6756
@Override
@@ -74,9 +63,7 @@ public boolean equals(Object obj)
7463
return false;
7564
}
7665
ClpTableHandle other = (ClpTableHandle) obj;
77-
return this.schemaTableName.equals(other.schemaTableName) &&
78-
this.tablePath.equals(other.tablePath) &&
79-
this.storageType == other.storageType;
66+
return this.schemaTableName.equals(other.schemaTableName) && this.tablePath.equals(other.tablePath);
8067
}
8168

8269
@Override
@@ -85,13 +72,6 @@ public String toString()
8572
return toStringHelper(this)
8673
.add("schemaTableName", schemaTableName)
8774
.add("tablePath", tablePath)
88-
.add("storageType", storageType)
8975
.toString();
9076
}
91-
92-
public enum StorageType
93-
{
94-
FS, // Local File System
95-
S3
96-
}
9777
}

presto-clp/src/main/java/com/facebook/presto/plugin/clp/metadata/ClpMySqlMetadataProvider.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public class ClpMySqlMetadataProvider
3939
public static final String COLUMN_METADATA_TABLE_COLUMN_NAME = "name";
4040
public static final String COLUMN_METADATA_TABLE_COLUMN_TYPE = "type";
4141
public static final String DATASETS_TABLE_COLUMN_NAME = "name";
42-
public static final String DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_TYPE = "archive_storage_type";
4342
public static final String DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_DIRECTORY = "archive_storage_directory";
4443

4544
// Table suffixes
@@ -49,9 +48,8 @@ public class ClpMySqlMetadataProvider
4948
// SQL templates
5049
private static final String SQL_SELECT_COLUMN_METADATA_TEMPLATE = "SELECT * FROM `%s%s" + COLUMN_METADATA_TABLE_SUFFIX + "`";
5150
private static final String SQL_SELECT_DATASETS_TEMPLATE = format(
52-
"SELECT `%s`, `%s`, `%s` FROM `%%s%s`",
51+
"SELECT `%s`, `%s` FROM `%%s%s`",
5352
DATASETS_TABLE_COLUMN_NAME,
54-
DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_TYPE,
5553
DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_DIRECTORY,
5654
DATASETS_TABLE_SUFFIX);
5755

@@ -102,14 +100,9 @@ public List<ClpTableHandle> listTableHandles(String schemaName)
102100
ResultSet resultSet = statement.executeQuery(query)) {
103101
while (resultSet.next()) {
104102
String tableName = resultSet.getString(DATASETS_TABLE_COLUMN_NAME);
105-
String archiveStorageType = resultSet.getString(DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_TYPE);
106103
String archiveStorageDirectory = resultSet.getString(DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_DIRECTORY);
107104
if (isValidIdentifier(tableName) && archiveStorageDirectory != null && !archiveStorageDirectory.isEmpty()) {
108-
tableHandles.add(
109-
new ClpTableHandle(
110-
new SchemaTableName(schemaName, tableName),
111-
archiveStorageDirectory,
112-
ClpTableHandle.StorageType.valueOf(archiveStorageType.toUpperCase())));
105+
tableHandles.add(new ClpTableHandle(new SchemaTableName(schemaName, tableName), archiveStorageDirectory));
113106
}
114107
else {
115108
log.warn("Ignoring invalid table name found in metadata: %s", tableName);

presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpMetadataDbSetUp.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import static com.facebook.presto.plugin.clp.metadata.ClpMySqlMetadataProvider.COLUMN_METADATA_TABLE_COLUMN_NAME;
3535
import static com.facebook.presto.plugin.clp.metadata.ClpMySqlMetadataProvider.COLUMN_METADATA_TABLE_COLUMN_TYPE;
3636
import static com.facebook.presto.plugin.clp.metadata.ClpMySqlMetadataProvider.DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_DIRECTORY;
37-
import static com.facebook.presto.plugin.clp.metadata.ClpMySqlMetadataProvider.DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_TYPE;
3837
import static com.facebook.presto.plugin.clp.metadata.ClpMySqlMetadataProvider.DATASETS_TABLE_COLUMN_NAME;
3938
import static com.facebook.presto.plugin.clp.metadata.ClpMySqlMetadataProvider.DATASETS_TABLE_SUFFIX;
4039
import static com.facebook.presto.plugin.clp.split.ClpMySqlSplitProvider.ARCHIVES_TABLE_COLUMN_ID;
@@ -184,13 +183,9 @@ private static void createDatasetsTable(Statement stmt)
184183
throws SQLException
185184
{
186185
final String createDatasetsTableSql = format(
187-
"CREATE TABLE IF NOT EXISTS %s (" +
188-
" %s VARCHAR(255) PRIMARY KEY," +
189-
" %s VARCHAR(64) NOT NULL," +
190-
" %s VARCHAR(4096) NOT NULL)",
186+
"CREATE TABLE IF NOT EXISTS %s (%s VARCHAR(255) PRIMARY KEY, %s VARCHAR(4096) NOT NULL)",
191187
DATASETS_TABLE_NAME,
192188
DATASETS_TABLE_COLUMN_NAME,
193-
DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_TYPE,
194189
DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_DIRECTORY);
195190
stmt.execute(createDatasetsTableSql);
196191
}
@@ -199,15 +194,13 @@ private static void updateDatasetsTable(Connection conn, String tableName)
199194
throws SQLException
200195
{
201196
final String insertDatasetsTableSql = format(
202-
"INSERT INTO %s (%s, %s, %s) VALUES (?, ?, ?)",
197+
"INSERT INTO %s (%s, %s) VALUES (?, ?)",
203198
DATASETS_TABLE_NAME,
204199
DATASETS_TABLE_COLUMN_NAME,
205-
DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_TYPE,
206200
DATASETS_TABLE_COLUMN_ARCHIVE_STORAGE_DIRECTORY);
207201
try (PreparedStatement pstmt = conn.prepareStatement(insertDatasetsTableSql)) {
208202
pstmt.setString(1, tableName);
209-
pstmt.setString(2, "fs");
210-
pstmt.setString(3, ARCHIVE_STORAGE_DIRECTORY_BASE + tableName);
203+
pstmt.setString(2, ARCHIVE_STORAGE_DIRECTORY_BASE + tableName);
211204
pstmt.executeUpdate();
212205
}
213206
}

presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpSplit.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import static com.facebook.presto.plugin.clp.ClpMetadataDbSetUp.DbHandle;
3232
import static com.facebook.presto.plugin.clp.ClpMetadataDbSetUp.getDbHandle;
3333
import static com.facebook.presto.plugin.clp.ClpMetadataDbSetUp.setupSplit;
34-
import static com.facebook.presto.plugin.clp.ClpTableHandle.StorageType.FS;
3534
import static org.testng.Assert.assertEquals;
3635

3736
@Test(singleThreaded = true)
@@ -77,9 +76,7 @@ public void testListSplits()
7776
String tablePath = ARCHIVE_STORAGE_DIRECTORY_BASE + tableName;
7877
List<String> expectedSplits = entry.getValue();
7978
ClpTableLayoutHandle layoutHandle = new ClpTableLayoutHandle(
80-
new ClpTableHandle(new SchemaTableName(DEFAULT_SCHEMA_NAME, tableName),
81-
tablePath, FS),
82-
Optional.empty());
79+
new ClpTableHandle(new SchemaTableName(DEFAULT_SCHEMA_NAME, tableName), tablePath), Optional.empty());
8380
List<ClpSplit> splits = clpSplitProvider.listSplits(layoutHandle);
8481
assertEquals(splits.size(), expectedSplits.size());
8582

0 commit comments

Comments
 (0)