Skip to content

feat: re-format the query-id #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void testConnectionRefused() {
@Test(groups = {"it"})
public void testBasicQueryIDHeader() {
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(OkHttpUtils.basicAuthInterceptor("databend", "databend")).build();
String expectedUUID = UUID.randomUUID().toString();
String expectedUUID = UUID.randomUUID().toString().replace("-","");
AtomicReference<String> lastNodeID = new AtomicReference<>();

Map<String, String> additionalHeaders = new HashMap<>();
Expand All @@ -85,7 +85,7 @@ public void testBasicQueryIDHeader() {
DatabendClient cli = new DatabendClientV1(client, "select 1", settings, null, lastNodeID);
Assert.assertEquals(cli.getAdditionalHeaders().get(X_Databend_Query_ID), expectedUUID);

String expectedUUID1 = UUID.randomUUID().toString();
String expectedUUID1 = UUID.randomUUID().toString().replace("-", "");
Map<String, String> additionalHeaders1 = new HashMap<>();
additionalHeaders1.put(X_Databend_Query_ID, expectedUUID1);
ClientSettings settings1 = new ClientSettings(DATABEND_HOST, DatabendSession.createDefault(), DEFAULT_QUERY_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT, DEFAULT_SOCKET_TIMEOUT, PaginationOptions.defaultPaginationOptions(), additionalHeaders1, null, DEFAULT_RETRY_ATTEMPTS);
Expand All @@ -104,7 +104,7 @@ public void testBasicQueryIDHeader() {
@Test(groups = {"it"})
public void testDiscoverNodes() {
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(OkHttpUtils.basicAuthInterceptor("databend", "databend")).build();
String expectedUUID = UUID.randomUUID().toString();
String expectedUUID = UUID.randomUUID().toString().replace("-", "");

Map<String, String> additionalHeaders = new HashMap<>();
additionalHeaders.put(X_Databend_Query_ID, expectedUUID);
Expand All @@ -119,7 +119,7 @@ public void testDiscoverNodes() {
@Test(groups = {"it"})
public void testDiscoverNodesUnSupported() {
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(OkHttpUtils.basicAuthInterceptor("databend", "databend")).build();
String expectedUUID = UUID.randomUUID().toString();
String expectedUUID = UUID.randomUUID().toString().replace("-", "");

Map<String, String> additionalHeaders = new HashMap<>();
additionalHeaders.put(X_Databend_Query_ID, expectedUUID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ DatabendClient startQueryWithFailover(String sql, StageAttachment attach) throws

for (int attempt = 0; attempt <= maxRetries; attempt++) {
try {
String queryId = UUID.randomUUID().toString();
String queryId = UUID.randomUUID().toString().replace("-", "");;
String candidateHost = selectHostForQuery(queryId);

// configure the client settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private DatabendCopyParams uploadBatchesForCopyInto() throws SQLException {
File saved = batchInsertUtils.get().saveBatchToCSV(batchValues);
try (FileInputStream fis = new FileInputStream(saved);) {
DatabendConnection c = (DatabendConnection) getConnection();
String uuid = UUID.randomUUID().toString();
String uuid = UUID.randomUUID().toString().replace("-", "");
// format %Y/%m/%d/%H/%M/%S/fileName.csv
String stagePrefix = String.format("%s/%s/%s/%s/%s/%s/%s/",
LocalDateTime.now().getYear(),
Expand Down Expand Up @@ -205,7 +205,7 @@ private StageAttachment uploadBatches() throws SQLException {
File saved = batchInsertUtils.get().saveBatchToCSV(batchValues);
try (FileInputStream fis = new FileInputStream(saved);) {
DatabendConnection c = (DatabendConnection) getConnection();
String uuid = UUID.randomUUID().toString();
String uuid = UUID.randomUUID().toString().replace("-", "");
// format %Y/%m/%d/%H/%M/%S/fileName.csv
String stagePrefix = String.format("%s/%s/%s/%s/%s/%s/%s/",
LocalDateTime.now().getYear(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class StatementInfoWrapper {
* @return the statement that will be sent to the server
*/
public static StatementInfoWrapper of(@NonNull RawStatement rawStatement) {
return of(rawStatement, UUID.randomUUID().toString());
return of(rawStatement, UUID.randomUUID().toString().replace("-", ""));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public List<StatementInfoWrapper> replaceParameterMarksWithValues(@NonNull Map<I
Pair<String, String> additionalParams = subQuery.getStatementType() == StatementType.PARAM_SETTING
? ((SetParamRawStatement) subQuery).getAdditionalProperty()
: null;
subQueries.add(new StatementInfoWrapper(subQueryWithParams, UUID.randomUUID().toString(),
subQueries.add(new StatementInfoWrapper(subQueryWithParams, UUID.randomUUID().toString().replace("-", ""),
subQuery.getStatementType(), additionalParams, subQuery));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public String[] getValues() {

public File saveBatchToCSV(List<String[]> values) {
// get a temporary directory
String id = UUID.randomUUID().toString();
String id = UUID.randomUUID().toString().replace("-","");
File tempDir = new File(System.getProperty("java.io.tmpdir"));
File tempFile = new File(tempDir, "databend_batch_insert_" + id + ".csv");
return saveBatchToCSV(values, tempFile);
Expand Down