@@ -317,6 +317,33 @@ public void testLogComment(String logComment) throws Exception {
317317 Assert .assertEquals (logRecords .get (0 ).getString ("log_comment" ), logComment == null ? "" : logComment );
318318 }
319319
320+ @ Test (groups = { "integration" })
321+ public void testInsertSettingsDeduplicationToken () throws Exception {
322+ final String tableName = "insert_settings_database_test" ;
323+ final String createTableSQL = "CREATE TABLE " + tableName + " ( A Int64 ) ENGINE = MergeTree ORDER BY A SETTINGS " +
324+ "non_replicated_deduplication_window = 100" ;
325+ final String deduplicationToken = RandomStringUtils .randomAlphabetic (36 );
326+
327+ dropTable (tableName );
328+ createTable (createTableSQL );
329+
330+ InsertSettings insertSettings = settings .setInputStreamCopyBufferSize (8198 * 2 )
331+ .setDeduplicationToken (deduplicationToken );
332+
333+ for (int i = 0 ; i < 3 ; ++i ) {
334+ ByteArrayOutputStream data = new ByteArrayOutputStream ();
335+ PrintWriter writer = new PrintWriter (data );
336+ writer .printf ("%d\n " , i );
337+ writer .flush ();
338+ InsertResponse response = client .insert (tableName , new ByteArrayInputStream (data .toByteArray ()), ClickHouseFormat .TSV , insertSettings )
339+ .get (30 , TimeUnit .SECONDS );
340+ response .close ();
341+ }
342+
343+ List <GenericRecord > records = client .queryAll ("SELECT * FROM " + tableName );
344+ assertEquals (records .size (), 1 );
345+ }
346+
320347 @ DataProvider ( name = "logCommentDataProvider" )
321348 public static Object [] logCommentDataProvider () {
322349 return new Object [][] {
0 commit comments