diff --git a/src/main/java/com/starrocks/connector/flink/catalog/StarRocksCatalog.java b/src/main/java/com/starrocks/connector/flink/catalog/StarRocksCatalog.java index 3cdbc88e..ce76cf8c 100644 --- a/src/main/java/com/starrocks/connector/flink/catalog/StarRocksCatalog.java +++ b/src/main/java/com/starrocks/connector/flink/catalog/StarRocksCatalog.java @@ -140,11 +140,17 @@ public Optional getTable(String databaseName, String tableName) while (resultSet.next()) { String name = resultSet.getString("COLUMN_NAME"); String type = resultSet.getString("DATA_TYPE"); - int position = resultSet.getInt("ORDINAL_POSITION"); Integer size = resultSet.getInt("COLUMN_SIZE"); if (resultSet.wasNull()) { size = null; } + // mysql does not have boolean type, and starrocks `information_schema`.`COLUMNS` will return + // a "tinyint" data type for both StarRocks BOOLEAN and TINYINT type, Distinguish them by + // column size, and the size of BOOLEAN is null + if ("tinyint".equalsIgnoreCase(type) && size == null) { + type = "boolean"; + } + int position = resultSet.getInt("ORDINAL_POSITION"); Integer scale = resultSet.getInt("DECIMAL_DIGITS"); if (resultSet.wasNull()) { scale = null; diff --git a/src/main/java/com/starrocks/connector/flink/catalog/StarRocksTable.java b/src/main/java/com/starrocks/connector/flink/catalog/StarRocksTable.java index aa81a1d5..39dba333 100644 --- a/src/main/java/com/starrocks/connector/flink/catalog/StarRocksTable.java +++ b/src/main/java/com/starrocks/connector/flink/catalog/StarRocksTable.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; @@ -172,10 +173,29 @@ public String toString() { ", numBuckets=" + numBuckets + ", comment='" + comment + '\'' + ", properties=" + properties + - ", columnMap=" + columnMap + '}'; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StarRocksTable that = (StarRocksTable) o; + return Objects.equals(databaseName, that.databaseName) && + Objects.equals(tableName, that.tableName) && + tableType == that.tableType && + Objects.equals(columns, that.columns) && + Objects.equals(tableKeys, that.tableKeys) && + Objects.equals(distributionKeys, that.distributionKeys) && + Objects.equals(numBuckets, that.numBuckets) && + Objects.equals(comment, that.comment) && + Objects.equals(properties, that.properties); + } + /** Build a {@link StarRocksTable}. */ public static class Builder { @@ -219,7 +239,7 @@ public Builder setDistributionKeys(List distributionKeys) { return this; } - public Builder setNumBuckets(int numBuckets) { + public Builder setNumBuckets(Integer numBuckets) { this.numBuckets = numBuckets; return this; }