@@ -1521,14 +1521,14 @@ public CompletableFuture<InsertResponse> insert(String tableName,
1521
1521
* Does an insert request to a server. Data is pushed when a {@link DataStreamWriter#onOutput(OutputStream)} is called.
1522
1522
*
1523
1523
* @param tableName - target table name
1524
- * @param columns - list of column names to insert data into. If null or empty, all columns will be used.
1524
+ * @param columnNames - list of column names to insert data into. If null or empty, all columns will be used.
1525
1525
* @param writer - {@link DataStreamWriter} implementation
1526
1526
* @param format - source format
1527
1527
* @param settings - operation settings
1528
1528
* @return {@code CompletableFuture<InsertResponse>} - a promise to insert response
1529
1529
*/
1530
1530
public CompletableFuture <InsertResponse > insert (String tableName ,
1531
- List <String > columns ,
1531
+ List <String > columnNames ,
1532
1532
DataStreamWriter writer ,
1533
1533
ClickHouseFormat format ,
1534
1534
InsertSettings settings ) {
@@ -1559,20 +1559,17 @@ public CompletableFuture<InsertResponse> insert(String tableName,
1559
1559
settings .setOption (ClientConfigProperties .INPUT_OUTPUT_FORMAT .getKey (), format .name ());
1560
1560
final InsertSettings finalSettings = settings ;
1561
1561
1562
- StringBuilder columnString = new StringBuilder ();
1563
- if (columns != null && !columns .isEmpty ()) {
1564
- columnString .append ("(" );
1565
- for (int i = 0 ; i < columns .size (); i ++) {
1566
- columnString .append (columns .get (i ));
1567
- if (i < columns .size () - 1 ) {
1568
- columnString .append (", " );
1569
- }
1562
+ StringBuilder sqlStmt = new StringBuilder ("INSERT INTO " ).append (tableName );
1563
+ if (columnNames != null && !columnNames .isEmpty ()) {
1564
+ sqlStmt .append (" (" );
1565
+ for (String columnName : columnNames ) {
1566
+ sqlStmt .append (columnName ).append (", " );
1570
1567
}
1571
- columnString .append (")" );
1568
+ sqlStmt .deleteCharAt (sqlStmt .length () - 2 );
1569
+ sqlStmt .append (")" );
1572
1570
}
1573
-
1574
- final String sqlStmt = String .format ("INSERT INTO %s %s FORMAT %s" , tableName , columnString , format .name ());
1575
- finalSettings .serverSetting (ClickHouseHttpProto .QPARAM_QUERY_STMT , sqlStmt );
1571
+ sqlStmt .append (" FORMAT " ).append (format .name ());
1572
+ finalSettings .serverSetting (ClickHouseHttpProto .QPARAM_QUERY_STMT , sqlStmt .toString ());
1576
1573
responseSupplier = () -> {
1577
1574
long startTime = System .nanoTime ();
1578
1575
// Selecting some node
0 commit comments