Skip to content

Commit f5e7869

Browse files
authored
[v3.0.0] Deprecate SQL Delete statement (#3337)
* Remove all delete statement related code and docs Signed-off-by: Chen Dai <daichen@amazon.com> * Fix spotless Signed-off-by: Chen Dai <daichen@amazon.com> * Remove doctest Signed-off-by: Chen Dai <daichen@amazon.com> * Fix broken delete IT Signed-off-by: Chen Dai <daichen@amazon.com> * Update doc Signed-off-by: Chen Dai <daichen@amazon.com> * Undo import star statements Signed-off-by: Chen Dai <daichen@amazon.com> --------- Signed-off-by: Chen Dai <daichen@amazon.com>
1 parent 28275b8 commit f5e7869

File tree

17 files changed

+1
-517
lines changed

17 files changed

+1
-517
lines changed

DEVELOPER_GUIDE.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ For test cases, you can use the cases in the following checklist in case you mis
294294

295295
- *Other Statements*
296296

297-
- DELETE
298297
- SHOW
299298
- DESCRIBE
300299

common/src/main/java/org/opensearch/sql/common/setting/Settings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public enum Key {
2222
SQL_ENABLED("plugins.sql.enabled"),
2323
SQL_SLOWLOG("plugins.sql.slowlog"),
2424
SQL_CURSOR_KEEP_ALIVE("plugins.sql.cursor.keep_alive"),
25-
SQL_DELETE_ENABLED("plugins.sql.delete.enabled"),
2625
SQL_PAGINATION_API_SEARCH_AFTER("plugins.sql.pagination.api"),
2726

2827
/** PPL Settings. */

docs/user/admin/settings.rst

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -260,61 +260,6 @@ Result set::
260260
"transient": {}
261261
}
262262

263-
plugins.sql.delete.enabled
264-
======================
265-
266-
Description
267-
-----------
268-
269-
By default, DELETE clause disabled. You can enable DELETE clause by this setting.
270-
271-
1. The default value is false.
272-
2. This setting is node scope.
273-
3. This setting can be updated dynamically.
274-
275-
276-
Example 1
277-
---------
278-
279-
You can update the setting with a new value like this.
280-
281-
SQL query::
282-
283-
sh$ curl -sS -H 'Content-Type: application/json' -X PUT localhost:9200/_plugins/_query/settings \
284-
... -d '{"transient":{"plugins.sql.delete.enabled":"false"}}'
285-
{
286-
"acknowledged": true,
287-
"persistent": {},
288-
"transient": {
289-
"plugins": {
290-
"sql": {
291-
"delete": {
292-
"enabled": "false"
293-
}
294-
}
295-
}
296-
}
297-
}
298-
299-
Example 2
300-
---------
301-
302-
Query result after the setting updated is like:
303-
304-
SQL query::
305-
306-
sh$ curl -sS -H 'Content-Type: application/json' -X POST localhost:9200/_plugins/_sql \
307-
... -d '{"query" : "DELETE * FROM accounts"}'
308-
{
309-
"error": {
310-
"reason": "Invalid SQL query",
311-
"details": "DELETE clause is disabled by default and will be deprecated. Using the plugins.sql.delete.enabled setting to enable it",
312-
"type": "SQLFeatureDisabledException"
313-
},
314-
"status": 400
315-
}
316-
317-
318263
plugins.query.executionengine.spark.session.limit
319264
==================================================
320265

docs/user/dml/delete.rst

Lines changed: 0 additions & 87 deletions
This file was deleted.

docs/user/dql/basics.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,6 @@ Description
374374

375375
For ``LIKE`` and other full text search topics, please refer to Full Text Search documentation.
376376

377-
Besides SQL query, WHERE clause can also be used in SQL statement such as ``DELETE``. Please refer to Data Manipulation Language documentation for details.
378-
379377
Example 1: Comparison Operators
380378
-------------------------------
381379

docs/user/index.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ OpenSearch SQL enables you to extract insights out of OpenSearch using the famil
4343

4444
- `Window Functions <dql/window.rst>`_
4545

46-
* **Data Manipulation Language**
47-
48-
- `DELETE Statement <dml/delete.rst>`_
49-
5046
* **Beyond SQL**
5147

5248
- `PartiQL (JSON) Support <beyond/partiql.rst>`_

integ-test/src/test/java/org/opensearch/sql/legacy/DeleteIT.java

Lines changed: 0 additions & 139 deletions
This file was deleted.

integ-test/src/test/java/org/opensearch/sql/legacy/ExplainIT.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,6 @@ public void searchSanityFilter() throws IOException {
135135
result.replaceAll("\\s+", ""), equalTo(expectedOutput.replaceAll("\\s+", "")));
136136
}
137137

138-
@Test
139-
public void deleteSanity() throws IOException {
140-
141-
String expectedOutputFilePath =
142-
TestUtils.getResourceFilePath("src/test/resources/expectedOutput/delete_explain.json");
143-
String expectedOutput =
144-
Files.toString(new File(expectedOutputFilePath), StandardCharsets.UTF_8)
145-
.replaceAll("\r", "");
146-
;
147-
148-
String result =
149-
explainQuery(
150-
String.format(
151-
"DELETE FROM %s WHERE firstname LIKE 'A%%' AND age > 20", TEST_INDEX_ACCOUNT));
152-
Assert.assertThat(
153-
result.replaceAll("\\s+", ""), equalTo(expectedOutput.replaceAll("\\s+", "")));
154-
}
155-
156138
@Test
157139
public void spatialFilterExplainTest() throws IOException {
158140

integ-test/src/test/java/org/opensearch/sql/legacy/PluginIT.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import org.opensearch.client.RequestOptions;
1818
import org.opensearch.client.Response;
1919
import org.opensearch.client.ResponseException;
20-
import org.opensearch.sql.common.setting.Settings;
21-
import org.opensearch.sql.legacy.utils.StringUtils;
2220
import org.opensearch.sql.plugin.rest.RestQuerySettingsAction;
2321

2422
public class PluginIT extends SQLIntegTestCase {
@@ -59,31 +57,6 @@ public void sqlEnableSettingsTest() throws IOException {
5957
wipeAllClusterSettings();
6058
}
6159

62-
@Test
63-
public void sqlDeleteSettingsTest() throws IOException {
64-
updateClusterSettings(
65-
new ClusterSetting(PERSISTENT, Settings.Key.SQL_DELETE_ENABLED.getKeyValue(), "false"));
66-
67-
String deleteQuery = StringUtils.format("DELETE FROM %s", TestsConstants.TEST_INDEX_ACCOUNT);
68-
final ResponseException exception =
69-
expectThrows(ResponseException.class, () -> executeQuery(deleteQuery));
70-
JSONObject actual = new JSONObject(TestUtils.getResponseBody(exception.getResponse()));
71-
JSONObject expected =
72-
new JSONObject(
73-
"{\n"
74-
+ " \"error\": {\n"
75-
+ " \"reason\": \"Invalid SQL query\",\n"
76-
+ " \"details\": \"DELETE clause is disabled by default and will be deprecated."
77-
+ " Using the plugins.sql.delete.enabled setting to enable it\",\n"
78-
+ " \"type\": \"SQLFeatureDisabledException\"\n"
79-
+ " },\n"
80-
+ " \"status\": 400\n"
81-
+ "}");
82-
assertTrue(actual.toString(), actual.similar(expected));
83-
84-
wipeAllClusterSettings();
85-
}
86-
8760
@Test
8861
public void sqlTransientOnlySettingTest() throws IOException {
8962
// (1) compact form

0 commit comments

Comments
 (0)