yuxiqian commented on code in PR #3150:
URL: https://github.com/apache/flink-cdc/pull/3150#discussion_r1547462148


##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-starrocks/src/test/java/org/apache/flink/cdc/connectors/starrocks/sink/CdcDataTypeTransformerTest.java:
##########
@@ -75,6 +76,68 @@ public void testCharTypeForPrimaryKey() {
         assertTrue(smallLengthColumn.isNullable());
     }
 
+    @Test
+    public void testDecimalForPrimaryKey() {
+        // map to Int of StarRocks if primary key column with precision < 10 
and scale = 0
+        StarRocksColumn.Builder intLengthBuilder =
+                new 
StarRocksColumn.Builder().setColumnName("primary_key").setOrdinalPosition(0);
+        new DecimalType(9, 0)
+                .accept(new StarRocksUtils.CdcDataTypeTransformer(true, 
intLengthBuilder));
+        StarRocksColumn intLengthColumn = intLengthBuilder.build();
+        assertEquals("primary_key", intLengthColumn.getColumnName());
+        assertEquals(0, intLengthColumn.getOrdinalPosition());
+        assertEquals(StarRocksUtils.INT, intLengthColumn.getDataType());
+        assertTrue(intLengthColumn.isNullable());
+
+        // map to BigInt of StarRocks if primary key column with precision < 
19 and scale = 0
+        StarRocksColumn.Builder bigIntLengthBuilder =
+                new 
StarRocksColumn.Builder().setColumnName("primary_key").setOrdinalPosition(0);
+        new DecimalType(10, 0)
+                .accept(new StarRocksUtils.CdcDataTypeTransformer(true, 
bigIntLengthBuilder));
+        StarRocksColumn bigIntLengthColumn = bigIntLengthBuilder.build();
+        assertEquals("primary_key", bigIntLengthColumn.getColumnName());
+        assertEquals(0, bigIntLengthColumn.getOrdinalPosition());
+        assertEquals(StarRocksUtils.BIGINT, bigIntLengthColumn.getDataType());
+        assertTrue(bigIntLengthColumn.isNullable());
+
+        // map to LARGEINT of StarRocks if primary key column with precision < 
18 and scale = 0
+        StarRocksColumn.Builder unsignedBigIntLengthBuilder =
+                new 
StarRocksColumn.Builder().setColumnName("primary_key").setOrdinalPosition(0);
+        new DecimalType(20, 0)

Review Comment:
   Maybe we can add test cases when `DecimalType` precision goes across 
specific boundaries like from 9 to 10, 18 to 19, and 37 to 38.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to