Skip to content

Commit b41de5e

Browse files
committed
Update supported type conversion in Db2
1 parent d775440 commit b41de5e

File tree

6 files changed

+51
-66
lines changed

6 files changed

+51
-66
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,22 +274,22 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
274274
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c4", DataType.TEXT))
275275
.doesNotThrowAnyException();
276276
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c5", DataType.TEXT))
277-
.isInstanceOf(UnsupportedOperationException.class);
277+
.doesNotThrowAnyException();
278278
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c6", DataType.TEXT))
279279
.doesNotThrowAnyException();
280280
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c7", DataType.TEXT))
281281
.doesNotThrowAnyException();
282282
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c8", DataType.TEXT))
283283
.isInstanceOf(UnsupportedOperationException.class);
284284
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c9", DataType.TEXT))
285-
.isInstanceOf(UnsupportedOperationException.class);
285+
.doesNotThrowAnyException();
286286
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c10", DataType.TEXT))
287-
.isInstanceOf(UnsupportedOperationException.class);
287+
.doesNotThrowAnyException();
288288
if (isTimestampTypeSupported()) {
289289
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c11", DataType.TEXT))
290-
.isInstanceOf(UnsupportedOperationException.class);
290+
.doesNotThrowAnyException();
291291
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c12", DataType.TEXT))
292-
.isInstanceOf(UnsupportedOperationException.class);
292+
.doesNotThrowAnyException();
293293
}
294294

295295
TableMetadata.Builder expectedTableMetadataBuilder =
@@ -298,18 +298,18 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
298298
.addColumn("c2", DataType.INT)
299299
.addColumn("c3", DataType.TEXT)
300300
.addColumn("c4", DataType.TEXT)
301-
.addColumn("c5", DataType.FLOAT)
301+
.addColumn("c5", DataType.TEXT)
302302
.addColumn("c6", DataType.TEXT)
303303
.addColumn("c7", DataType.TEXT)
304304
.addColumn("c8", DataType.BLOB)
305-
.addColumn("c9", DataType.DATE)
306-
.addColumn("c10", DataType.TIME)
305+
.addColumn("c9", DataType.TEXT)
306+
.addColumn("c10", DataType.TEXT)
307307
.addPartitionKey("c1")
308308
.addClusteringKey("c2", Scan.Ordering.Order.ASC);
309309
if (isTimestampTypeSupported()) {
310310
expectedTableMetadataBuilder
311-
.addColumn("c11", DataType.TIMESTAMP)
312-
.addColumn("c12", DataType.TIMESTAMPTZ);
311+
.addColumn("c11", DataType.TEXT)
312+
.addColumn("c12", DataType.TEXT);
313313
}
314314
TableMetadata expectedTableMetadata = expectedTableMetadataBuilder.build();
315315
assertThat(admin.getTableMetadata(namespace1, TABLE4)).isEqualTo(expectedTableMetadata);

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
321321
() ->
322322
admin.alterColumnType(
323323
getNamespace1(), getTable4(), getColumnName5(), DataType.TEXT))
324-
.isInstanceOf(UnsupportedOperationException.class);
324+
.doesNotThrowAnyException();
325325
assertThatCode(
326326
() ->
327327
admin.alterColumnType(
@@ -341,23 +341,23 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
341341
() ->
342342
admin.alterColumnType(
343343
getNamespace1(), getTable4(), getColumnName9(), DataType.TEXT))
344-
.isInstanceOf(UnsupportedOperationException.class);
344+
.doesNotThrowAnyException();
345345
assertThatCode(
346346
() ->
347347
admin.alterColumnType(
348348
getNamespace1(), getTable4(), getColumnName10(), DataType.TEXT))
349-
.isInstanceOf(UnsupportedOperationException.class);
349+
.doesNotThrowAnyException();
350350
if (isTimestampTypeSupported()) {
351351
assertThatCode(
352352
() ->
353353
admin.alterColumnType(
354354
getNamespace1(), getTable4(), getColumnName11(), DataType.TEXT))
355-
.isInstanceOf(UnsupportedOperationException.class);
355+
.doesNotThrowAnyException();
356356
assertThatCode(
357357
() ->
358358
admin.alterColumnType(
359359
getNamespace1(), getTable4(), getColumnName12(), DataType.TEXT))
360-
.isInstanceOf(UnsupportedOperationException.class);
360+
.doesNotThrowAnyException();
361361
}
362362

363363
TableMetadata.Builder expectedTableMetadataBuilder =
@@ -366,18 +366,18 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
366366
.addColumn(getColumnName2(), DataType.INT)
367367
.addColumn(getColumnName3(), DataType.TEXT)
368368
.addColumn(getColumnName4(), DataType.TEXT)
369-
.addColumn(getColumnName5(), DataType.FLOAT)
369+
.addColumn(getColumnName5(), DataType.TEXT)
370370
.addColumn(getColumnName6(), DataType.TEXT)
371371
.addColumn(getColumnName7(), DataType.TEXT)
372372
.addColumn(getColumnName8(), DataType.BLOB)
373-
.addColumn(getColumnName9(), DataType.DATE)
374-
.addColumn(getColumnName10(), DataType.TIME)
373+
.addColumn(getColumnName9(), DataType.TEXT)
374+
.addColumn(getColumnName10(), DataType.TEXT)
375375
.addPartitionKey(getColumnName1())
376376
.addClusteringKey(getColumnName2(), Scan.Ordering.Order.ASC);
377377
if (isTimestampTypeSupported()) {
378378
expectedTableMetadataBuilder
379-
.addColumn(getColumnName11(), DataType.TIMESTAMP)
380-
.addColumn(getColumnName12(), DataType.TIMESTAMPTZ);
379+
.addColumn(getColumnName11(), DataType.TEXT)
380+
.addColumn(getColumnName12(), DataType.TEXT);
381381
}
382382
TableMetadata expectedTableMetadata = expectedTableMetadataBuilder.build();
383383
assertThat(admin.getTableMetadata(getNamespace1(), getTable4()))

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
320320
() ->
321321
admin.alterColumnType(
322322
getNamespace1(), getTable4(), getColumnName5(), DataType.TEXT))
323-
.isInstanceOf(UnsupportedOperationException.class);
323+
.doesNotThrowAnyException();
324324
assertThatCode(
325325
() ->
326326
admin.alterColumnType(
@@ -340,23 +340,23 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
340340
() ->
341341
admin.alterColumnType(
342342
getNamespace1(), getTable4(), getColumnName9(), DataType.TEXT))
343-
.isInstanceOf(UnsupportedOperationException.class);
343+
.doesNotThrowAnyException();
344344
assertThatCode(
345345
() ->
346346
admin.alterColumnType(
347347
getNamespace1(), getTable4(), getColumnName10(), DataType.TEXT))
348-
.isInstanceOf(UnsupportedOperationException.class);
348+
.doesNotThrowAnyException();
349349
if (isTimestampTypeSupported()) {
350350
assertThatCode(
351351
() ->
352352
admin.alterColumnType(
353353
getNamespace1(), getTable4(), getColumnName11(), DataType.TEXT))
354-
.isInstanceOf(UnsupportedOperationException.class);
354+
.doesNotThrowAnyException();
355355
assertThatCode(
356356
() ->
357357
admin.alterColumnType(
358358
getNamespace1(), getTable4(), getColumnName12(), DataType.TEXT))
359-
.isInstanceOf(UnsupportedOperationException.class);
359+
.doesNotThrowAnyException();
360360
}
361361

362362
TableMetadata.Builder expectedTableMetadataBuilder =
@@ -365,18 +365,18 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
365365
.addColumn(getColumnName2(), DataType.INT)
366366
.addColumn(getColumnName3(), DataType.TEXT)
367367
.addColumn(getColumnName4(), DataType.TEXT)
368-
.addColumn(getColumnName5(), DataType.FLOAT)
368+
.addColumn(getColumnName5(), DataType.TEXT)
369369
.addColumn(getColumnName6(), DataType.TEXT)
370370
.addColumn(getColumnName7(), DataType.TEXT)
371371
.addColumn(getColumnName8(), DataType.BLOB)
372-
.addColumn(getColumnName9(), DataType.DATE)
373-
.addColumn(getColumnName10(), DataType.TIME)
372+
.addColumn(getColumnName9(), DataType.TEXT)
373+
.addColumn(getColumnName10(), DataType.TEXT)
374374
.addPartitionKey(getColumnName1())
375375
.addClusteringKey(getColumnName2(), Scan.Ordering.Order.ASC);
376376
if (isTimestampTypeSupported()) {
377377
expectedTableMetadataBuilder
378-
.addColumn(getColumnName11(), DataType.TIMESTAMP)
379-
.addColumn(getColumnName12(), DataType.TIMESTAMPTZ);
378+
.addColumn(getColumnName11(), DataType.TEXT)
379+
.addColumn(getColumnName12(), DataType.TEXT);
380380
}
381381
TableMetadata expectedTableMetadata = expectedTableMetadataBuilder.build();
382382
assertThat(admin.getTableMetadata(getNamespace1(), getTable4()))

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,22 +274,22 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
274274
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c4", DataType.TEXT))
275275
.doesNotThrowAnyException();
276276
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c5", DataType.TEXT))
277-
.isInstanceOf(UnsupportedOperationException.class);
277+
.doesNotThrowAnyException();
278278
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c6", DataType.TEXT))
279279
.doesNotThrowAnyException();
280280
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c7", DataType.TEXT))
281281
.doesNotThrowAnyException();
282282
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c8", DataType.TEXT))
283283
.isInstanceOf(UnsupportedOperationException.class);
284284
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c9", DataType.TEXT))
285-
.isInstanceOf(UnsupportedOperationException.class);
285+
.doesNotThrowAnyException();
286286
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c10", DataType.TEXT))
287-
.isInstanceOf(UnsupportedOperationException.class);
287+
.doesNotThrowAnyException();
288288
if (isTimestampTypeSupported()) {
289289
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c11", DataType.TEXT))
290-
.isInstanceOf(UnsupportedOperationException.class);
290+
.doesNotThrowAnyException();
291291
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c12", DataType.TEXT))
292-
.isInstanceOf(UnsupportedOperationException.class);
292+
.doesNotThrowAnyException();
293293
}
294294

295295
TableMetadata.Builder expectedTableMetadataBuilder =
@@ -298,18 +298,18 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
298298
.addColumn("c2", DataType.INT)
299299
.addColumn("c3", DataType.TEXT)
300300
.addColumn("c4", DataType.TEXT)
301-
.addColumn("c5", DataType.FLOAT)
301+
.addColumn("c5", DataType.TEXT)
302302
.addColumn("c6", DataType.TEXT)
303303
.addColumn("c7", DataType.TEXT)
304304
.addColumn("c8", DataType.BLOB)
305-
.addColumn("c9", DataType.DATE)
306-
.addColumn("c10", DataType.TIME)
305+
.addColumn("c9", DataType.TEXT)
306+
.addColumn("c10", DataType.TEXT)
307307
.addPartitionKey("c1")
308308
.addClusteringKey("c2", Scan.Ordering.Order.ASC);
309309
if (isTimestampTypeSupported()) {
310310
expectedTableMetadataBuilder
311-
.addColumn("c11", DataType.TIMESTAMP)
312-
.addColumn("c12", DataType.TIMESTAMPTZ);
311+
.addColumn("c11", DataType.TEXT)
312+
.addColumn("c12", DataType.TEXT);
313313
}
314314
TableMetadata expectedTableMetadata = expectedTableMetadataBuilder.build();
315315
assertThat(admin.getTableMetadata(namespace1, TABLE4)).isEqualTo(expectedTableMetadata);

core/src/integration-test/java/com/scalar/db/transaction/jdbc/JdbcTransactionAdminIntegrationTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -346,22 +346,22 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
346346
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c4", DataType.TEXT))
347347
.doesNotThrowAnyException();
348348
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c5", DataType.TEXT))
349-
.isInstanceOf(UnsupportedOperationException.class);
349+
.doesNotThrowAnyException();
350350
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c6", DataType.TEXT))
351351
.doesNotThrowAnyException();
352352
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c7", DataType.TEXT))
353353
.doesNotThrowAnyException();
354354
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c8", DataType.TEXT))
355355
.isInstanceOf(UnsupportedOperationException.class);
356356
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c9", DataType.TEXT))
357-
.isInstanceOf(UnsupportedOperationException.class);
357+
.doesNotThrowAnyException();
358358
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c10", DataType.TEXT))
359-
.isInstanceOf(UnsupportedOperationException.class);
359+
.doesNotThrowAnyException();
360360
if (isTimestampTypeSupported()) {
361361
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c11", DataType.TEXT))
362-
.isInstanceOf(UnsupportedOperationException.class);
362+
.doesNotThrowAnyException();
363363
assertThatCode(() -> admin.alterColumnType(namespace1, TABLE4, "c12", DataType.TEXT))
364-
.isInstanceOf(UnsupportedOperationException.class);
364+
.doesNotThrowAnyException();
365365
}
366366

367367
TableMetadata.Builder expectedTableMetadataBuilder =
@@ -370,18 +370,18 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
370370
.addColumn("c2", DataType.INT)
371371
.addColumn("c3", DataType.TEXT)
372372
.addColumn("c4", DataType.TEXT)
373-
.addColumn("c5", DataType.FLOAT)
373+
.addColumn("c5", DataType.TEXT)
374374
.addColumn("c6", DataType.TEXT)
375375
.addColumn("c7", DataType.TEXT)
376376
.addColumn("c8", DataType.BLOB)
377-
.addColumn("c9", DataType.DATE)
378-
.addColumn("c10", DataType.TIME)
377+
.addColumn("c9", DataType.TEXT)
378+
.addColumn("c10", DataType.TEXT)
379379
.addPartitionKey("c1")
380380
.addClusteringKey("c2", Scan.Ordering.Order.ASC);
381381
if (isTimestampTypeSupported()) {
382382
expectedTableMetadataBuilder
383-
.addColumn("c11", DataType.TIMESTAMP)
384-
.addColumn("c12", DataType.TIMESTAMPTZ);
383+
.addColumn("c11", DataType.TEXT)
384+
.addColumn("c12", DataType.TEXT);
385385
}
386386
TableMetadata expectedTableMetadata = expectedTableMetadataBuilder.build();
387387
assertThat(admin.getTableMetadata(namespace1, TABLE4)).isEqualTo(expectedTableMetadata);

core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineDb2.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -577,21 +577,6 @@ public void throwIfCrossPartitionScanOrderingOnBlobColumnNotSupported(
577577

578578
@Override
579579
public boolean isTypeConversionSupported(DataType from, DataType to) {
580-
if (from == DataType.BLOB && to == DataType.TEXT) {
581-
return false;
582-
}
583-
if (from == DataType.FLOAT && to == DataType.TEXT) {
584-
return false;
585-
}
586-
if (from == DataType.DATE && to == DataType.TEXT) {
587-
return false;
588-
}
589-
if (from == DataType.TIME && to == DataType.TEXT) {
590-
return false;
591-
}
592-
if (from == DataType.TIMESTAMP && to == DataType.TEXT) {
593-
return false;
594-
}
595-
return !(from == DataType.TIMESTAMPTZ && to == DataType.TEXT);
580+
return from != DataType.BLOB || to != DataType.TEXT;
596581
}
597582
}

0 commit comments

Comments
 (0)