healchow commented on code in PR #8338:
URL: https://github.com/apache/inlong/pull/8338#discussion_r1244978650
##########
inlong-sort/sort-flink/base/src/main/java/org/apache/inlong/sort/base/format/JsonDynamicSchemaFormat.java:
##########
@@ -336,6 +358,45 @@ protected RowType extractSchemaNode(JsonNode schema,
List<String> pkNames) {
return new RowType(fields);
}
+ /**
+ * set precision and scale for decimal and other types
+ *
+ * @param type original flink type
+ * @param dialectType database dialect type
+ * @return flink type revised according to dialect type
+ */
+ public LogicalType handleDialectSqlType(LogicalType type, String
dialectType) {
+ if (StringUtils.isBlank(dialectType)) {
+ return type;
+ }
+ if (type instanceof DecimalType) {
+ Matcher matcher = DIALECT_SQL_TYPE_PATTERN.matcher(dialectType);
+ int precision;
+ int scale;
+ DecimalType decimalType = new
DecimalType(DecimalType.MAX_PRECISION);
+ if (matcher.matches()) {
+ String[] items = matcher.group(1).split(",");
+ precision = Integer.parseInt(items[0].trim());
+ if (precision < DecimalType.MIN_PRECISION || precision >
DecimalType.MAX_PRECISION) {
+ LOG.info("Decimal has invalid precision {}", precision);
Review Comment:
```suggestion
LOG.info("invalid decimal precision: {}, change to: {}",
precision, decimalType.getPrecision());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]