diff --git a/v2/sourcedb-to-spanner/src/main/java/com/google/cloud/teleport/v2/source/reader/io/jdbc/dialectadapter/mysql/MysqlDialectAdapter.java b/v2/sourcedb-to-spanner/src/main/java/com/google/cloud/teleport/v2/source/reader/io/jdbc/dialectadapter/mysql/MysqlDialectAdapter.java index cd90dd0b48..ffa46d4aff 100644 --- a/v2/sourcedb-to-spanner/src/main/java/com/google/cloud/teleport/v2/source/reader/io/jdbc/dialectadapter/mysql/MysqlDialectAdapter.java +++ b/v2/sourcedb-to-spanner/src/main/java/com/google/cloud/teleport/v2/source/reader/io/jdbc/dialectadapter/mysql/MysqlDialectAdapter.java @@ -376,6 +376,7 @@ private ImmutableMap getTableCols( .put("TINYTEXT", IndexType.STRING) .put("DATETIME", IndexType.TIME_STAMP) .put("TIMESTAMP", IndexType.TIME_STAMP) + .put("BOOL", IndexType.NUMERIC) .put("YEAR", IndexType.NUMERIC) .build(); diff --git a/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/source/reader/io/jdbc/dialectadapter/mysql/MysqlDialectAdapterTest.java b/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/source/reader/io/jdbc/dialectadapter/mysql/MysqlDialectAdapterTest.java index a5a72036c6..dab5d4587c 100644 --- a/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/source/reader/io/jdbc/dialectadapter/mysql/MysqlDialectAdapterTest.java +++ b/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/source/reader/io/jdbc/dialectadapter/mysql/MysqlDialectAdapterTest.java @@ -280,7 +280,7 @@ public void testDiscoverTablesRsException() throws SQLException { public void testDiscoverIndexesBasic() throws SQLException, RetriableSchemaDiscoveryException { ImmutableList testTables = ImmutableList.of("testTable1"); ImmutableList colTypes = - ImmutableList.of("float", "integer", "bit", "char", "varbinary", "binary", "year"); + ImmutableList.of("float", "integer", "bit", "char", "varbinary", "binary", "year", "bool"); ImmutableList expectedSourceColumnIndexInfos = ImmutableList.of( SourceColumnIndexInfo.builder() @@ -343,6 +343,15 @@ public void testDiscoverIndexesBasic() throws SQLException, RetriableSchemaDisco .setCardinality(42L) .setIndexType(IndexType.BINARY) .setOrdinalPosition(4) + .build(), + SourceColumnIndexInfo.builder() + .setColumnName("testColBool") + .setIndexName("primary") + .setIsUnique(true) + .setIsPrimary(true) + .setCardinality(2L) + .setIndexType(IndexType.NUMERIC) + .setOrdinalPosition(5) .build()); SourceColumnIndexInfo.builder() .setColumnName("testColYear") diff --git a/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/templates/MySQLDataTypesIT.java b/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/templates/MySQLDataTypesIT.java index 057dcba4fb..692b77f35d 100644 --- a/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/templates/MySQLDataTypesIT.java +++ b/v2/sourcedb-to-spanner/src/test/java/com/google/cloud/teleport/v2/templates/MySQLDataTypesIT.java @@ -277,6 +277,7 @@ private Map>> getExpectedData() { "2005-01-01T00:01:54.123456000Z", "2037-12-30T23:59:59Z", "2038-01-18T23:59:59Z")); + expectedData.put("bool_pk", createRows("bool_pk", false, true)); expectedData.put("year_pk", createRows("year_pk", "1901", "2000")); return expectedData; } diff --git a/v2/sourcedb-to-spanner/src/test/resources/DataTypesIT/mysql-data-types.sql b/v2/sourcedb-to-spanner/src/test/resources/DataTypesIT/mysql-data-types.sql index ae05379a26..e5fcfe9d2b 100644 --- a/v2/sourcedb-to-spanner/src/test/resources/DataTypesIT/mysql-data-types.sql +++ b/v2/sourcedb-to-spanner/src/test/resources/DataTypesIT/mysql-data-types.sql @@ -296,6 +296,12 @@ CREATE TABLE year_pk_table ( year_pk_col YEAR NOT NULL ); +CREATE TABLE bool_pk_table ( + id BOOL PRIMARY KEY, + bool_pk_col BOOL NOT NULL +); + + ALTER TABLE `bigint_table` MODIFY `id` INT AUTO_INCREMENT; ALTER TABLE `bigint_unsigned_table` MODIFY `id` INT AUTO_INCREMENT; ALTER TABLE `binary_table` MODIFY `id` INT AUTO_INCREMENT; @@ -454,6 +460,8 @@ INSERT INTO `timestamp_pk_table` (`id`, `timestamp_pk_col`) VALUES ('2005-01-01 SET time_zone = SYSTEM; INSERT INTO `year_pk_table` (`id`, `year_pk_col`) VALUES (1901, 1901), (2000, 2000); +INSERT INTO `bool_pk_table` (`id`, `bool_pk_col`) VALUES (TRUE, TRUE), (FALSE, FALSE); + INSERT INTO `bigint_table` (`bigint_col`) VALUES (NULL); INSERT INTO `bigint_unsigned_table` (`bigint_unsigned_col`) VALUES (NULL); INSERT INTO `binary_table` (`binary_col`) VALUES (NULL); diff --git a/v2/sourcedb-to-spanner/src/test/resources/DataTypesIT/mysql-spanner-schema.sql b/v2/sourcedb-to-spanner/src/test/resources/DataTypesIT/mysql-spanner-schema.sql index 06d0382984..dfb4a7be16 100644 --- a/v2/sourcedb-to-spanner/src/test/resources/DataTypesIT/mysql-spanner-schema.sql +++ b/v2/sourcedb-to-spanner/src/test/resources/DataTypesIT/mysql-spanner-schema.sql @@ -323,6 +323,11 @@ CREATE TABLE IF NOT EXISTS timestamp_pk_table ( timestamp_pk_col TIMESTAMP NOT NULL, ) PRIMARY KEY(id); +CREATE TABLE IF NOT EXISTS bool_pk_table ( + id BOOL NOT NULL, + bool_pk_col BOOL NOT NULL, +) PRIMARY KEY(id); + CREATE TABLE IF NOT EXISTS year_pk_table ( id INT64 NOT NULL, year_pk_col INT64 NOT NULL,