@Test
  public void do_test()
      throws InterruptedException,
          TException,
          IoTDBConnectionException,
          IOException,
          StatementExecutionException {
    consumer = create_pull_consumer("pull_time", "ts_time_range_dataset", false, null);
    // Write data before subscribing
    insert_data(1704038396000L); // 2023-12-31 23:59:56+08:00
    // Subscribe
    consumer.subscribe(topicName);
    subs.getSubscriptions().forEach(System.out::println);
    assertEquals(subs.getSubscriptions().size(), 1, "show subscriptions after subscription");

    // Before consumption subscription data
    consume_data(consumer, session_dest);
    check_count(2, "select count(s_0) from " + device, "Start time boundary data:" + pattern);

    insert_data(System.currentTimeMillis()); // now
    consume_data(consumer, session_dest);
    check_count(
        2, "select count(s_0) from " + device, "Write some real-time data later:" + pattern);

    insert_data(1707782400000L); // 2024-02-13 08:00:00+08:00
    consume_data(consumer, session_dest);
    check_count(6, "select count(s_0) from " + device, "Data within the time range:" + pattern);

    insert_data(1711814398000L); // 2024-03-30 23:59:58+08:00
    consume_data(consumer, session_dest);
    // Because the end time is 2024-03-31 00:00:00, closed interval
    check_count(8, "select count(s_0) from " + device, "End time limit data:" + pattern);

    insert_data(1711900798000L); // 2024-03-31 23:59:58+08:00
    consume_data(consumer, session_dest);
    check_count(8, "select count(s_0) from " + device, "End time boundary data:" + pattern);
  }
Start time, end time are both closed intervals. If not specified, the time will be 00:00:00.
integration-test/src/test/java/org/apache/iotdb/subscription/it/triple/treemodel/regression/pullconsumer/time/IoTDBTimeRangePullConsumerDataSetIT.java