diff --git a/core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminImportTestUtils.java b/core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminImportTestUtils.java index b33d72f47b..531fe9c645 100644 --- a/core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminImportTestUtils.java +++ b/core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminImportTestUtils.java @@ -362,12 +362,20 @@ private LinkedHashMap prepareColumnsForOracle() { columns.put("col19", "TIMESTAMP"); // override to TIME columns.put("col20", "TIMESTAMP WITH TIME ZONE"); columns.put("col21", "TIMESTAMP WITH LOCAL TIME ZONE"); + columns.put("col22", "NUMBER(1)"); // override to BOOLEAN return columns; } private Map prepareOverrideColumnsTypeForOracle() { return ImmutableMap.of( - "col16", DataType.TIME, "col17", DataType.TIMESTAMP, "col19", DataType.TIME); + "col16", + DataType.TIME, + "col17", + DataType.TIMESTAMP, + "col19", + DataType.TIME, + "col22", + DataType.BOOLEAN); } private TableMetadata prepareTableMetadataForOracle() { @@ -395,6 +403,7 @@ private TableMetadata prepareTableMetadataForOracle() { .addColumn("col19", DataType.TIME) .addColumn("col20", DataType.TIMESTAMPTZ) .addColumn("col21", DataType.TIMESTAMPTZ) + .addColumn("col22", DataType.BOOLEAN) .addPartitionKey("pk1") .addPartitionKey("pk2") .build(); diff --git a/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineOracle.java b/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineOracle.java index 8e69660f69..3be3cf82ce 100644 --- a/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineOracle.java +++ b/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineOracle.java @@ -308,6 +308,9 @@ DataType getDataTypeForScalarDbInternal( numericTypeDescription, columnDescription)); } if (digits == 0) { + if (columnSize == 1 && overrideDataType == DataType.BOOLEAN) { + return DataType.BOOLEAN; + } logger.info( "Data type larger than that of underlying database is assigned: {} to BIGINT", numericTypeDescription); diff --git a/core/src/test/java/com/scalar/db/storage/jdbc/RdbEngineTest.java b/core/src/test/java/com/scalar/db/storage/jdbc/RdbEngineTest.java index ff839f29ac..1d7d14edfb 100644 --- a/core/src/test/java/com/scalar/db/storage/jdbc/RdbEngineTest.java +++ b/core/src/test/java/com/scalar/db/storage/jdbc/RdbEngineTest.java @@ -99,6 +99,9 @@ private static void prepareDataTypeMap() { DATA_TYPE_MAP.get(POSTGRESQL).put(new Column(JDBCType.BIT, "bool", 1, 0), DataType.BOOLEAN); DATA_TYPE_MAP.get(SQL_SERVER).put(new Column(JDBCType.BIT, "bit", 1, 0), DataType.BOOLEAN); DATA_TYPE_MAP.get(DB2).put(new Column(JDBCType.BOOLEAN, "BOOLEAN"), DataType.BOOLEAN); + DATA_TYPE_MAP + .get(ORACLE) + .put(new Column(JDBCType.NUMERIC, "NUMBER", 1, 0, DataType.BOOLEAN), DataType.BOOLEAN); // INT DATA_TYPE_MAP.get(MYSQL).put(new Column(JDBCType.TINYINT, "TINYINT"), DataType.INT); @@ -203,6 +206,7 @@ private static void prepareDataTypeMap() { DATA_TYPE_MAP.get(ORACLE).put(new Column(JDBCType.NUMERIC, "NUMBER", 15, 0), DataType.BIGINT); DATA_TYPE_MAP.get(ORACLE).put(new Column(JDBCType.NUMERIC, "NUMBER", 15, 2), DataType.DOUBLE); DATA_TYPE_MAP.get(ORACLE).put(new Column(JDBCType.NUMERIC, "NUMBER", 16, 0), null); + DATA_TYPE_MAP.get(ORACLE).put(new Column(JDBCType.NUMERIC, "NUMBER", 1, 0), DataType.BIGINT); DATA_TYPE_MAP.get(SQL_SERVER).put(new Column(JDBCType.NUMERIC, "numeric"), null); DATA_TYPE_MAP.get(SQL_SERVER).put(new Column(JDBCType.DECIMAL, "decimal"), null); DATA_TYPE_MAP.get(DB2).put(new Column(JDBCType.DECIMAL, "DECIMAL"), null);