jarredhj0214 commented on code in PR #13548:
URL: https://github.com/apache/gravitino/pull/13548#discussion_r4228559695
##########
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:
Yes. For example, DECIMAL(10,2) UNSIGNED and DECIMAL(38,30) UNSIGNED have
getTypeName() = "DECIMAL UNSIGNED" and precision <= 38. They take the first
branch and map to DecimalType, preserving the converter's existing behavior.
DecimalType does not represent unsignedness; its precision/scale can represent
all values of these unsigned decimals, but the unsigned constraint is not
retained in the type metadata.
The unsigned suffix below is only needed for precision > 38, where
ExternalType preserves the MySQL type declaration. In 9de32128e I added an
explanatory comment, unsigned boundary unit coverage at precision 38/39
(precision 10 was already covered), and MySQL load IT cases for unsigned
precision 10/38/39.
spotlessApply and the MySQL module unit tests passed. The IT compiled, but
could not be executed locally because Docker is unavailable.
--
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]