private Void randomDeviceDeletion(
      AtomicLong writtenPointCounter,
      List<AtomicLong> deviceDeletedPointCounters,
      ExecutorService allThreads,
      int fileNumMax,
      int pointPerFile,
      int deletionRange,
      int minIntervalToRecord,
      int testNum)
      throws SQLException, InterruptedException {
    // delete random 'deletionRange' points each time
    List<List<TimeRange>> allDeviceUndeletedRanges = new ArrayList<>();
    for (int i = 0; i < deviceDeletedPointCounters.size(); i++) {
      allDeviceUndeletedRanges.add(new ArrayList<>());
    }
    // pointPerFile * fileNumMax
    long deletionEnd = (long) fileNumMax * pointPerFile - 1;
    long nextRangeStart = 0;
    Random random = new Random();

    try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
        Statement statement = connection.createStatement()) {

      statement.execute("create database if not exists test");
      statement.execute("use test");
      while ((writtenPointCounter.get() < deletionEnd
              || allDeviceUndeletedRanges.stream().anyMatch(l -> !l.isEmpty()))
          && !Thread.interrupted()) {
        // record the newly inserted interval if it is long enough
        for (int i = 0; i < deviceDeletedPointCounters.size(); i++) {
          long currentWrittenTime = writtenPointCounter.get();
          List<TimeRange> deviceUndeletedRanges = allDeviceUndeletedRanges.get(i);

          if (currentWrittenTime - nextRangeStart >= minIntervalToRecord) {
            deviceUndeletedRanges.add(new TimeRange(nextRangeStart, currentWrittenTime));
            nextRangeStart = currentWrittenTime + 1;
          }
          if (deviceUndeletedRanges.isEmpty()) {
            Thread.sleep(10);
            continue;
          }
          // pick up a random range
          int rangeIndex = random.nextInt(deviceUndeletedRanges.size());
          TimeRange timeRange = deviceUndeletedRanges.get(rangeIndex);
          // delete a random part in the range
          LOGGER.debug("Pick up a range [{}, {}]", timeRange.getMin(), timeRange.getMax());
          long rangeDeletionStart;
          long timeRangeLength = timeRange.getMax() - timeRange.getMin() + 1;
          if (timeRangeLength == 1) {
            rangeDeletionStart = timeRange.getMin();
          } else {
            rangeDeletionStart = random.nextInt((int) (timeRangeLength - 1)) + timeRange.getMin();
          }
          long rangeDeletionEnd = Math.min(rangeDeletionStart + deletionRange, timeRange.getMax());
          LOGGER.debug("Deletion range [{}, {}]", rangeDeletionStart, rangeDeletionEnd);

          statement.execute(
              "delete from test.table"
                  + testNum
                  + " where time >= "
                  + rangeDeletionStart
                  + " and time <= "
                  + rangeDeletionEnd
                  + " and deviceId = 'd"
                  + i
                  + "'");
          deviceDeletedPointCounters.get(i).addAndGet(rangeDeletionEnd - rangeDeletionStart + 1);
          LOGGER.debug(
              "Deleted range [{}, {}], written points: {}, deleted points: {}",
              timeRange.getMin(),
              timeRange.getMax(),
              currentWrittenTime + 1,
              deviceDeletedPointCounters.get(i).get());

          // update the range
          if (rangeDeletionStart == timeRange.getMin() && rangeDeletionEnd == timeRange.getMax()) {
            // range fully deleted
            deviceUndeletedRanges.remove(rangeIndex);
          } else if (rangeDeletionStart == timeRange.getMin()) {
            // prefix deleted
            timeRange.setMin(rangeDeletionEnd + 1);
          } else if (rangeDeletionEnd == timeRange.getMax()) {
            // suffix deleted
            timeRange.setMax(rangeDeletionStart - 1);
          } else {
            // split into two ranges
            deviceUndeletedRanges.add(new TimeRange(rangeDeletionEnd + 1, timeRange.getMax()));
            timeRange.setMax(rangeDeletionStart - 1);
          }

          // check the point count
          try (ResultSet set =
              statement.executeQuery(
                  "select count(*) from table"
                      + testNum
                      + " where time <= "
                      + currentWrittenTime
                      + " AND deviceId = 'd"
                      + i
                      + "'")) {
            assertTrue(set.next());
            long expectedCnt = currentWrittenTime + 1 - deviceDeletedPointCounters.get(i).get();
            if (expectedCnt != set.getLong(1)) {
              allDeviceUndeletedRanges.set(i, mergeRanges(deviceUndeletedRanges));
              List<TimeRange> remainingRanges =
                  collectDataRanges(statement, currentWrittenTime, testNum);
              LOGGER.debug("Expected ranges: {}", deviceUndeletedRanges);
              LOGGER.debug("Remaining ranges: {}", remainingRanges);
              fail(
                  String.format(
                      "Inconsistent number of points %d - %d", expectedCnt, set.getLong(1)));
            }
          }

          Thread.sleep(10);
        }
      }
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      return null;
    } catch (SQLException e) {
      if (e.getMessage().contains("Fail to reconnect")) {
        // restart triggered, ignore
        return null;
      } else {
        allThreads.shutdownNow();
        throw e;
      }
    } catch (ParallelRequestTimeoutException ignored) {
      // restart triggered, ignore
      return null;
    } catch (Throwable e) {
      allThreads.shutdownNow();
      throw e;
    }
    return null;
  }
Should delete this case after the deletion value filter feature be implemented
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java