datafusion-match-recognize 0.56.0

MATCH_RECOGNIZE extension for DataFusion
Documentation
datafusion-match-recognize-0.56.0 has been yanked.

datafusion-match-recognize

This crate implements and installs SQL MATCH_RECOGNIZE in Apache DataFusion. Most applications need only its session installer and MatchRecognizeConfig. datafusion-hash-grouped-order is published separately as a reusable physical operator, and the remaining workspace crates support testing and developer tooling.

[!WARNING] Early preview — not ready for production. Treat the DataFusion 56 release line as experimental; APIs, configuration options, and Substrait payloads may still change, and production readiness is not expected before DataFusion 57 at the earliest.

Normal Application Path

Follow Application Integration for pinned dependencies, a working external application, and troubleshooting steps. The new_match_recognize_context Rustdoc contains the compiled installer example and lists its registration order, replacements, additions, and errors.

Application API

API Purpose Availability
new_match_recognize_context Install the extension and return a new SessionContext Always
MatchRecognizeConfig Configure compile, runtime, scheduling, and diagnostic options Always
planning module Build MATCH_RECOGNIZE logical plans programmatically without SQL Always
advanced module Install alongside an application's custom planner or registry setup Always; unstable
substrait module Import and export the package-specific Substrait extension substrait feature

The Support Matrix defines accepted SQL, defaults, limitations, and differences from other SQL systems.

Compatibility

The repository depends on the official Apache DataFusion 56.0.0 release from crates.io, which includes custom-operator sort pushdown #26118 and fetched merge ordering #27331. The matcher uses the corrected generic sort-pushdown fallback. Proposed input sorts must satisfy its matching requirements and prove the requested output order after rebuilding the node. Required sorts over generated match values remain above matching. The matcher contract records the supported cases and optimization limits. Host applications must use the same DataFusion 56 crates.io release line. Cargo treats Git and crates.io dependencies as different packages, so they produce incompatible Rust types even when their package versions match. The repository status table records the current baseline, minimum Rust version, and package availability.

Arrow 60.2.0 is provided through datafusion::arrow. Arrow Union data is unsupported, including nested and encoded forms, pending upstream issue #11598. See the SQL support restriction; ordinary SQL UNION remains available.

Read the README and Rustdoc from the revision your application pins. Links to the main branch describe current development and may cover a later revision.

Cargo Features

Feature Default Effect
sql Yes Adds the SQL adapter and relation planner for MATCH_RECOGNIZE SQL
substrait No Exposes package-owned Substrait import and export helpers

All installations support the full DEFINE and MEASURES surface, including running aggregates and navigation. Queries whose DEFINE conditions depend only on input rows automatically use the static runtime paths.

Disabling default features removes the SQL adapter. It does not produce a smaller SQL installation. Explicit feature lists must include sql when the application accepts SQL text. With default features disabled and substrait not enabled, parser dependencies are absent. The substrait feature adds them transitively and requires the Protocol Buffers compiler (protoc) on PATH, even when sql remains disabled. Applications that construct plans without SQL use the SQL-free planning flow.

Configuration

Default runtime behavior does not require an explicit MatchRecognizeConfig. Insert MatchRecognizeConfig::default() into SessionConfig before creating the builder when the application needs custom values or SQL SET match_recognize.* commands. The type groups stable resource and compiler limits (match_recognize.limits.*), advanced scheduler settings (match_recognize.scheduler.*), and unstable diagnostic overrides (match_recognize.diagnostics.*).

The production evaluation guide explains the memory, spill, cancellation, and deadline boundaries that affect configuration choices. Build the local API reference for field contracts with:

cargo doc -p datafusion-match-recognize --all-features --open

Expert Integration Contracts

Installer Effects and Name Collisions

The normal installer preserves other builder fields but does not add DataFusion's default features. It returns a new context and replaces any query planner already configured on the builder. It also replaces same-named scalar functions (match_number, match_sequence_number, classifier, excluded), window functions (first, last, prev, next), and internal aggregates (__mr_first_agg, __mr_last_agg, __mr_prev_agg, __mr_next_agg). Install the extension once. Repeated installation adds duplicate logical and physical optimizer rules and, with sql, duplicate relation planners. The new_match_recognize_context Rustdoc defines the exact order, side effects, and errors.

Manual Registration

Applications with a custom query planner can add the extension through advanced::physical_extension_planner. The advanced::query_planner_with_extensions Rustdoc provides a compiled example and the remaining hook order. Registration errors do not roll back components already added to a caller-owned SessionState.

Custom planners must append advanced::physical_optimizer_rule() to optimize matcher input and ordered output. See its Rustdoc for buffering and memory-budget behavior.

Internal physical operators, planner implementations, and optimizer rule types remain implementation details and are not re-exported by this crate.

Substrait Interchange

The optional substrait helpers import and export complete DataFusion plans using this package's Substrait extension. This is not a portable standard MATCH_RECOGNIZE relation. The Substrait wire reference defines feature identifiers, payload versions, validation, and lower-level APIs.

License

Licensed under the Apache License, Version 2.0. See LICENSE and NOTICE.