datafusion-match-recognize 0.56.0

MATCH_RECOGNIZE extension for DataFusion
Documentation
// 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.
//
// This product includes software developed at Datadog (https://www.datadoghq.com/) Copyright 2025-Present Datadog, Inc.

use super::*;

pub(super) fn verify_failed_start_is_lazy() {
    let WideAggregateHarness {
        schema,
        compiled,
        mut matcher,
        batch,
        ..
    } = wide_aggregate_harness(None, false);
    let input = BatchCollection::try_new(vec![batch], Arc::clone(&schema)).unwrap();
    let provider = bool_test_provider(BooleanArray::from(vec![true]));
    let factory_calls = Arc::new(AtomicUsize::new(0));
    let factory = crate::execution::matching::aggregate_runtime::lazy_tests::factory(
        Arc::clone(&factory_calls),
        false,
    );
    matcher.install_malformed_aggregate_factories_for_test(
        vec![factory; WIDE_AGGREGATE_PROGRAMS].into(),
    );
    let mut ctx =
        ScanContext::new(compiled.nfa().state_count(), compiled.num_symbols(), 1);
    bind_test_identity(&mut ctx, &matcher);
    let discard_count = ctx.candidate_discard_count;

    let error = matcher
        .start_candidate_scan(test_session(&matcher, &provider, &input, &mut ctx))
        .expect_err("a start without a program must be cleaned up");
    assert!(error.to_string().contains("active executable variant"));
    assert_eq!(factory_calls.load(Ordering::SeqCst), 0);
    assert_eq!(ctx.candidate_discard_count, discard_count + 1);
    assert!(!ctx.has_live_continuation());
    assert!(!ctx.has_active_states());
}