Skip to content

Commit d88a89c

Browse files
authored
Remove deprecated partial delete job (#389)
1 parent f085280 commit d88a89c

File tree

4 files changed

+14
-197
lines changed

4 files changed

+14
-197
lines changed

src/main/java/com/treasuredata/client/TDClient.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import com.treasuredata.client.model.TDJobRequest;
4444
import com.treasuredata.client.model.TDJobSubmitResult;
4545
import com.treasuredata.client.model.TDJobSummary;
46-
import com.treasuredata.client.model.TDPartialDeleteJob;
4746
import com.treasuredata.client.model.TDResultFormat;
4847
import com.treasuredata.client.model.TDSaveQueryRequest;
4948
import com.treasuredata.client.model.TDSavedQuery;
@@ -564,33 +563,6 @@ public void deleteTableIfExists(String databaseName, String tableName)
564563
}
565564
}
566565

567-
@Override
568-
public TDPartialDeleteJob partialDelete(String databaseName, String tableName, long from, long to)
569-
throws TDClientException
570-
{
571-
return partialDelete(databaseName, tableName, from, to, null);
572-
}
573-
574-
@Override
575-
public TDPartialDeleteJob partialDelete(String databaseName, String tableName, long from, long to, String domainKey)
576-
throws TDClientException
577-
{
578-
if ((from % 3600 != 0) || (to % 3600 != 0)) {
579-
throw new TDClientException(TDClientException.ErrorType.INVALID_INPUT, String.format("from/to value must be a multiple of 3600: [%s, %s)", from, to));
580-
}
581-
582-
Map<String, String> queryParams = new HashMap<>();
583-
queryParams.put("from", Long.toString(from));
584-
queryParams.put("to", Long.toString(to));
585-
586-
if (domainKey != null) {
587-
queryParams.put("domain_key", domainKey);
588-
}
589-
590-
TDPartialDeleteJob job = doPost(buildUrl("/v3/table/partialdelete", databaseName, tableName), Collections.unmodifiableMap(queryParams), TDPartialDeleteJob.class);
591-
return job;
592-
}
593-
594566
@Override
595567
public void swapTables(String databaseName, String tableName1, String tableName2)
596568
{

src/main/java/com/treasuredata/client/TDClientApi.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import com.treasuredata.client.model.TDJobList;
3434
import com.treasuredata.client.model.TDJobRequest;
3535
import com.treasuredata.client.model.TDJobSummary;
36-
import com.treasuredata.client.model.TDPartialDeleteJob;
3736
import com.treasuredata.client.model.TDResultFormat;
3837
import com.treasuredata.client.model.TDSaveQueryRequest;
3938
import com.treasuredata.client.model.TDSavedQuery;
@@ -215,10 +214,6 @@ public interface TDClientApi<ClientImpl>
215214

216215
void deleteTableIfExists(String databaseName, String tableName);
217216

218-
TDPartialDeleteJob partialDelete(String databaseName, String tableName, long from, long to);
219-
220-
TDPartialDeleteJob partialDelete(String databaseName, String tableName, long from, long to, String domainKey);
221-
222217
void swapTables(String databaseName, String tableName1, String tableName2);
223218

224219
// schema API

src/main/java/com/treasuredata/client/model/TDPartialDeleteJob.java

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/test/java/com/treasuredata/client/TestTDClient.java

Lines changed: 14 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import com.treasuredata.client.model.TDJobRequest;
4242
import com.treasuredata.client.model.TDJobRequestBuilder;
4343
import com.treasuredata.client.model.TDJobSummary;
44-
import com.treasuredata.client.model.TDPartialDeleteJob;
4544
import com.treasuredata.client.model.TDResultFormat;
4645
import com.treasuredata.client.model.TDSaveQueryRequest;
4746
import com.treasuredata.client.model.TDSavedQuery;
@@ -1001,85 +1000,6 @@ private static String newTemporaryName(String prefix)
10011000
return prefix + "_" + dateStr;
10021001
}
10031002

1004-
@Test
1005-
public void partialDeleteTest()
1006-
throws Exception
1007-
{
1008-
String t = newTemporaryName("td_client_test");
1009-
try {
1010-
client.deleteTableIfExists(SAMPLE_DB, t);
1011-
1012-
String jobId = client.submit(TDJobRequest.newPrestoQuery(SAMPLE_DB,
1013-
String.format("CREATE TABLE %s AS SELECT * FROM (VALUES TD_TIME_PARSE('2015-01-01', 'UTC'), TD_TIME_PARSE('2015-02-01', 'UTC')) as sample(time)", t, t)));
1014-
1015-
waitJobCompletion(jobId);
1016-
1017-
String before = queryResult(SAMPLE_DB, String.format("SELECT * FROM %s", t));
1018-
1019-
assertTrue(before.contains("1420070400"));
1020-
assertTrue(before.contains("1422748800"));
1021-
1022-
// delete 2015-01-01 entry
1023-
try {
1024-
client.partialDelete(SAMPLE_DB, t, 1420070400, 1420070400 + 1);
1025-
fail("should not reach here");
1026-
}
1027-
catch (TDClientException e) {
1028-
assertEquals(TDClientException.ErrorType.INVALID_INPUT, e.getErrorType());
1029-
}
1030-
long from = 1420070400 - (1420070400 % 3600);
1031-
long to = from + 3600;
1032-
TDPartialDeleteJob partialDeleteJob = client.partialDelete(SAMPLE_DB, t, from, to);
1033-
logger.debug("partial delete job: " + partialDeleteJob);
1034-
assertEquals(from, partialDeleteJob.getFrom());
1035-
assertEquals(to, partialDeleteJob.getTo());
1036-
assertEquals(SAMPLE_DB, partialDeleteJob.getDatabase());
1037-
assertEquals(t, partialDeleteJob.getTable());
1038-
1039-
waitJobCompletion(partialDeleteJob.getJobId());
1040-
1041-
String after = queryResult(SAMPLE_DB, String.format("SELECT * FROM %s", t));
1042-
assertFalse(after.contains("1420070400"));
1043-
assertTrue(after.contains("1422748800"));
1044-
}
1045-
finally {
1046-
client.deleteTableIfExists(SAMPLE_DB, t);
1047-
}
1048-
}
1049-
1050-
@Test
1051-
public void partialDeleteWithDomainKeyTest()
1052-
throws Exception
1053-
{
1054-
String domainKey = randomDomainKey();
1055-
1056-
String t = newTemporaryName("td_client_test");
1057-
try {
1058-
client.deleteTableIfExists(SAMPLE_DB, t);
1059-
1060-
String jobId = client.submit(TDJobRequest.newPrestoQuery(SAMPLE_DB,
1061-
String.format("CREATE TABLE %s AS SELECT * FROM (VALUES TD_TIME_PARSE('2015-01-01', 'UTC'), TD_TIME_PARSE('2015-02-01', 'UTC')) as sample(time)", t, t)));
1062-
1063-
waitJobCompletion(jobId);
1064-
1065-
int from = 1420070400;
1066-
int to = from + 3600;
1067-
1068-
TDPartialDeleteJob deleteJob = client.partialDelete(SAMPLE_DB, t, from, to, domainKey);
1069-
1070-
try {
1071-
client.partialDelete(SAMPLE_DB, t, from, to, domainKey);
1072-
fail("Expected " + TDClientHttpConflictException.class.getName());
1073-
}
1074-
catch (TDClientHttpConflictException e) {
1075-
assertThat(e.getConflictsWith(), is(Optional.of(deleteJob.getJobId())));
1076-
}
1077-
}
1078-
finally {
1079-
client.deleteTableIfExists(SAMPLE_DB, t);
1080-
}
1081-
}
1082-
10831003
@Test
10841004
public void swapTest()
10851005
throws Exception
@@ -1248,9 +1168,23 @@ public void testBulkImport()
12481168
}
12491169

12501170
// Check the data
1171+
// It seems it needs some time to reflect the data in TD,
1172+
// so we will wait for few mins before checking the data
1173+
deadline = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(5);
1174+
12511175
TDTable imported = client.listTables(SAMPLE_DB).stream().filter(input -> {
12521176
return input.getName().equals(bulkImportTable);
12531177
}).findFirst().get();
1178+
while (imported.getRowCount() == 0) {
1179+
if (System.currentTimeMillis() > deadline) {
1180+
throw new IllegalStateException("timeout error: data is not imported yet");
1181+
}
1182+
logger.info("Waiting data import step completion");
1183+
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
1184+
imported = client.listTables(SAMPLE_DB).stream().filter(input -> {
1185+
return input.getName().equals(bulkImportTable);
1186+
}).findFirst().get();
1187+
}
12541188

12551189
assertEquals(numRowsInPart * 2, imported.getRowCount());
12561190
List<TDColumn> columns = imported.getColumns();

0 commit comments

Comments
 (0)