Skip to content
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 @@ -38,8 +38,8 @@
import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.countTimeSeriesColumnHeaders;
import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.showChildNodesColumnHeaders;
import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.showChildPathsColumnHeaders;
import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.showDatabasesColumnHeaders;
import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.showDevicesColumnHeaders;
import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.showStorageGroupsColumnHeaders;
import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.showTTLColumnHeaders;
import static org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.showTimeSeriesColumnHeaders;
import static org.apache.iotdb.db.it.utils.TestUtils.assertNonQueryTestFail;
Expand Down Expand Up @@ -160,9 +160,7 @@ private void testReadSchema() {
// show/count databases
resultSetEqualTest(
"show databases",
showStorageGroupsColumnHeaders.stream()
.map(ColumnHeader::getColumnName)
.toArray(String[]::new),
showDatabasesColumnHeaders.stream().map(ColumnHeader::getColumnName).toArray(String[]::new),
new String[] {"root.test,1,1,0,604800000,"},
"test1",
"test123");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
import static org.junit.Assert.assertTrue;

@Category({LocalStandaloneIT.class, ClusterIT.class})
public class IoTDBDeleteStorageGroupIT extends AbstractSchemaIT {
public class IoTDBDeleteDatabaseIT extends AbstractSchemaIT {

public IoTDBDeleteStorageGroupIT(SchemaTestMode schemaTestMode) {
public IoTDBDeleteDatabaseIT(SchemaTestMode schemaTestMode) {
super(schemaTestMode);
}

Expand All @@ -65,7 +65,7 @@ public void tearDown() throws Exception {
}

@Test
public void testDeleteStorageGroup() throws Exception {
public void testDeleteDatabase() throws Exception {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE root.ln.wf01.wt01");
Expand All @@ -90,7 +90,7 @@ public void testDeleteStorageGroup() throws Exception {
}

@Test
public void testDeleteMultipleStorageGroupWithQuote() throws Exception {
public void testDeleteMultipleDatabasesWithQuote() throws Exception {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE root.ln1.wf01.wt01");
Expand All @@ -113,7 +113,7 @@ public void testDeleteMultipleStorageGroupWithQuote() throws Exception {
}

@Test(expected = SQLException.class)
public void deleteNonExistStorageGroup() throws Exception {
public void deleteNonExistDatabase() throws Exception {
try (final Connection connection = EnvFactory.getEnv().getConnection();
final Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE root.ln2.wf01.wt01");
Expand All @@ -122,7 +122,7 @@ public void deleteNonExistStorageGroup() throws Exception {
}

@Test
public void testDeleteStorageGroupWithStar() throws Exception {
public void testDeleteDatabaseWithStar() throws Exception {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE root.ln3.wf01.wt01");
Expand All @@ -145,7 +145,7 @@ public void testDeleteStorageGroupWithStar() throws Exception {
}

@Test
public void testDeleteAllStorageGroups() throws Exception {
public void testDeleteAllDatabases() throws Exception {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE root.ln4.wf01.wt01");
Expand All @@ -164,7 +164,7 @@ public void testDeleteAllStorageGroups() throws Exception {
}

@Test
public void testDeleteStorageGroupAndThenQuery() throws Exception {
public void testDeleteDatabaseAndThenQuery() throws Exception {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("insert into root.sg1.d1(time,s1) values(1,1);");
Expand All @@ -185,7 +185,7 @@ public void testDeleteStorageGroupAndThenQuery() throws Exception {
}

@Test
public void testDeleteStorageGroupInvalidateCache() throws Exception {
public void testDeleteDatabaseInvalidateCache() throws Exception {
try (final Connection connection = EnvFactory.getEnv().getConnection();
final Statement statement = connection.createStatement()) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -185,37 +186,36 @@ public void showTimeseriesTest() throws SQLException {
}

@Test
public void showStorageGroupTest() throws SQLException {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
String[] sqls =
public void showDatabasesTest() throws SQLException {
try (final Connection connection = EnvFactory.getEnv().getConnection();
final Statement statement = connection.createStatement()) {
final String[] sqls =
new String[] {
"show databases",
"show databases root.ln.wf01.**",
"show databases root.ln.wf01.wt01.status"
};
Set<String>[] standards =
new Set[] {
new HashSet<>(
Arrays.asList(
"root.ln.wf01.wt01",
"root.ln.wf01.wt02",
"root.ln1.wf01.wt01",
"root.ln2.wf01.wt01")),
new HashSet<>(Arrays.asList("root.ln.wf01.wt01", "root.ln.wf01.wt02")),
new HashSet<>()
final List<String>[] standards =
new List[] {
Arrays.asList(
"root.ln.wf01.wt01",
"root.ln.wf01.wt02",
"root.ln1.wf01.wt01",
"root.ln2.wf01.wt01"),
Arrays.asList("root.ln.wf01.wt01", "root.ln.wf01.wt02"),
Collections.emptyList()
};

for (int n = 0; n < sqls.length; n++) {
String sql = sqls[n];
Set<String> standard = standards[n];
try (ResultSet resultSet = statement.executeQuery(sql)) {
final String sql = sqls[n];
final List<String> standard = standards[n];
int i = 0;
try (final ResultSet resultSet = statement.executeQuery(sql)) {
while (resultSet.next()) {
Assert.assertTrue(standard.contains(resultSet.getString(1)));
standard.remove(resultSet.getString(1));
assertEquals(standard.get(i++), resultSet.getString(1));
}
assertEquals(0, standard.size());
} catch (SQLException e) {
assertEquals(i, standard.size());
} catch (final SQLException e) {
e.printStackTrace();
fail(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import java.text.DateFormat;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -619,16 +621,19 @@ public static void assertResultSetEqual(
}

public static void assertResultSetEqual(
ResultSet actualResultSet, String expectedHeader, Set<String> expectedRetSet) {
final ResultSet actualResultSet,
final String expectedHeader,
final Collection<String> expectedResult) {
try {
ResultSetMetaData resultSetMetaData = actualResultSet.getMetaData();
StringBuilder header = new StringBuilder();
final ResultSetMetaData resultSetMetaData = actualResultSet.getMetaData();
final StringBuilder header = new StringBuilder();
for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) {
header.append(resultSetMetaData.getColumnName(i)).append(",");
}
assertEquals(expectedHeader, header.toString());

Set<String> actualRetSet = new HashSet<>();
final Collection<String> actualRetSet =
expectedResult instanceof Set ? new HashSet<>() : new ArrayList<>();

while (actualResultSet.next()) {
StringBuilder builder = new StringBuilder();
Expand All @@ -637,8 +642,8 @@ public static void assertResultSetEqual(
}
actualRetSet.add(builder.toString());
}
assertEquals(expectedRetSet, actualRetSet);
} catch (Exception e) {
assertEquals(expectedResult, actualRetSet);
} catch (final Exception e) {
e.printStackTrace();
Assert.fail(String.valueOf(e));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,9 @@ public void testDatabaseWithSpecificCharacters() throws SQLException {

try (final ResultSet resultSet = statement.executeQuery("SHOW DATABASES")) {
assertTrue(resultSet.next());
if (resultSet.getString(1).equals("information_schema")) {
assertTrue(resultSet.next());
}
assertEquals("````x", resultSet.getString(1));
assertTrue(resultSet.next());
assertEquals("information_schema", resultSet.getString(1));
assertFalse(resultSet.next());
}

Expand Down Expand Up @@ -379,25 +378,24 @@ public void testInformationSchema() throws SQLException {
TestUtils.assertResultSetEqual(
statement.executeQuery("show tables"),
"TableName,TTL(ms),",
new HashSet<>(
Arrays.asList(
"databases,INF,",
"tables,INF,",
"columns,INF,",
"queries,INF,",
"regions,INF,",
"topics,INF,",
"pipe_plugins,INF,",
"pipes,INF,",
"subscriptions,INF,",
"views,INF,",
"models,INF,",
"functions,INF,",
"configurations,INF,",
"keywords,INF,",
"nodes,INF,",
"config_nodes,INF,",
"data_nodes,INF,")));
Arrays.asList(
"columns,INF,",
"config_nodes,INF,",
"configurations,INF,",
"data_nodes,INF,",
"databases,INF,",
"functions,INF,",
"keywords,INF,",
"models,INF,",
"nodes,INF,",
"pipe_plugins,INF,",
"pipes,INF,",
"queries,INF,",
"regions,INF,",
"subscriptions,INF,",
"tables,INF,",
"topics,INF,",
"views,INF,"));

TestUtils.assertResultSetEqual(
statement.executeQuery("desc databases"),
Expand Down Expand Up @@ -773,9 +771,8 @@ public void testMixedDatabase() throws SQLException {
final Statement statement = connection.createStatement()) {
try (final ResultSet resultSet = statement.executeQuery("SHOW DATABASES DETAILS")) {
assertTrue(resultSet.next());
if (resultSet.getString(1).equals("information_schema")) {
assertTrue(resultSet.next());
}
assertEquals("information_schema", resultSet.getString(1));
assertTrue(resultSet.next());
assertEquals("test", resultSet.getString(1));
assertFalse(resultSet.next());
}
Expand Down Expand Up @@ -858,10 +855,9 @@ public void testDBAuth() throws SQLException {
assertEquals(showDBColumnHeaders.get(i).getColumnName(), metaData.getColumnName(i + 1));
}
Assert.assertTrue(resultSet.next());
if (resultSet.getString(1).equals("information_schema")) {
assertTrue(resultSet.next());
}
assertEquals("db", resultSet.getString(1));
Assert.assertTrue(resultSet.next());
assertEquals("information_schema", resultSet.getString(1));
Assert.assertFalse(resultSet.next());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ public void testManageTable() {
// Test create table with only time column
statement.execute("create table table3()");

tableNames = new String[] {"table3", "table2"};
ttls = new String[] {"3000000", "6600000"};
tableNames = new String[] {"table2", "table3"};
ttls = new String[] {"6600000", "3000000"};

// show tables from current database
try (final ResultSet resultSet = statement.executeQuery("SHOW tables")) {
Expand All @@ -336,7 +336,7 @@ public void testManageTable() {
statement.execute("alter table table3 set properties ttl=1000000");
statement.execute("alter table table3 set properties ttl=DEFAULT");

ttls = new String[] {"INF", "6600000"};
ttls = new String[] {"6600000", "INF"};
// The table3's ttl shall be "INF"
try (final ResultSet resultSet = statement.executeQuery("SHOW tables")) {
int cnt = 0;
Expand Down Expand Up @@ -662,10 +662,9 @@ public void testTableAuth() throws SQLException {
assertEquals(showDBColumnHeaders.get(i).getColumnName(), metaData.getColumnName(i + 1));
}
Assert.assertTrue(resultSet.next());
if (resultSet.getString(1).equals("information_schema")) {
assertTrue(resultSet.next());
}
assertEquals("db", resultSet.getString(1));
Assert.assertTrue(resultSet.next());
assertEquals("information_schema", resultSet.getString(1));
Assert.assertFalse(resultSet.next());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public static DatasetHeader getShowDevicesWithSgHeader() {
return new DatasetHeader(ColumnHeaderConstant.showDevicesWithSgColumnHeaders, true);
}

public static DatasetHeader getShowStorageGroupHeader(final boolean isDetailed) {
public static DatasetHeader getShowDatabaseHeader(final boolean isDetailed) {
return isDetailed
? new DatasetHeader(ColumnHeaderConstant.showStorageGroupsDetailColumnHeaders, true)
: new DatasetHeader(ColumnHeaderConstant.showStorageGroupsColumnHeaders, true);
? new DatasetHeader(ColumnHeaderConstant.showDatabasesDetailColumnHeaders, true)
: new DatasetHeader(ColumnHeaderConstant.showDatabasesColumnHeaders, true);
}

public static DatasetHeader getShowTTLHeader() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private DatabaseSupplier(final List<TSDataType> dataTypes, final String userName
@Override
protected void constructLine() {
if (!hasShownInformationSchema) {
InformationSchemaUtils.buildDatabaseTsBlock(s -> true, resultBuilder, true, false);
InformationSchemaUtils.buildDatabaseTsBlock(resultBuilder, true, false);
hasShownInformationSchema = true;
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3136,7 +3136,7 @@ public Analysis visitShowStorageGroup(
Analysis analysis = new Analysis();
analysis.setRealStatement(showDatabaseStatement);
analysis.setRespDatasetHeader(
DatasetHeaderFactory.getShowStorageGroupHeader(showDatabaseStatement.isDetailed()));
DatasetHeaderFactory.getShowDatabaseHeader(showDatabaseStatement.isDetailed()));
return analysis;
}

Expand Down
Loading
Loading