ClickHouse / ClickHouse/clickhouse-java

User Agent is not being added properly to all queries

Ouverte
#2,622 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
bug client-api-v2
Langage dominant
Java
Étoiles
1.6k
Forks
636
Merge moyen
2 j 23 h
PR mergées (30 j)
29

Description

## Description

### Steps to reproduce
1. Create the following table:
```sql
CREATE TABLE default.example_table
(
`id` Int32,
`name` String
)
ENGINE = MergeTree
ORDER BY id
SETTINGS index_granularity = 8192
```
2. Run the following JDBC code:

```java
package com.google.cloud.teleport.v2;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class JDBCMain {
private static final Logger log = LoggerFactory.getLogger(JDBCMain.class);
static final String TABLE_NAME = "default.example_table";

public static void main(String[] args) throws Exception {
String url = System.getProperty("chUrl", "jdbc:ch://localhost:8123?client_name=thisisatest");

// Set user and password if needed
Properties properties = new Properties();
properties.setProperty("user", System.getProperty("chUser", "default"));
properties.setProperty("password", System.getProperty("chPassword", "123456"));

printInsertedData(url, properties);

}

static void printInsertedData(String url, Properties properties) throws SQLException {
try (Connection conn = DriverManager.getConnection(url, properties)) {//Grab a connection using the jdbc DriverManager
try (Statement stmt = conn.createStatement()) {
try (ResultSet rs = stmt.executeQuery("SELECT * FROM " + TABLE_NAME)) {
while (rs.next()) {
//Print the values of the current row
log.info(rs.getString(1));
log.info(rs.getString(2));
}
}
}
}
}

}
```

### Error Log or Exception StackTrace

When querying the `query_log` table, we get the following data. The full result is attached as a CSV.

Image

I verified that all these queries are related to the same "batch".

[jdbc_user_agent_issue.csv](https://github.com/user-attachments/files/23096043/jdbc_user_agent_issue.csv)

### Expected Behaviour

The `client_name` should be applied to all related queries, including internal queries being fired by the client.

#### Client Configuration

Added as a connection string in the example above.

#### Environment
* Client version: 0.9.2

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la configuration de la connexion JDBCMain et reproduisez le SELECT tout en inspectant query_log et le CSV joint. Suivez la propagation de client_name vers les requêtes principales et internes ; le travail est terminé lorsque chaque requête du même batch porte le client_name configuré. Aucun fichier du repository ni aucun test n’est nommé dans l’issue.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java, sql
Domaine
backend, databases
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
42/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.