wombatu-kun commented on code in PR #16606:
URL: https://github.com/apache/iceberg/pull/16606#discussion_r3691342886


##########
kafka-connect/kafka-connect/src/test/java/org/apache/iceberg/connect/data/TestSinkWriter.java:
##########
@@ -235,6 +237,26 @@ public void testDynamicNoRoute() {
     assertThat(writerResults).hasSize(0);
   }
 
+  @Test
+  public void testEvolveAddsFractionalDecimalColumn() {
+    IcebergSinkConfig config = mock(IcebergSinkConfig.class);
+    when(config.tableConfig(any())).thenReturn(mock(TableSinkConfig.class));
+    
when(config.tables()).thenReturn(ImmutableList.of(TABLE_IDENTIFIER.toString()));
+    when(config.evolveSchemaEnabled()).thenReturn(true);
+
+    // a new column whose value is a fractional decimal < 1: 
BigDecimal("0.001") has precision 1
+    // and scale 3, so before the fix the column evolves to a malformed 
decimal(1, 3) and the
+    // write below fails; after the fix it evolves to decimal(3, 3) and the 
record is written.
+    Map<String, Object> value = ImmutableMap.of("amount", new 
BigDecimal("0.001"));
+
+    List<IcebergWriterResult> writerResults = sinkWriterTest(value, config);
+    assertThat(writerResults).isNotEmpty();
+
+    // the column evolved to a valid decimal that can hold 0.001 (scale <= 
precision)
+    Type added = 
catalog.loadTable(TABLE_IDENTIFIER).schema().findType("amount");

Review Comment:
   Done e081d1513



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to