Hisoka-X commented on code in PR #9452:
URL: https://github.com/apache/seatunnel/pull/9452#discussion_r2153519915
##########
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:
Can we convert the precision of data dynamically before insert it?
--
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]