@Test
  public void testLogicalNavigationFunction() {
    String[] expectedHeader = new String[] {"time", "price"};
    String[] retArray1 =
        new String[] {
          "2025-01-01T00:01:00.000Z,10.0,",
          "2025-01-01T00:02:00.000Z,20.0,",
          "2025-01-01T00:03:00.000Z,30.0,",
        };
    String[] retArray2 =
        new String[] {
          "2025-01-01T00:01:00.000Z,30.0,",
          "2025-01-01T00:02:00.000Z,30.0,",
          "2025-01-01T00:03:00.000Z,30.0,",
        };
    String[] retArray3 =
        new String[] {
          "2025-01-01T00:01:00.000Z,10.0,",
          "2025-01-01T00:02:00.000Z,10.0,",
          "2025-01-01T00:03:00.000Z,10.0,",
        };
    String[] retArray4 =
        new String[] {
          "2025-01-01T00:01:00.000Z,null,",
          "2025-01-01T00:02:00.000Z,null,",
          "2025-01-01T00:03:00.000Z,10.0,",
        };
    String[] retArray5 =
        new String[] {
          "2025-01-01T00:01:00.000Z,10.0,",
          "2025-01-01T00:02:00.000Z,10.0,",
          "2025-01-01T00:03:00.000Z,10.0,",
        };
    String[] retArray6 =
        new String[] {
          "2025-01-01T00:01:00.000Z,30.0,",
          "2025-01-01T00:02:00.000Z,30.0,",
          "2025-01-01T00:03:00.000Z,30.0,",
        };

    String sql =
        "SELECT m.time, m.price "
            + "FROM t2 "
            + "MATCH_RECOGNIZE ( "
            + "    MEASURES "
            + "        %s AS price "
            + "    ALL ROWS PER MATCH "
            + "    AFTER MATCH SKIP PAST LAST ROW "
            + "    PATTERN (A+) "
            + "    DEFINE "
            + "        A AS true "
            + ") AS m";
    // LAST(totalprice)
    tableResultSetEqualTest(format(sql, "totalprice"), expectedHeader, retArray1, DATABASE_NAME);
    tableResultSetEqualTest(
        format(sql, "RPR_LAST(totalprice)"), expectedHeader, retArray1, DATABASE_NAME);
    tableResultSetEqualTest(
        format(sql, "RPR_LAST(totalprice, 0)"), expectedHeader, retArray1, DATABASE_NAME);
    tableResultSetEqualTest(
        format(sql, "RUNNING RPR_LAST(totalprice)"), expectedHeader, retArray1, DATABASE_NAME);

    // FINAL LAST(totalprice)
    tableResultSetEqualTest(
        format(sql, "FINAL RPR_LAST(totalprice)"), expectedHeader, retArray2, DATABASE_NAME);

    // FIRST(totalprice)
    tableResultSetEqualTest(
        format(sql, "RPR_FIRST(totalprice)"), expectedHeader, retArray3, DATABASE_NAME);
    tableResultSetEqualTest(
        format(sql, "RPR_FIRST(totalprice, 0)"), expectedHeader, retArray3, DATABASE_NAME);
    tableResultSetEqualTest(
        format(sql, "RUNNING RPR_FIRST(totalprice)"), expectedHeader, retArray3, DATABASE_NAME);
    tableResultSetEqualTest(
        format(sql, "FINAL RPR_FIRST(totalprice)"), expectedHeader, retArray3, DATABASE_NAME);

    // LAST(totalprice, 2)
    tableResultSetEqualTest(
        format(sql, "RPR_LAST(totalprice, 2)"), expectedHeader, retArray4, DATABASE_NAME);

    // FINAL LAST(totalprice, 2)
    tableResultSetEqualTest(
        format(sql, "FINAL RPR_LAST(totalprice, 2)"), expectedHeader, retArray5, DATABASE_NAME);

    // FIRST(totalprice, 2)
    tableResultSetEqualTest(
        format(sql, "RPR_FIRST(totalprice, 2)"), expectedHeader, retArray6, DATABASE_NAME);
    tableResultSetEqualTest(
        format(sql, "FINAL RPR_FIRST(totalprice, 2)"), expectedHeader, retArray6, DATABASE_NAME);
  }
Search range: all devices whose department is 'DEP_1', each device's data is grouped
separately, and the time range is between 2025-01-01T00:00:00 and 2025-01-01T01:00:00.

<p>Event analysis: Whenever the altitude exceeds 500 and then drops below 500, it is marked as
an event.
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBPatternRecognitionIT.java