Copilot commented on code in PR #9452:
URL: https://github.com/apache/seatunnel/pull/9452#discussion_r2153730446


##########
seatunnel-connectors-v2/connector-paimon/src/test/java/org/apache/seatunnel/connectors/seatunnel/paimon/utils/RowConverterTest.java:
##########
@@ -335,4 +336,34 @@ public void paimonToSeaTunnel() {
                 RowConverter.convert(internalRow, seaTunnelRowType, 
getTableSchema(10, 10));
         Assertions.assertEquals(convert, seaTunnelRow);
     }
+
+    @Test
+    public void decimalToPaimon() {
+        SeaTunnelRowType sourceType =
+                new SeaTunnelRowType(
+                        new String[] {"f0"}, new SeaTunnelDataType[] {new 
DecimalType(4, 1)});
+        TableSchema sinkSchema =
+                new TableSchema(
+                        0,
+                        TableSchema.newFields(RowType.of(DataTypes.DECIMAL(4, 
2))),
+                        1,
+                        Collections.EMPTY_LIST,
+                        KEY_NAME_LIST,
+                        Collections.EMPTY_MAP,
+                        "");
+        SeaTunnelRow data = new SeaTunnelRow(new Object[] {new 
BigDecimal("123.4")});
+
+        Assertions.assertThrowsExactly(
+                PaimonConnectorException.class,
+                () -> {
+                    try {
+                        RowConverter.reconvert(data, sourceType, sinkSchema);
+                    } catch (Exception e) {
+                        Assertions.assertEquals(
+                                "ErrorCode:[PAIMON-11], 
ErrorDescription:[deciaml type precision is incompatible. ] - `f0` field value 
is: 123.4, except filed schema of sink is `f0` DECIMAL(4, 1), but the filed in 
sink table which actual schema is `f0` DECIMAL(4, 2).Please check schema of 
sink table.",

Review Comment:
   Typographical errors found in the error message; consider correcting 
'deciaml' to 'decimal' and 'filed' to 'field'.
   ```suggestion
                                   "ErrorCode:[PAIMON-11], 
ErrorDescription:[decimal type precision is incompatible. ] - `f0` field value 
is: 123.4, except field schema of sink is `f0` DECIMAL(4, 1), but the field in 
sink table which actual schema is `f0` DECIMAL(4, 2).Please check schema of 
sink table.",
   ```



##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/utils/RowConverter.java:
##########
@@ -521,11 +523,25 @@ private static void checkCanWriteWithSchema(
             if (sinkDecimalType.getPrecision() < 
sourceDecimalType.getPrecision()
                     || sinkDecimalType.getScale() < 
sourceDecimalType.getScale()) {
                 throw CommonError.writeRowErrorWithSchemaIncompatibleSchema(
-                        "Paimon",
+                        PaimonBaseOptions.CONNECTOR_IDENTITY,
                         sourceFieldName + StringUtils.SPACE + 
sourceFieldType.getSqlType(),
                         exceptDataField.asSQLString(),
                         sinkDataField.asSQLString());
             }
+            BigDecimal bd =
+                    ((BigDecimal) fieldValue)
+                            .setScale(sinkDecimalType.getScale(), 
RoundingMode.HALF_UP);
+            if (bd.precision() > sinkDecimalType.getPrecision()) {
+                String message =
+                        String.format(
+                                "`%s` field value is: %s, except filed schema 
of sink is %s, but the filed in sink table which actual schema is %s.Please 
check schema of sink table.",

Review Comment:
   The error message string constructed here contains typos ('deciaml' should 
be 'decimal' and 'filed' should be 'field'). Consider updating the string 
format for clarity.
   ```suggestion
                                   "`%s` field value is: %s, except field 
schema of sink is %s, but the field in sink table with actual schema is %s. 
Please check the schema of the sink table.",
   ```



##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/exception/PaimonConnectorErrorCode.java:
##########
@@ -29,7 +29,10 @@ public enum PaimonConnectorErrorCode implements 
SeaTunnelErrorCode {
     LOAD_CATALOG("PAIMON-06", "Load catalog failed"),
     GET_FILED_FAILED("PAIMON-07", "Get field failed"),
     UNSUPPORTED_PRIMARY_DATATYPE("PAIMON-08", "Paimon primary key datatype is 
unsupported"),
-    WRITE_PROPS_BUCKET_KEY_ERROR("PAIMON-09", "Cannot define 'bucket-key' in 
dynamic bucket mode");
+    WRITE_PROPS_BUCKET_KEY_ERROR("PAIMON-09", "Cannot define 'bucket-key' in 
dynamic bucket mode"),
+    NON_PRIMARY_KEY_CHECK_ERROR(
+            "PAIMON-10", "Primary keys should be empty when nonPrimaryKey is 
true"),
+    DECIMAL_PRECISION_INCOMPATIBLE("PAIMON-11", "deciaml type precision is 
incompatible. ");

Review Comment:
   Consider correcting the typo in the error description: 'deciaml' should be 
'decimal'.
   ```suggestion
       DECIMAL_PRECISION_INCOMPATIBLE("PAIMON-11", "decimal type precision is 
incompatible. ");
   ```



-- 
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]

Reply via email to