Skip to content

Commit 1e93245

Browse files
authored
Diasble delete-from sql
1 parent 45d189e commit 1e93245

File tree

3 files changed

+124
-0
lines changed

3 files changed

+124
-0
lines changed

integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import static org.junit.Assert.assertTrue;
5151
import static org.junit.Assert.fail;
5252

53+
@Ignore
5354
@RunWith(IoTDBTestRunner.class)
5455
@Category({TableLocalStandaloneIT.class, TableClusterIT.class})
5556
public class IoTDBDeletionTableIT {
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iotdb.relational.it.db.it;
21+
22+
import org.apache.iotdb.it.env.EnvFactory;
23+
import org.apache.iotdb.it.framework.IoTDBTestRunner;
24+
import org.apache.iotdb.itbase.category.TableClusterIT;
25+
import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
26+
import org.apache.iotdb.itbase.env.BaseEnv;
27+
28+
import org.junit.AfterClass;
29+
import org.junit.BeforeClass;
30+
import org.junit.Test;
31+
import org.junit.experimental.categories.Category;
32+
import org.junit.runner.RunWith;
33+
34+
import java.sql.Connection;
35+
import java.sql.SQLException;
36+
import java.sql.Statement;
37+
import java.util.Locale;
38+
39+
import static org.junit.Assert.assertEquals;
40+
import static org.junit.Assert.fail;
41+
42+
@RunWith(IoTDBTestRunner.class)
43+
@Category({TableLocalStandaloneIT.class, TableClusterIT.class})
44+
public class IoTDBDisableDeletionTableIT {
45+
46+
@BeforeClass
47+
public static void setUp() throws Exception {
48+
Locale.setDefault(Locale.ENGLISH);
49+
50+
EnvFactory.getEnv()
51+
.getConfig()
52+
.getCommonConfig()
53+
.setPartitionInterval(1000)
54+
.setMemtableSizeThreshold(10000);
55+
// Adjust memstable threshold size to make it flush automatically
56+
EnvFactory.getEnv().initClusterEnvironment();
57+
}
58+
59+
@AfterClass
60+
public static void tearDown() throws Exception {
61+
EnvFactory.getEnv().cleanClusterEnvironment();
62+
}
63+
64+
@Test
65+
public void testDeletionDisabled() throws SQLException {
66+
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
67+
Statement statement = connection.createStatement()) {
68+
statement.execute("create database test");
69+
statement.execute("use test");
70+
statement.execute(
71+
"CREATE TABLE vehicle1(deviceId STRING ID, s0 INT32 MEASUREMENT, s1 INT64 MEASUREMENT, s2 FLOAT MEASUREMENT, s3 TEXT MEASUREMENT, s4 BOOLEAN MEASUREMENT)");
72+
73+
statement.execute("insert into vehicle1(time, deviceId, s0) values (10, 'd0', 310)");
74+
statement.execute("insert into vehicle1(time, deviceId, s3) values (10, 'd0','text')");
75+
statement.execute("insert into vehicle1(time, deviceId, s4) values (10, 'd0',true)");
76+
77+
try {
78+
statement.execute("DELETE FROM vehicle1 WHERE s0 <= 300 AND s0 > 0");
79+
fail("should not reach here!");
80+
} catch (SQLException e) {
81+
assertEquals("701: Delete statement is not supported yet.", e.getMessage());
82+
}
83+
84+
try {
85+
statement.execute("DELETE FROM vehicle1 WHERE s3 = 'text'");
86+
fail("should not reach here!");
87+
} catch (SQLException e) {
88+
assertEquals("701: Delete statement is not supported yet.", e.getMessage());
89+
}
90+
91+
try {
92+
statement.execute("DELETE FROM vehicle1 WHERE s4 != true");
93+
fail("should not reach here!");
94+
} catch (SQLException e) {
95+
assertEquals("701: Delete statement is not supported yet.", e.getMessage());
96+
}
97+
98+
try {
99+
statement.execute("DELETE FROM vehicle1 WHERE time < 10 and deviceId > 'd0'");
100+
fail("should not reach here!");
101+
} catch (SQLException e) {
102+
assertEquals("701: Delete statement is not supported yet.", e.getMessage());
103+
}
104+
105+
try {
106+
statement.execute("DELETE FROM vehicle1 WHERE time < 10 and deviceId is not null");
107+
fail("should not reach here!");
108+
} catch (SQLException e) {
109+
assertEquals("701: Delete statement is not supported yet.", e.getMessage());
110+
}
111+
112+
try {
113+
statement.execute("DELETE FROM vehicle1 WHERE time < 10 and deviceId = null");
114+
fail("should not reach here!");
115+
} catch (SQLException e) {
116+
assertEquals("701: Delete statement is not supported yet.", e.getMessage());
117+
}
118+
}
119+
}
120+
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@ private Scope visitInsert(WrappedInsertStatement insert, Optional<Scope> scope)
533533

534534
@Override
535535
protected Scope visitDelete(Delete node, Optional<Scope> scope) {
536+
if (true) {
537+
throw new SemanticException("Delete statement is not supported yet.");
538+
}
536539
final Scope ret = Scope.create();
537540
AnalyzeUtils.analyzeDelete(node, queryContext);
538541
analysis.setScope(node, ret);

0 commit comments

Comments
 (0)