|
1 | 1 | package com.clickhouse.benchmark.clients; |
2 | 2 |
|
3 | 3 | import com.clickhouse.benchmark.BenchmarkRunner; |
4 | | -import com.clickhouse.benchmark.TestEnvironment; |
5 | 4 | import com.clickhouse.benchmark.data.DataSet; |
6 | | -import com.clickhouse.benchmark.data.DataSets; |
7 | 5 | import com.clickhouse.benchmark.data.FileDataSet; |
8 | 6 | import com.clickhouse.benchmark.data.SimpleDataSet; |
9 | | -import com.clickhouse.client.BaseIntegrationTest; |
10 | 7 | import com.clickhouse.client.ClickHouseClient; |
11 | 8 | import com.clickhouse.client.ClickHouseCredentials; |
12 | 9 | import com.clickhouse.client.ClickHouseNode; |
|
40 | 37 | import static com.clickhouse.benchmark.BenchmarkRunner.getSelectCountQuery; |
41 | 38 | import static com.clickhouse.benchmark.BenchmarkRunner.getSyncQuery; |
42 | 39 | import static com.clickhouse.benchmark.TestEnvironment.DB_NAME; |
43 | | -import static com.clickhouse.benchmark.TestEnvironment.cleanupEnvironment; |
44 | 40 | import static com.clickhouse.benchmark.TestEnvironment.getPassword; |
45 | 41 | import static com.clickhouse.benchmark.TestEnvironment.getServer; |
46 | 42 | import static com.clickhouse.benchmark.TestEnvironment.getUsername; |
@@ -111,12 +107,11 @@ public static void initializeTables(DataState dataState) { |
111 | 107 | LOGGER.info("Initializing tables: {}, {}", dataState.tableNameFilled, dataState.tableNameEmpty); |
112 | 108 | LOGGER.debug("Create {}: {}", dataState.tableNameFilled, dataState.dataSet.getCreateTableString(dataState.tableNameFilled)); |
113 | 109 | LOGGER.debug("Create {}: {}", dataState.tableNameEmpty, dataState.dataSet.getCreateTableString(dataState.tableNameEmpty)); |
114 | | - //Truncate tables if they exist |
115 | | - truncateTable(dataState.tableNameEmpty); |
116 | | - truncateTable(dataState.tableNameFilled); |
117 | 110 | runAndSyncQuery(dataState.dataSet.getCreateTableString(dataState.tableNameEmpty), dataState.tableNameEmpty); |
118 | 111 | runAndSyncQuery(dataState.dataSet.getCreateTableString(dataState.tableNameFilled), dataState.tableNameFilled); |
119 | | - //A happy side effect of the above is that the tables are created if they don't exist, and if they do they are truncated + synced |
| 112 | + //Truncate tables if they existed |
| 113 | + truncateTable(dataState.tableNameEmpty); |
| 114 | + truncateTable(dataState.tableNameFilled); |
120 | 115 |
|
121 | 116 | ClickHouseFormat format = dataState.dataSet.getFormat(); |
122 | 117 | LOGGER.debug("Inserting data into table: {}, format: {}", dataState.tableNameFilled, format); |
@@ -153,6 +148,7 @@ public static void syncQuery(String tableName) { |
153 | 148 | } |
154 | 149 | } |
155 | 150 |
|
| 151 | + |
156 | 152 | public static void truncateTable(String tableName) { |
157 | 153 | LOGGER.info("Truncating table: {}", tableName); |
158 | 154 | runAndSyncQuery(String.format("TRUNCATE TABLE IF EXISTS `%s`.`%s`", DB_NAME, tableName), tableName); |
|
0 commit comments