You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Implement MATCH_RECOGNIZE for Advanced Pattern Matching #13583
Is your feature request related to a problem or challenge?
The MATCH_RECOGNIZE clause, introduced in SQL:2016, provides powerful capabilities for pattern matching in data streams or tables. It is particularly useful for scenarios such as identifying user behavior patterns—for example, determining which users followed a specific sequence of page views and actions on a website before opening a support ticket or completing a purchase. I noticed that datafusion-sqlparser-rs can parse SQL queries which contain the MATCH_RECOGNIZE clause, which could serve as a foundation for implementation. Is there any interest in implementing this feature?
Describe the solution you'd like
No response
Describe alternatives you've considered
No response
Additional context
No response
Reacted by Bruno Volpato, debugmiller, Geoffrey Claude and Marcos Antonio Vaz Salles
I've got a pretty terrible hackathon POC which more or less works. I'll clean it up and hopefully open up a draft PR by the end of the week for follow up discussions!
I'm pretty much AFK until September, so sharing what I've got so far: #16685
As written in the PR description, this is a partial POC of MATCH_RECOGNIZE, restricted to no cross referencing symbols in the DEFINE clause, and no streaming support (fully buffered as the WindowAgg node.)
The goal was really to explore if MATCH_RECOGNIZE could be built using existing DataFusion operators. Besides the core pattern matching part, it does seem pretty feasible!
MATCH_RECOGNIZE is most probably too complex to integrate in the core DataFusion. As mentioned in #16505 (comment) for TABLESAMPLE, I believe it would make more sense to develop it as an extension in datafusion-contrib.
I've opened #18078, which is a prerequisite to allow building such extensions.
Activity
geoffreyclaude commentedon Jul 1, 2025
take
geoffreyclaude commentedon Jul 1, 2025
I've got a pretty terrible hackathon POC which more or less works. I'll clean it up and hopefully open up a draft PR by the end of the week for follow up discussions!
geoffreyclaude commentedon Jul 8, 2025
I'm pretty much AFK until September, so sharing what I've got so far: #16685
As written in the PR description, this is a partial POC of MATCH_RECOGNIZE, restricted to no cross referencing symbols in the DEFINE clause, and no streaming support (fully buffered as the WindowAgg node.)
The goal was really to explore if MATCH_RECOGNIZE could be built using existing DataFusion operators. Besides the core pattern matching part, it does seem pretty feasible!
geoffreyclaude commentedon Oct 15, 2025
MATCH_RECOGNIZEis most probably too complex to integrate in the core DataFusion. As mentioned in #16505 (comment) for TABLESAMPLE, I believe it would make more sense to develop it as an extension indatafusion-contrib.I've opened #18078, which is a prerequisite to allow building such extensions.
alamb commentedon Aug 11, 2026
Thanks to @geoffreyclaude 's work to enable extensibility in planning, this is now possible
You can read about how this works in the blog Extending SQL in DataFusion: from ->> to TABLESAMPLE (https://datafusion.apache.org/blog/2026/01/12/extending-sql/)