Skip to content
Draft
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 @@ -27,12 +27,14 @@
import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowModelsStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.template.DropSchemaTemplateStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.AuthorStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowDeleteTimeSeriesProgressStatement;

public class ExecuteStatementHandler {
private ExecuteStatementHandler() {}

public static boolean validateStatement(Statement statement) {
return !(statement instanceof QueryStatement)
&& !(statement instanceof ShowDeleteTimeSeriesProgressStatement)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major external-service-impl/rest/src/main/java/org/apache/iotdb/rest/protocol/v1/handler/ExecuteStatementHandler.java:37 — Query path still rejects SHOW DELETE TIMESERIES PROGRESS: fillQueryDataSet has no branch for it

After this change SHOW DELETE TIMESERIES PROGRESS reaches the REST v1 query endpoint, but QueryDataSetHandler.fillQueryDataSet (v1, lines 61-84) only special-cases ShowStatement/ShowModels/ShowAIDevices/ShowLoadedModels/AuthorStatement/GetRegionIdStatement and QueryStatement; ShowDeleteTimeSeriesProgressStatement (extends Statement, implements IConfigStatement) falls through to the fallback branch and returns QUERY_PROCESS_ERROR "unsupported query data type", so the feature does not work. The non-query endpoint simultaneously regresses from SUCCESS_STATUS to EXECUTE_STATEMENT_ERROR.

Fix: Add statement instanceof ShowDeleteTimeSeriesProgressStatement to the fillShowPlanDataSet branch in external-service-impl/rest/.../v1/handler/QueryDataSetHandler.java, mirroring the validator change (and v2 for parity).

&& !(statement instanceof ShowModelsStatement)
&& !(statement instanceof ShowAIDevicesStatement)
&& !(statement instanceof ShowLoadedModelsStatement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowLoadedModelsStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.model.ShowModelsStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.AuthorStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowDeleteTimeSeriesProgressStatement;
import org.apache.iotdb.rest.i18n.RestMessages;
import org.apache.iotdb.rest.protocol.handler.QueryRowLimitUtils;
import org.apache.iotdb.rest.protocol.v1.model.ExecutionStatus;
Expand Down Expand Up @@ -59,6 +60,7 @@ public static Response fillQueryDataSet(
IQueryExecution queryExecution, Statement statement, int actualRowSizeLimit)
throws IoTDBException {
if (statement instanceof ShowStatement
|| statement instanceof ShowDeleteTimeSeriesProgressStatement
|| statement instanceof ShowModelsStatement
|| statement instanceof ShowAIDevicesStatement
|| statement instanceof ShowLoadedModelsStatement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.iotdb.db.queryengine.plan.analyze.QueryType;
import org.apache.iotdb.db.queryengine.plan.execution.ExecutionResult;
import org.apache.iotdb.db.queryengine.plan.execution.IQueryExecution;
import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowDeleteTimeSeriesProgressStatement;
import org.apache.iotdb.rest.protocol.model.ExecutionStatus;
import org.apache.iotdb.rest.protocol.v1.model.QueryDataSet;
import org.apache.iotdb.rpc.TSStatusCode;
Expand All @@ -45,10 +46,17 @@
import java.util.Queue;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class QueryDataSetHandlerTest {

@Test
public void showDeleteTimeSeriesProgressIsAllowedAsQuery() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor external-service-impl/rest/src/test/java/org/apache/iotdb/rest/protocol/v1/handler/QueryDataSetHandlerTest.java:55 — New test only asserts validateStatement and never exercises fillQueryDataSet

showDeleteTimeSeriesProgressIsAllowedAsQuery asserts only assertFalse(ExecuteStatementHandler.validateStatement(...)), so it passes even though QueryDataSetHandler.fillQueryDataSet still returns a QUERY_PROCESS_ERROR for this statement type. The regression is invisible to the test suite.

Fix: Extend the test to call QueryDataSetHandler.fillQueryDataSet(new TestQueryExecution(...), new ShowDeleteTimeSeriesProgressStatement(), limit) and assert a QueryDataSet with the expected column names is returned.

assertFalse(
ExecuteStatementHandler.validateStatement(new ShowDeleteTimeSeriesProgressStatement()));
}

@Test
public void fillDataSetWithTimestampsShouldAllowResultAtExactLimit() throws Exception {
Response response =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,17 @@ public void perData(CloseableHttpClient httpClient) {
nonQuery(httpClient, "{\"sql\":\"GRANT WRITE ON root.** to user root1\"}", httpPostV2);
}

@Test
public void showDeleteTimeSeriesProgressIsQueryableThroughRestV1() throws IOException {
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
Map result = queryMetaData(httpClient, "{\"sql\":\"SHOW DELETE TIMESERIES PROGRESS\"}");
List<String> columnNames = (List<String>) result.get("columnNames");
Assert.assertNotNull(columnNames);
Assert.assertEquals(8, columnNames.size());
Assert.assertTrue(columnNames.contains("ProcedureId"));
}
}

@Test
public void insertAndQuery() {
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
Expand Down
Loading