jarredhj0214 commented on code in PR #13548:
URL: https://github.com/apache/gravitino/pull/13548#discussion_r4228927381
##########
catalogs/catalog-jdbc-mysql/src/main/java/org/apache/gravitino/catalog/mysql/converter/MysqlTypeConverter.java:
##########
@@ -166,4 +168,19 @@ public String fromGravitino(Type type) {
throw new IllegalArgumentException(
String.format("Couldn't convert Gravitino type %s to MySQL type",
type.simpleString()));
}
+
+ private static Type toGravitinoDecimal(JdbcTypeBean typeBean) {
+ int precision = typeBean.getColumnSize();
+ int scale = typeBean.getScale();
+ if (precision <= MAX_DECIMAL_PRECISION) {
+ return Types.DecimalType.of(precision, scale);
+ }
+
+ // MySQL supports precision up to 65, while Gravitino DecimalType is
limited to 38.
+ // Preserve larger decimals as ExternalType so loading the table does not
fail.
+ String unsignedSuffix =
+ DECIMAL_UNSIGNED.equalsIgnoreCase(typeBean.getTypeName()) ? "
unsigned" : "";
Review Comment:
To preserve UNSIGNED for precision <= 38 as well, the smallest converter
change would be to map all DECIMAL UNSIGNED columns to ExternalType. However,
that changes the existing native decimal mapping, and downstream connectors may
then expose these columns as strings (for example, SparkJdbcTypeConverter maps
ExternalType to StringType), affecting decimal expressions and compatibility.
Keeping native decimal semantics while preserving UNSIGNED would require
extending DecimalType with unsigned support and updating the relevant
serialization, clients, and connector mappings, which is a broader change.
I suggest keeping this PR focused on loading decimals with precision > 38
and handling unsigned metadata preservation separately, with downstream
compatibility considered explicitly.
--
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]