datafusion-match-recognize 0.56.1

SQL MATCH_RECOGNIZE row-pattern matching for Apache 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.

//! Dependency-light MATCH_RECOGNIZE types shared across planning,
//! interchange, NFA compilation, functions, and execution.
//!
//! These types let the crates exchange values and validated identifiers without
//! depending on each other's implementations. This crate does not parse SQL,
//! select an execution strategy, or manage mutable matcher state.
//!
//! ## Coordinate and identifier spaces
//!
//! | Type | Origin and bounds |
//! | --- | --- |
//! | [`SymbolId`] | Real symbols start at slot 1; slot 0 is Empty. User symbol slices omit that slot, so their indices differ by one. |
//! | [`AbsoluteRow`] | Zero-based `u64` coordinate in the complete input stream. It identifies a physical row only inside a validated extent; acceptance can also occur at its end. |
//! | [`PhysicalEndExclusive`], [`PhysicalExtent`] | Half-open physical bounds `[start, end)`. The exclusive end can equal the start for an empty extent. |
//! | [`PhysicalRowCount`] | A `u64` count or distance between positions, rather than an absolute coordinate. |
//!
//! `PositionOffset` is a checked `u32` distance
//! from an explicit `AbsoluteRow` origin, and `AggregateId` is a zero-based
//! index checked against a fully built executable program's aggregate table.
//! Absolute positions
//! remain wide; compact offsets require the checked conversions those types
//! provide. Convert a symbol slot to a user slice index only after excluding
//! Empty.

mod algebraic;
mod coordinates;
mod ids;
pub mod metadata;
pub mod output_spec;
pub mod pattern;
pub mod spec;
pub mod symbol_eval_mode;
#[cfg(any(test, feature = "test-support"))]
pub mod test_support;
pub mod vm;

pub use algebraic::{
    AggregateValue, AggregationPositions, LabeledAggregationPositions,
    PositionHistoryError,
};
pub use coordinates::{
    AbsoluteRow, PhysicalEndExclusive, PhysicalExtent, PhysicalRowCount,
};
pub use ids::{AggregateId, PositionOffset, SymbolId};
pub use metadata::{
    MAX_VALID_MATCH_SEQUENCE_NUMBER, MIN_VALID_MATCH_SEQUENCE_NUMBER,
    MatchMetadataColumn, StaticPredicateKind, classifier_bits_col_name,
    is_reserved_internal_column_name, managed_aggregate_col_name,
    static_predicate_and_col_name, static_predicate_or_col_name, static_scalar_col_name,
    symbol_col_name,
};
pub use output_spec::{
    MAX_NAVIGATION_OFFSET, MatchRecognizeOutputSpec, MatchSummaryField, NavigationOffset,
    NavigationOffsets, OutputSpecWithArrowSchema, OutputSpecWithDFSchema,
};
pub use pattern::{
    AfterMatchSkip, EmptyMatchesMode, NormalizedPattern, Pattern, PatternAnalysisSummary,
    PatternStructuralInfo, RepetitionPreference, RepetitionQuantifier, RowsPerMatch,
    Symbol,
};
pub use spec::{
    MatchRecognizeDefinition, MatchRecognizeMeasure, MatchRecognizeNamedExpression,
    MatchRecognizeNullOrdering, MatchRecognizeOutputContract,
    MatchRecognizeSortDirection, MatchRecognizeSortExpr, MatchRecognizeSpec,
    MatchRecognizeSpecError, MatchRecognizeSpecResult,
};
pub use symbol_eval_mode::SymbolEvalMode;
pub use vm::{MAX_FIRST_OFFSET, MAX_PREV_DEPTH};