feat(sync): 增加int unsigned类型转换为long
This commit is contained in:
@@ -49,7 +49,7 @@ public class TypeConverterV2 implements TypeConverter {
|
||||
private static final Logger logger = LoggerFactory.getLogger(TypeConverterV2.class);
|
||||
private static final Pattern BOOLEAN_REGEX = Pattern.compile("^boolean|bool$");
|
||||
private static final Pattern INT_REGEX = Pattern.compile("^(tinyint|smallint|int|smallserial|integer)(\\(\\d+\\))?$");
|
||||
private static final Pattern LONG_REGEX = Pattern.compile("^(bigint unsigned)|((bigint|serial|long)(\\(\\d+\\))?)$");
|
||||
private static final Pattern LONG_REGEX = Pattern.compile("^((int|bigint) unsigned)|((bigint|serial|long)(\\(\\d+\\))?)$");
|
||||
private static final Pattern DATE_REGEX = Pattern.compile("^date|timestamp|timestamp without time zone|datetime|time$");
|
||||
private static final Pattern FLOAT_REGEX = Pattern.compile("^float(\\(\\d+\\))?$");
|
||||
private static final Pattern DOUBLE_REGEX = Pattern.compile("^double(\\(\\d+\\))?$");
|
||||
@@ -67,7 +67,7 @@ public class TypeConverterV2 implements TypeConverter {
|
||||
fields.add(new Field(Constants.UNION_KEY_NAME, STRING_SCHEMA, null, ""));
|
||||
|
||||
for (TableMeta.FieldMeta field : meta.getFields()) {
|
||||
fields.add(new Field(field.getName(), convertType(meta, field.getType(), field.getLength(), field.getScala()), null, JsonProperties.NULL_VALUE));
|
||||
fields.add(new Field(field.getName(), convertType(meta.getAlias(), field.getType(), field.getLength(), field.getScala()), null, JsonProperties.NULL_VALUE));
|
||||
}
|
||||
|
||||
fields.add(new Field(Constants.UPDATE_TIMESTAMP_KEY_NAME, LONG_SCHEMA, null, -1));
|
||||
@@ -75,7 +75,7 @@ public class TypeConverterV2 implements TypeConverter {
|
||||
return Schema.createRecord(meta.getTable(), null, null, false, fields);
|
||||
}
|
||||
|
||||
private Schema convertType(TableMeta meta, String type, Long length, Integer scala) {
|
||||
private Schema convertType(String table, String type, Long length, Integer scala) {
|
||||
type = type.trim().toLowerCase();
|
||||
if (BOOLEAN_REGEX.matcher(type).matches()) {
|
||||
return NULLABLE_BOOLEAN_SCHEMA;
|
||||
@@ -98,7 +98,7 @@ public class TypeConverterV2 implements TypeConverter {
|
||||
return NULLABLE_DECIMAL_SCHEMA.apply(length.intValue(), scala);
|
||||
}
|
||||
} else {
|
||||
LogHelper.warn(logger, LogHelper.LogPoint.FIELD_TYPE_NOT_FOUND, "{} Cannot find correct type for source type: {} length: {} scala: {}", meta.getAlias(), type, length, scala);
|
||||
LogHelper.warn(logger, LogHelper.LogPoint.FIELD_TYPE_NOT_FOUND, "{} Cannot find correct type for source type: {} length: {} scala: {}", table, type, length, scala);
|
||||
return NULLABLE_STRING_SCHEMA;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user