Skip to content

Commit

Permalink
Merge pull request #1895 from ClickHouse/fix-insert-settings
Browse files Browse the repository at this point in the history
[client-v2] tweak the setting
  • Loading branch information
Paultagoras authored Oct 30, 2024
2 parents e1e7416 + 8b25d63 commit 714dcf8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Map<String, Object> getAllSettings() {
* @return
*/
public InsertSettings setDeduplicationToken(String token) {
rawSettings.put("insert_deduplication_token", token);
serverSetting("insert_deduplication_token", token);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,33 @@ public void testLogComment(String logComment) throws Exception {
Assert.assertEquals(logRecords.get(0).getString("log_comment"), logComment == null ? "" : logComment);
}

@Test(groups = { "integration" })
public void testInsertSettingsDeduplicationToken() throws Exception {
final String tableName = "insert_settings_database_test";
final String createTableSQL = "CREATE TABLE " + tableName + " ( A Int64 ) ENGINE = MergeTree ORDER BY A SETTINGS " +
"non_replicated_deduplication_window = 100";
final String deduplicationToken = RandomStringUtils.randomAlphabetic(36);

dropTable(tableName);
createTable(createTableSQL);

InsertSettings insertSettings = settings.setInputStreamCopyBufferSize(8198 * 2)
.setDeduplicationToken(deduplicationToken);

for (int i = 0; i < 3; ++i) {
ByteArrayOutputStream data = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(data);
writer.printf("%d\n", i);
writer.flush();
InsertResponse response = client.insert(tableName, new ByteArrayInputStream(data.toByteArray()), ClickHouseFormat.TSV, insertSettings)
.get(30, TimeUnit.SECONDS);
response.close();
}

List<GenericRecord> records = client.queryAll("SELECT * FROM " + tableName);
assertEquals(records.size(), 1);
}

@DataProvider( name = "logCommentDataProvider")
public static Object[] logCommentDataProvider() {
return new Object[][] {
Expand Down

0 comments on commit 714dcf8

Please sign in to comment.