Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove sql merge #12021

Merged
merged 3 commits into from
Feb 4, 2024
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 @@ -184,36 +184,6 @@ public void test() throws SQLException {
cleanData();
}

@Test
public void testMerge() throws SQLException {
prepareMerge();

try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("merge");
statement.execute("DELETE FROM root.vehicle.d0.** WHERE time <= 15000");

// before merge completes
try (ResultSet set = statement.executeQuery("SELECT * FROM root.vehicle.d0")) {
int cnt = 0;
while (set.next()) {
cnt++;
}
assertEquals(5000, cnt);
}

// after merge completes
try (ResultSet set = statement.executeQuery("SELECT * FROM root.vehicle.d0")) {
int cnt = 0;
while (set.next()) {
cnt++;
}
assertEquals(5000, cnt);
}
cleanData();
}
}

@Test
public void testDelAfterFlush() throws SQLException {
try (Connection connection = EnvFactory.getEnv().getConnection();
Expand Down Expand Up @@ -486,13 +456,13 @@ private void prepareData() throws SQLException {
statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
statement.addBatch("merge");
statement.addBatch("flush");
// prepare Unseq-File
for (int i = 1; i <= 100; i++) {
statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
statement.addBatch("merge");
statement.addBatch("flush");
// prepare BufferWrite cache
for (int i = 301; i <= 400; i++) {
statement.addBatch(
Expand All @@ -513,21 +483,4 @@ private void cleanData() throws SQLException {
statement.execute(deleteAllTemplate);
}
}

public void prepareMerge() throws SQLException {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {

// prepare BufferWrite data
for (int i = 10001; i <= 20000; i++) {
statement.execute(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
// prepare Overflow data
for (int i = 1; i <= 10000; i++) {
statement.execute(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class})
public class IoTDBFlushQueryMergeIT {
public class IoTDBFlushQueryIT {

private static String[] sqls =
new String[] {
Expand Down Expand Up @@ -96,7 +96,6 @@ public void selectAllSQLTest() {
cnt++;
}
}
statement.execute("merge");
} catch (Exception e) {
fail(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ public void testInsertMultiRowWithMultiTimePartition() throws Exception {
st1.execute("flush");
st1.execute("insert into root.sg1.d1(time,s1) values(604799990,1), (604800001,1)");
st1.execute("flush");
st1.execute("merge");
ResultSet rs1 = st1.executeQuery("select s1 from root.sg1.d1");
assertTrue(rs1.next());
assertEquals(604799990, rs1.getLong("Time"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ private static void insertData() {
}

statement.addBatch("flush");
statement.addBatch("merge");

// unsequential data, memory data
for (int time = 1000; time < 1100; time++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,35 +180,6 @@ public void test() throws SQLException {
cleanData();
}

@Test
public void testMerge() throws SQLException {
prepareMerge();

try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("merge");
statement.execute("DELETE FROM root.vehicle.d0.** WHERE time <= 15000");

// before merge completes
try (ResultSet set = statement.executeQuery("SELECT * FROM root.vehicle.d0")) {
int cnt = 0;
while (set.next()) {
cnt++;
}
}

// after merge completes
try (ResultSet set = statement.executeQuery("SELECT * FROM root.vehicle.d0")) {
int cnt = 0;
while (set.next()) {
cnt++;
}
assertEquals(5000, cnt);
}
cleanData();
}
}

@Test
public void testDelAfterFlush() throws SQLException {
try (Connection connection = EnvFactory.getEnv().getConnection();
Expand Down Expand Up @@ -505,13 +476,13 @@ private void prepareData() throws SQLException {
statement.execute(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
statement.execute("merge");
statement.execute("flush");
// prepare Unseq-File
for (int i = 1; i <= 100; i++) {
statement.execute(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
statement.execute("merge");
statement.execute("flush");
// prepare BufferWrite cache
for (int i = 301; i <= 400; i++) {
statement.execute(
Expand All @@ -531,23 +502,4 @@ private void cleanData() throws SQLException {
statement.execute(deleteAllTemplate);
}
}

public void prepareMerge() throws SQLException {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {

// prepare BufferWrite data
for (int i = 10001; i <= 20000; i++) {
statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
statement.executeBatch();
// prepare Overflow data
for (int i = 1; i <= 10000; i++) {
statement.addBatch(
String.format(insertTemplate, i, i, i, (double) i, "'" + i + "'", i % 2 == 0));
}
statement.executeBatch();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ public void maintainOperationsTest() {
public void adminOperationsTest() {
assertNonQueryTestFail(
"flush", "803: Only the admin user can perform this operation", "test", "test123");
assertNonQueryTestFail(
"merge", "803: Only the admin user can perform this operation", "test", "test123");
assertNonQueryTestFail(
"clear cache", "803: Only the admin user can perform this operation", "test", "test123");
assertNonQueryTestFail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,6 @@ public void testBatchInsertSeqAndUnseq()

session.executeNonQueryStatement("FLUSH");
session.executeNonQueryStatement("FLUSH root.sg1");
session.executeNonQueryStatement("MERGE");
session.executeNonQueryStatement("FULL MERGE");

List<String> deviceIds = new ArrayList<>();
queryForBatch(Collections.singletonList("root.sg1.d1"), 400);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ dclStatement
;

utilityStatement
: merge | fullMerge | flush | clearCache | settle | repairData | explain
: | flush | clearCache | settle | repairData | explain
| setSystemStatus | showVersion | showFlushInfo | showLockInfo | showQueryResource
| showQueries | killQuery | grantWatermarkEmbedding | revokeWatermarkEmbedding
| loadConfiguration | loadTimeseries | loadFile | removeFile | unloadFile
Expand Down Expand Up @@ -933,16 +933,6 @@ usernameWithRoot
* 5. Utility Statements
*/

// Merge
merge
: MERGE (ON (LOCAL | CLUSTER))?
;

// Full Merge
fullMerge
: FULL MERGE (ON (LOCAL | CLUSTER))?
;

// Flush
flush
: FLUSH prefixPath? (COMMA prefixPath)* boolean_literal? (ON (LOCAL | CLUSTER))?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@
import org.apache.iotdb.db.queryengine.plan.statement.sys.FlushStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.KillQueryStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.LoadConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.MergeStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.RepairDataStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetSystemStatusStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowQueriesStatement;
Expand Down Expand Up @@ -3122,27 +3121,6 @@ private String parseAttributeValue(IoTDBSqlParser.AttributeValueContext ctx) {
return parseIdentifier(ctx.getText());
}

// Merge
@Override
public Statement visitMerge(IoTDBSqlParser.MergeContext ctx) {
MergeStatement mergeStatement = new MergeStatement(StatementType.MERGE);
if (ctx.CLUSTER() != null && !IoTDBDescriptor.getInstance().getConfig().isClusterMode()) {
throw new SemanticException("MERGE ON CLUSTER is not supported in standalone mode");
}
mergeStatement.setOnCluster(ctx.LOCAL() == null);
return mergeStatement;
}

@Override
public Statement visitFullMerge(IoTDBSqlParser.FullMergeContext ctx) {
MergeStatement mergeStatement = new MergeStatement(StatementType.FULL_MERGE);
if (ctx.CLUSTER() != null && !IoTDBDescriptor.getInstance().getConfig().isClusterMode()) {
throw new SemanticException("FULL MERGE ON CLUSTER is not supported in standalone mode");
}
mergeStatement.setOnCluster(ctx.LOCAL() == null);
return mergeStatement;
}

// Flush

@Override
Expand Down
Loading