You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: watermark_filter.rs
    path of file: ./repos/risingwave/src/stream/src/executor
    
    the code of the file until where you have to start completion: // Copyright 2024 RisingWave Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use std::cmp;
use std::ops::Deref;
use std::sync::Arc;

use futures::future::{try_join, try_join_all};
use futures::StreamExt;
use futures_async_stream::try_stream;
use risingwave_common::hash::VnodeBitmapExt;
use risingwave_common::row::{OwnedRow, Row};
use risingwave_common::types::{DataType, DefaultOrd, ScalarImpl};
use risingwave_common::{bail, row};
use risingwave_expr::expr::{
    build_func_non_strict, ExpressionBoxExt, InputRefExpression, LiteralExpression,
    NonStrictExpression,
};
use risingwave_expr::Result as ExprResult;
use risingwave_hummock_sdk::HummockReadEpoch;
use risingwave_pb::expr::expr_node::Type;
use risingwave_storage::table::batch_table::storage_table::StorageTable;
use risingwave_storage::table::TableDistribution;
use risingwave_storage::StateStore;

use super::error::StreamExecutorError;
use super::filter::FilterExecutor;
use super::{ActorContextRef, Execute, Executor, ExecutorInfo, Message, StreamExecutorResult};
use crate::common::table::state_table::StateTable;
use crate::executor::{expect_first_barrier, Watermark};
use crate::task::ActorEvalErrorReport;

/// The executor will generate a `Watermark` after each chunk.
/// This will also guarantee all later rows with event time **less than** the watermark will be
/// filtered.
pub struct WatermarkFilterExecutor<S: StateStore> {
    ctx: ActorContextRef,

    input: Executor,
    /// The expression used to calculate the watermark value.
    watermark_expr: NonStrictExpression,
    /// The column we should generate watermark and filter on.
    event_time_col_idx: usize,
    table: StateTable<S>,
    global_watermark_table: StorageTable<S>,

    eval_error_report: ActorEvalErrorReport,
}

impl<S: StateStore> WatermarkFilterExecutor<S> {
    pub fn new(
        ctx: ActorContextRef,
        info: &ExecutorInfo,
        input: Executor,
        watermark_expr: NonStrictExpression,
        event_time_col_idx: usize,
        table: StateTable<S>,
        global_watermark_table: StorageTable<S>,
    ) -> Self {
        let eval_error_report = ActorEvalErrorReport {
            actor_context: ctx.clone(),
            identity: Arc::from(info.identity.as_ref()),
        };

        Self {
            ctx,
            input,
            watermark_expr,
            event_time_col_idx,
            table,
            global_watermark_table,
            eval_error_report,
        }
    }
}

impl<S: StateStore> Execute for WatermarkFilterExecutor<S> {
    fn execute(self: Box<Self>) -> super::BoxedMessageStream {
        self.execute_inner().boxed()
    }
}

impl<S: StateStore> WatermarkFilterExecutor<S> {
    #[try_stream(ok = Message, error = StreamExecutorError)]

    
    async fn test_watermark_filter() {
        let chunk1 = StreamChunk::from_pretty(
            "  I TS
             + 1 2022-11-07T00:00:00
             + 2 2022-11-08T00:00:00
             + 3 2022-11-06T00:00:00",
        );
        let chunk2 = StreamChunk::from_pretty(
            "  I TS
             + 4 2022-11-07T00:00:00
             + 5 2022-11-06T00:00:00
             + 6 2022-11-10T00:00:00",
        );
        let chunk3 = StreamChunk::from_pretty(
            "  I TS
             + 7 2022-11-14T00:00:00
             + 8 2022-11-09T00:00:00
             + 9 2022-11-08T00:00:00",
        );

        let mem_state = MemoryStateStore::new();

        let (executor, mut tx) = create_watermark_filter_executor(mem_state.clone()).await;
        let mut executor = executor.execute();

        // push the init barrier
        tx.push_barrier(test_epoch(1), false);
        executor.next().await.unwrap().unwrap();

        macro_rules! watermark {
            ($scalar:expr) => {
                Watermark::new(1, WATERMARK_TYPE.clone(), $scalar)
            };
        }

        // push the 1st chunk
        tx.push_chunk(chunk1);
        let chunk = executor.next().await.unwrap().unwrap();
        assert_eq!(
            chunk.into_chunk().unwrap().compact(),
            StreamChunk::from_pretty(
                "  I TS
                 + 1 2022-11-07T00:00:00
                 + 2 2022-11-08T00:00:00
                 + 3 2022-11-06T00:00:00",
            )
        );
        let watermark = executor.next().await.unwrap().unwrap();
        assert_eq!(
            watermark.into_watermark().unwrap(),
            watermark!(ScalarImpl::Timestamp(
                Date::from_ymd_uncheck(2022, 11, 7).and_hms_uncheck(0, 0, 0)
            ))
        );

        // push the 2nd barrier
        tx.push_barrier(test_epoch(2), false);
        executor.next().await.unwrap().unwrap();

        // push the 2nd chunk
        tx.push_chunk(chunk2);
        let chunk = executor.next().await.unwrap().unwrap();
        assert_eq!(
            chunk.into_chunk().unwrap().compact(),
            StreamChunk::from_pretty(
                "  I TS
                 + 4 2022-11-07T00:00:00
                 + 6 2022-11-10T00:00:00",
            )
        );
        let watermark = executor.next().await.unwrap().unwrap();
        assert_eq!(
            watermark.into_watermark().unwrap(),
            watermark!(ScalarImpl::Timestamp(
                Date::from_ymd_uncheck(2022, 11, 9).and_hms_uncheck(0, 0, 0)
            ))
        );

        // push the 3nd barrier
        tx.push_barrier(test_epoch(3), false);
        executor.next().await.unwrap().unwrap();

        // Drop executor
        drop(executor);

        // Build new executor
        let (executor, mut tx) = create_watermark_filter_executor(mem_state.clone()).await;
        let mut executor = executor.execute();

        // push the 1st barrier after failover
        tx.push_barrier(test_epoch(4), false);
        executor.next().await.unwrap().unwrap();

        // Init watermark after failover
        let watermark = executor.next().await.unwrap().unwrap();
        assert_eq!(
            watermark.into_watermark().unwrap(),
            watermark!(ScalarImpl::Timestamp(
                Date::from_ymd_uncheck(2022, 11, 9).and_hms_uncheck(0, 0, 0)
            ))
        );

        // push the 3rd chunk
        tx.push_chunk(chunk3);
        let chunk = executor.next().await.unwrap().unwrap();
        assert_eq!(
            chunk.into_chunk().unwrap().compact(),
            StreamChunk::from_pretty(
                "  I TS
                 + 7 2022-11-14T00:00:00
                 + 8 2022-11-09T00:00:00",
            )
        );
        let watermark = executor.next().await.unwrap().unwrap();
        assert_eq!(
            watermark.into_watermark().unwrap(),
            watermark!(ScalarImpl::Timestamp(
                Date::from_ymd_uncheck(2022, 11, 13).and_hms_uncheck(0, 0, 0)
            ))
        );
    }