Skip to content

Commit

Permalink
Remove all delete statement related code and docs
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Dai <[email protected]>
  • Loading branch information
dai-chen committed Feb 19, 2025
1 parent 44ff520 commit 9a77faf
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 373 deletions.
1 change: 0 additions & 1 deletion DEVELOPER_GUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ For test cases, you can use the cases in the following checklist in case you mis

- *Other Statements*

- DELETE
- SHOW
- DESCRIBE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/** Setting. */
public abstract class Settings {
Expand All @@ -22,7 +23,6 @@ public enum Key {
SQL_ENABLED("plugins.sql.enabled"),
SQL_SLOWLOG("plugins.sql.slowlog"),
SQL_CURSOR_KEEP_ALIVE("plugins.sql.cursor.keep_alive"),
SQL_DELETE_ENABLED("plugins.sql.delete.enabled"),
SQL_PAGINATION_API_SEARCH_AFTER("plugins.sql.pagination.api"),

/** PPL Settings. */
Expand Down
87 changes: 0 additions & 87 deletions docs/user/dml/delete.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs/user/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ OpenSearch SQL enables you to extract insights out of OpenSearch using the famil

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

* **Data Manipulation Language**

- `DELETE Statement <dml/delete.rst>`_

* **Beyond SQL**

- `PartiQL (JSON) Support <beyond/partiql.rst>`_
Expand Down
139 changes: 0 additions & 139 deletions integ-test/src/test/java/org/opensearch/sql/legacy/DeleteIT.java

This file was deleted.

38 changes: 8 additions & 30 deletions integ-test/src/test/java/org/opensearch/sql/legacy/ExplainIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@

package org.opensearch.sql.legacy;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DOG;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_LOCATION;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_NESTED_TYPE;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_PEOPLE;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_PHRASE;

import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.opensearch.client.Request;
import org.opensearch.client.Response;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.opensearch.sql.legacy.TestsConstants.*;

public class ExplainIT extends SQLIntegTestCase {

@Override
Expand Down Expand Up @@ -135,24 +131,6 @@ public void searchSanityFilter() throws IOException {
result.replaceAll("\\s+", ""), equalTo(expectedOutput.replaceAll("\\s+", "")));
}

@Test
public void deleteSanity() throws IOException {

String expectedOutputFilePath =
TestUtils.getResourceFilePath("src/test/resources/expectedOutput/delete_explain.json");
String expectedOutput =
Files.toString(new File(expectedOutputFilePath), StandardCharsets.UTF_8)
.replaceAll("\r", "");
;

String result =
explainQuery(
String.format(
"DELETE FROM %s WHERE firstname LIKE 'A%%' AND age > 20", TEST_INDEX_ACCOUNT));
Assert.assertThat(
result.replaceAll("\\s+", ""), equalTo(expectedOutput.replaceAll("\\s+", "")));
}

@Test
public void spatialFilterExplainTest() throws IOException {

Expand Down
40 changes: 7 additions & 33 deletions integ-test/src/test/java/org/opensearch/sql/legacy/PluginIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@

package org.opensearch.sql.legacy;

import static org.hamcrest.Matchers.equalTo;
import static org.opensearch.sql.legacy.TestUtils.getResponseBody;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;

import java.io.IOException;
import java.util.Locale;
import org.json.JSONObject;
import org.junit.Test;
import org.opensearch.client.Request;
import org.opensearch.client.RequestOptions;
import org.opensearch.client.Response;
import org.opensearch.client.ResponseException;
import org.opensearch.sql.common.setting.Settings;
import org.opensearch.sql.legacy.utils.StringUtils;
import org.opensearch.sql.plugin.rest.RestQuerySettingsAction;

import java.io.IOException;
import java.util.Locale;

import static org.hamcrest.Matchers.equalTo;
import static org.opensearch.sql.legacy.TestUtils.getResponseBody;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;

public class PluginIT extends SQLIntegTestCase {

@Override
Expand Down Expand Up @@ -59,31 +58,6 @@ public void sqlEnableSettingsTest() throws IOException {
wipeAllClusterSettings();
}

@Test
public void sqlDeleteSettingsTest() throws IOException {
updateClusterSettings(
new ClusterSetting(PERSISTENT, Settings.Key.SQL_DELETE_ENABLED.getKeyValue(), "false"));

String deleteQuery = StringUtils.format("DELETE FROM %s", TestsConstants.TEST_INDEX_ACCOUNT);
final ResponseException exception =
expectThrows(ResponseException.class, () -> executeQuery(deleteQuery));
JSONObject actual = new JSONObject(TestUtils.getResponseBody(exception.getResponse()));
JSONObject expected =
new JSONObject(
"{\n"
+ " \"error\": {\n"
+ " \"reason\": \"Invalid SQL query\",\n"
+ " \"details\": \"DELETE clause is disabled by default and will be deprecated."
+ " Using the plugins.sql.delete.enabled setting to enable it\",\n"
+ " \"type\": \"SQLFeatureDisabledException\"\n"
+ " },\n"
+ " \"status\": 400\n"
+ "}");
assertTrue(actual.toString(), actual.similar(expected));

wipeAllClusterSettings();
}

@Test
public void sqlTransientOnlySettingTest() throws IOException {
// (1) compact form
Expand Down
1 change: 0 additions & 1 deletion legacy/src/main/antlr/OpenSearchLegacySqlLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ CASE: 'CASE';
CAST: 'CAST';
CROSS: 'CROSS';
DATETIME: 'DATETIME';
DELETE: 'DELETE';
DESC: 'DESC';
DESCRIBE: 'DESCRIBE';
DISTINCT: 'DISTINCT';
Expand Down
Loading

0 comments on commit 9a77faf

Please sign in to comment.