Skip to content

Commit 286768d

Browse files
committed
fix: explain analyze IT test should not run in TableCluster mode
1 parent c144fff commit 286768d

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTExplainAnalyzeIT.java

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import org.apache.iotdb.it.env.EnvFactory;
2525
import org.apache.iotdb.it.framework.IoTDBTestRunner;
26-
import org.apache.iotdb.itbase.category.TableClusterIT;
2726
import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
2827
import org.apache.iotdb.itbase.env.BaseEnv;
2928

@@ -50,21 +49,21 @@
5049
import static org.junit.Assert.fail;
5150

5251
@RunWith(IoTDBTestRunner.class)
53-
@Category({TableLocalStandaloneIT.class, TableClusterIT.class})
52+
@Category({TableLocalStandaloneIT.class})
5453
public class IoTExplainAnalyzeIT {
5554
private static final String DATABASE_NAME = "testdb";
5655

5756
private static final String[] creationSqls =
5857
new String[] {
59-
"CREATE DATABASE IF NOT EXISTS testdb",
60-
"USE testdb",
58+
"CREATE DATABASE IF NOT EXISTS " + DATABASE_NAME,
59+
"USE " + DATABASE_NAME,
6160
"CREATE TABLE IF NOT EXISTS testtb(deviceid STRING TAG, voltage FLOAT FIELD)",
6261
"INSERT INTO testtb VALUES(1000, 'd1', 100.0)",
6362
"INSERT INTO testtb VALUES(2000, 'd1', 200.0)",
6463
"INSERT INTO testtb VALUES(1000, 'd2', 300.0)",
6564
};
6665

67-
private static final String dropDbSqls = "DROP DATABASE IF EXISTS testdb";
66+
private static final String dropDbSqls = "DROP DATABASE IF EXISTS " + DATABASE_NAME;
6867

6968
@BeforeClass
7069
public static void setUpClass() {
@@ -100,20 +99,22 @@ public void tearDown() {
10099
}
101100

102101
@Test
103-
public void testEmptyCteQuery() throws SQLException {
104-
ResultSet resultSet = null;
102+
public void testEmptyCteQuery() {
105103
String sql =
106104
"explain analyze with cte1 as materialized (select * from testtb1) select * from testtb, cte1 where testtb.deviceid = cte1.deviceid";
107105
try (Connection conn = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
108106
Statement statement = conn.createStatement()) {
109-
statement.execute("Use testdb");
107+
statement.execute("Use " + DATABASE_NAME);
110108
statement.execute(
111109
"CREATE TABLE IF NOT EXISTS testtb1(deviceid STRING TAG, voltage FLOAT FIELD)");
112-
resultSet = statement.executeQuery(sql);
110+
ResultSet resultSet = statement.executeQuery(sql);
113111
StringBuilder sb = new StringBuilder();
114112
while (resultSet.next()) {
113+
System.out.println(resultSet.getString(1));
115114
sb.append(resultSet.getString(1)).append(System.lineSeparator());
116115
}
116+
resultSet.close();
117+
117118
String result = sb.toString();
118119
Assert.assertFalse(
119120
"Explain Analyze should not contain ExplainAnalyze node.",
@@ -125,33 +126,32 @@ public void testEmptyCteQuery() throws SQLException {
125126
Assert.assertEquals("", lines[1]);
126127
Assert.assertEquals("Main Query", lines[2]);
127128
statement.execute("DROP TABLE testtb1");
128-
} finally {
129-
if (resultSet != null) {
130-
resultSet.close();
131-
}
129+
130+
} catch (SQLException e) {
131+
fail(e.getMessage());
132132
}
133133
}
134134

135135
@Test
136-
public void testCteQueryExceedsThreshold() throws SQLException {
137-
ResultSet resultSet = null;
136+
public void testCteQueryExceedsThreshold() {
138137
String sql =
139138
"explain analyze with cte1 as materialized (select * from testtb2) select * from testtb where testtb.deviceid in (select deviceid from cte1)";
140139
try (Connection conn = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
141140
Statement statement = conn.createStatement()) {
142-
statement.execute("Use testdb");
141+
statement.execute("Use " + DATABASE_NAME);
143142
statement.execute(
144143
"CREATE TABLE IF NOT EXISTS testtb2(deviceid STRING TAG, voltage FLOAT FIELD)");
145144
for (int i = 0; i < 100; i++) {
146145
statement.addBatch(
147146
String.format("insert into testtb2(deviceid, voltage) values('d%d', %d)", i, i));
148147
}
149148
statement.executeBatch();
150-
resultSet = statement.executeQuery(sql);
149+
ResultSet resultSet = statement.executeQuery(sql);
151150
StringBuilder sb = new StringBuilder();
152151
while (resultSet.next()) {
153152
sb.append(resultSet.getString(1)).append(System.lineSeparator());
154153
}
154+
resultSet.close();
155155

156156
String result = sb.toString();
157157
Assert.assertFalse(
@@ -180,33 +180,31 @@ public void testCteQueryExceedsThreshold() throws SQLException {
180180
}
181181

182182
statement.execute("DROP TABLE testtb2");
183-
} finally {
184-
if (resultSet != null) {
185-
resultSet.close();
186-
}
183+
} catch (SQLException e) {
184+
fail(e.getMessage());
187185
}
188186
}
189187

190188
@Test
191-
public void testCteQuerySuccess() throws SQLException {
192-
ResultSet resultSet = null;
189+
public void testCteQuerySuccess() {
193190
String sql =
194191
"explain analyze with cte1 as materialized (select * from testtb3) select * from testtb where testtb.deviceid in (select deviceid from cte1)";
195192
try (Connection conn = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
196193
Statement statement = conn.createStatement()) {
197-
statement.execute("Use testdb");
194+
statement.execute("Use " + DATABASE_NAME);
198195
statement.execute(
199196
"CREATE TABLE IF NOT EXISTS testtb3(deviceid STRING TAG, voltage FLOAT FIELD)");
200197
for (int i = 0; i < 50; i++) {
201198
statement.addBatch(
202199
String.format("insert into testtb3(deviceid, voltage) values('d%d', %d)", i, i));
203200
}
204201
statement.executeBatch();
205-
resultSet = statement.executeQuery(sql);
202+
ResultSet resultSet = statement.executeQuery(sql);
206203
StringBuilder sb = new StringBuilder();
207204
while (resultSet.next()) {
208205
sb.append(resultSet.getString(1)).append(System.lineSeparator());
209206
}
207+
resultSet.close();
210208

211209
String result = sb.toString();
212210
Assert.assertTrue(
@@ -232,10 +230,8 @@ public void testCteQuerySuccess() throws SQLException {
232230
}
233231

234232
statement.execute("DROP TABLE testtb3");
235-
} finally {
236-
if (resultSet != null) {
237-
resultSet.close();
238-
}
233+
} catch (SQLException e) {
234+
fail(e.getMessage());
239235
}
240236
}
241237

0 commit comments

Comments
 (0)