Skip to content

Commit 813937a

Browse files
committed
Apply suggestions
1 parent 69af819 commit 813937a

File tree

5 files changed

+121
-189
lines changed

5 files changed

+121
-189
lines changed

core/src/integration-test/java/com/scalar/db/storage/jdbc/ConsensusCommitAdminIntegrationTestWithJdbcDatabase.java

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
149149
try {
150150
// Arrange
151151
Map<String, String> options = getCreationOptions();
152-
TableMetadata.Builder currentTableMetadataBuilder =
152+
TableMetadata currentTableMetadata =
153153
TableMetadata.newBuilder()
154154
.addColumn("c1", DataType.INT)
155155
.addColumn("c2", DataType.INT)
@@ -163,13 +163,11 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
163163
.addColumn("c10", DataType.TIME)
164164
.addColumn("c11", DataType.TIMESTAMPTZ)
165165
.addPartitionKey("c1")
166-
.addClusteringKey("c2", Scan.Ordering.Order.ASC);
167-
if (isTimestampTypeSupported()) {
168-
currentTableMetadataBuilder.addColumn("c12", DataType.TIMESTAMP);
169-
}
170-
TableMetadata currentTableMetadata = currentTableMetadataBuilder.build();
166+
.addClusteringKey("c2", Scan.Ordering.Order.ASC)
167+
.addColumn("c12", DataType.TIMESTAMP)
168+
.build();
171169
admin.createTable(namespace1, TABLE4, currentTableMetadata, options);
172-
InsertBuilder.Buildable insert =
170+
Insert insert =
173171
Insert.newBuilder()
174172
.namespace(namespace1)
175173
.table(TABLE4)
@@ -183,11 +181,10 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
183181
.blobValue("c8", "6".getBytes(StandardCharsets.UTF_8))
184182
.dateValue("c9", LocalDate.now(ZoneId.of("UTC")))
185183
.timeValue("c10", LocalTime.now(ZoneId.of("UTC")))
186-
.timestampTZValue("c11", Instant.now());
187-
if (isTimestampTypeSupported()) {
188-
insert.timestampValue("c12", LocalDateTime.now(ZoneOffset.UTC));
189-
}
190-
transactionalInsert(insert.build());
184+
.timestampTZValue("c11", Instant.now())
185+
.timestampValue("c12", LocalDateTime.now(ZoneOffset.UTC))
186+
.build();
187+
transactionalInsert(insert);
191188

192189
// Act Assert
193190
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c3", DataType.TEXT))
@@ -208,10 +205,8 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
208205
.isInstanceOf(UnsupportedOperationException.class);
209206
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c11", DataType.TEXT))
210207
.isInstanceOf(UnsupportedOperationException.class);
211-
if (isTimestampTypeSupported()) {
212-
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c12", DataType.TEXT))
213-
.isInstanceOf(UnsupportedOperationException.class);
214-
}
208+
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c12", DataType.TEXT))
209+
.isInstanceOf(UnsupportedOperationException.class);
215210
} finally {
216211
admin.dropTable(namespace1, TABLE4, true);
217212
}
@@ -238,11 +233,9 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
238233
.addColumn("c9", DataType.DATE)
239234
.addColumn("c10", DataType.TIME)
240235
.addColumn("c11", DataType.TIMESTAMPTZ)
236+
.addColumn("c12", DataType.TIMESTAMP)
241237
.addPartitionKey("c1")
242238
.addClusteringKey("c2", Scan.Ordering.Order.ASC);
243-
if (isTimestampTypeSupported()) {
244-
currentTableMetadataBuilder.addColumn("c12", DataType.TIMESTAMP);
245-
}
246239
TableMetadata currentTableMetadata = currentTableMetadataBuilder.build();
247240
admin.createTable(namespace1, TABLE4, currentTableMetadata, options);
248241
InsertBuilder.Buildable insert =
@@ -259,10 +252,8 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
259252
.blobValue("c8", "6".getBytes(StandardCharsets.UTF_8))
260253
.dateValue("c9", LocalDate.now(ZoneId.of("UTC")))
261254
.timeValue("c10", LocalTime.now(ZoneId.of("UTC")))
262-
.timestampTZValue("c11", Instant.now());
263-
if (isTimestampTypeSupported()) {
264-
insert.timestampValue("c12", LocalDateTime.now(ZoneOffset.UTC));
265-
}
255+
.timestampTZValue("c11", Instant.now())
256+
.timestampValue("c12", LocalDateTime.now(ZoneOffset.UTC));
266257
transactionalInsert(insert.build());
267258

268259
// Act Assert
@@ -284,12 +275,10 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
284275
.doesNotThrowAnyException();
285276
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c11", DataType.TEXT))
286277
.doesNotThrowAnyException();
287-
if (isTimestampTypeSupported()) {
288-
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c12", DataType.TEXT))
289-
.doesNotThrowAnyException();
290-
}
278+
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c12", DataType.TEXT))
279+
.doesNotThrowAnyException();
291280

292-
TableMetadata.Builder expectedTableMetadataBuilder =
281+
TableMetadata expectedTableMetadata =
293282
TableMetadata.newBuilder()
294283
.addColumn("c1", DataType.INT)
295284
.addColumn("c2", DataType.INT)
@@ -302,12 +291,10 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
302291
.addColumn("c9", DataType.TEXT)
303292
.addColumn("c10", DataType.TEXT)
304293
.addColumn("c11", DataType.TEXT)
294+
.addColumn("c12", DataType.TEXT)
305295
.addPartitionKey("c1")
306-
.addClusteringKey("c2", Scan.Ordering.Order.ASC);
307-
if (isTimestampTypeSupported()) {
308-
expectedTableMetadataBuilder.addColumn("c12", DataType.TEXT);
309-
}
310-
TableMetadata expectedTableMetadata = expectedTableMetadataBuilder.build();
296+
.addClusteringKey("c2", Scan.Ordering.Order.ASC)
297+
.build();
311298
assertThat(admin.getTableMetadata(namespace1, TABLE4)).isEqualTo(expectedTableMetadata);
312299
} finally {
313300
admin.dropTable(namespace1, TABLE4, true);

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminCaseSensitivityIntegrationTest.java

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
156156
try (DistributedStorage storage = storageFactory.getStorage()) {
157157
// Arrange
158158
Map<String, String> options = getCreationOptions();
159-
TableMetadata.Builder currentTableMetadataBuilder =
159+
TableMetadata currentTableMetadata =
160160
TableMetadata.newBuilder()
161161
.addColumn(getColumnName1(), DataType.INT)
162162
.addColumn(getColumnName2(), DataType.INT)
@@ -169,12 +169,10 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
169169
.addColumn(getColumnName9(), DataType.DATE)
170170
.addColumn(getColumnName10(), DataType.TIME)
171171
.addColumn(getColumnName11(), DataType.TIMESTAMPTZ)
172+
.addColumn(getColumnName12(), DataType.TIMESTAMP)
172173
.addPartitionKey(getColumnName1())
173-
.addClusteringKey(getColumnName2(), Scan.Ordering.Order.ASC);
174-
if (isTimestampTypeSupported()) {
175-
currentTableMetadataBuilder.addColumn(getColumnName12(), DataType.TIMESTAMP);
176-
}
177-
TableMetadata currentTableMetadata = currentTableMetadataBuilder.build();
174+
.addClusteringKey(getColumnName2(), Scan.Ordering.Order.ASC)
175+
.build();
178176
admin.createTable(getNamespace1(), getTable4(), currentTableMetadata, options);
179177
PutBuilder.Buildable put =
180178
Put.newBuilder()
@@ -190,10 +188,8 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
190188
.blobValue(getColumnName8(), "6".getBytes(StandardCharsets.UTF_8))
191189
.dateValue(getColumnName9(), LocalDate.now(ZoneId.of("UTC")))
192190
.timeValue(getColumnName10(), LocalTime.now(ZoneId.of("UTC")))
193-
.timestampTZValue(getColumnName11(), Instant.now());
194-
if (isTimestampTypeSupported()) {
195-
put.timestampValue(getColumnName12(), LocalDateTime.now(ZoneOffset.UTC));
196-
}
191+
.timestampTZValue(getColumnName11(), Instant.now())
192+
.timestampValue(getColumnName12(), LocalDateTime.now(ZoneOffset.UTC));
197193
storage.put(put.build());
198194
storage.close();
199195

@@ -243,13 +239,11 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
243239
admin.alterColumnType(
244240
getNamespace1(), getTable4(), getColumnName11(), DataType.TEXT))
245241
.isInstanceOf(UnsupportedOperationException.class);
246-
if (isTimestampTypeSupported()) {
247-
assertThatCode(
248-
() ->
249-
admin.alterColumnType(
250-
getNamespace1(), getTable4(), getColumnName12(), DataType.TEXT))
251-
.isInstanceOf(UnsupportedOperationException.class);
252-
}
242+
assertThatCode(
243+
() ->
244+
admin.alterColumnType(
245+
getNamespace1(), getTable4(), getColumnName12(), DataType.TEXT))
246+
.isInstanceOf(UnsupportedOperationException.class);
253247
} finally {
254248
admin.dropTable(getNamespace1(), getTable4(), true);
255249
}
@@ -263,7 +257,7 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
263257
try (DistributedStorage storage = storageFactory.getStorage()) {
264258
// Arrange
265259
Map<String, String> options = getCreationOptions();
266-
TableMetadata.Builder currentTableMetadataBuilder =
260+
TableMetadata currentTableMetadata =
267261
TableMetadata.newBuilder()
268262
.addColumn(getColumnName1(), DataType.INT)
269263
.addColumn(getColumnName2(), DataType.INT)
@@ -276,14 +270,12 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
276270
.addColumn(getColumnName9(), DataType.DATE)
277271
.addColumn(getColumnName10(), DataType.TIME)
278272
.addColumn(getColumnName11(), DataType.TIMESTAMPTZ)
273+
.addColumn(getColumnName12(), DataType.TIMESTAMP)
279274
.addPartitionKey(getColumnName1())
280-
.addClusteringKey(getColumnName2(), Scan.Ordering.Order.ASC);
281-
if (isTimestampTypeSupported()) {
282-
currentTableMetadataBuilder.addColumn(getColumnName12(), DataType.TIMESTAMP);
283-
}
284-
TableMetadata currentTableMetadata = currentTableMetadataBuilder.build();
275+
.addClusteringKey(getColumnName2(), Scan.Ordering.Order.ASC)
276+
.build();
285277
admin.createTable(getNamespace1(), getTable4(), currentTableMetadata, options);
286-
PutBuilder.Buildable put =
278+
Put put =
287279
Put.newBuilder()
288280
.namespace(getNamespace1())
289281
.table(getTable4())
@@ -297,11 +289,10 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
297289
.blobValue(getColumnName8(), "6".getBytes(StandardCharsets.UTF_8))
298290
.dateValue(getColumnName9(), LocalDate.now(ZoneId.of("UTC")))
299291
.timeValue(getColumnName10(), LocalTime.now(ZoneId.of("UTC")))
300-
.timestampTZValue(getColumnName11(), Instant.now());
301-
if (isTimestampTypeSupported()) {
302-
put.timestampValue(getColumnName12(), LocalDateTime.now(ZoneOffset.UTC));
303-
}
304-
storage.put(put.build());
292+
.timestampTZValue(getColumnName11(), Instant.now())
293+
.timestampValue(getColumnName12(), LocalDateTime.now(ZoneOffset.UTC))
294+
.build();
295+
storage.put(put);
305296
storage.close();
306297

307298
// Act Assert
@@ -350,15 +341,13 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
350341
admin.alterColumnType(
351342
getNamespace1(), getTable4(), getColumnName11(), DataType.TEXT))
352343
.doesNotThrowAnyException();
353-
if (isTimestampTypeSupported()) {
354-
assertThatCode(
355-
() ->
356-
admin.alterColumnType(
357-
getNamespace1(), getTable4(), getColumnName12(), DataType.TEXT))
358-
.doesNotThrowAnyException();
359-
}
344+
assertThatCode(
345+
() ->
346+
admin.alterColumnType(
347+
getNamespace1(), getTable4(), getColumnName12(), DataType.TEXT))
348+
.doesNotThrowAnyException();
360349

361-
TableMetadata.Builder expectedTableMetadataBuilder =
350+
TableMetadata expectedTableMetadata =
362351
TableMetadata.newBuilder()
363352
.addColumn(getColumnName1(), DataType.INT)
364353
.addColumn(getColumnName2(), DataType.INT)
@@ -372,11 +361,9 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
372361
.addColumn(getColumnName10(), DataType.TEXT)
373362
.addColumn(getColumnName11(), DataType.TEXT)
374363
.addPartitionKey(getColumnName1())
375-
.addClusteringKey(getColumnName2(), Scan.Ordering.Order.ASC);
376-
if (isTimestampTypeSupported()) {
377-
expectedTableMetadataBuilder.addColumn(getColumnName12(), DataType.TEXT);
378-
}
379-
TableMetadata expectedTableMetadata = expectedTableMetadataBuilder.build();
364+
.addClusteringKey(getColumnName2(), Scan.Ordering.Order.ASC)
365+
.addColumn(getColumnName12(), DataType.TEXT)
366+
.build();
380367
assertThat(admin.getTableMetadata(getNamespace1(), getTable4()))
381368
.isEqualTo(expectedTableMetadata);
382369
} finally {

0 commit comments

Comments
 (0)