[
https://issues.apache.org/jira/browse/FLINK-41693?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Martijn Visser updated FLINK-41693:
-----------------------------------
Description:
The docs list the greedy optional quantifier as supported, but {{A?}} behaves
reluctantly: Flink emits the match without A as soon as the next variable
accepts the row. With {{PATTERN (A? B)}}, both conditions true and two rows,
Trino returns one match with A=1, B=2 and Flink returns two matches that only
contain B. {{A\{0,1\}}} behaves the same.
{{MatchRecognizeITCase#testAggregates}} asserts this for its {{D?}}, so its
expected output changes with the fix. The fix depends on FLINK-41692, since
{{greedy()}} does not backtrack. FLINK-33538 describes the same early emission
in the Pattern API. The logical offsets example for {{PATTERN (A B? C)}} in the
docs shows the greedy mapping, which Flink does not produce.
was:
The docs list the greedy optional quantifier as supported, but {{A?}} behaves
reluctantly: Flink emits the match without A as soon as the next variable
accepts the row. With {{PATTERN (A? B)}}, both conditions true and two rows,
Trino returns one match with A=1, B=2 and Flink returns two matches that only
contain B. {{A\{0,1\}}} behaves the same.
{{MatchRecognizeITCase#testAggregates}} asserts this for its {{D?}}, so its
expected output changes with the fix. The fix depends on FLINK-D1, since
{{greedy()}} does not backtrack. FLINK-33538 describes the same early emission
in the Pattern API.
> MATCH_RECOGNIZE optional variable behaves reluctantly
> -----------------------------------------------------
>
> Key: FLINK-41693
> URL: https://issues.apache.org/jira/browse/FLINK-41693
> Project: Flink
> Issue Type: Bug
> Components: Library / CEP
> Reporter: Martijn Visser
> Priority: Major
>
> The docs list the greedy optional quantifier as supported, but {{A?}} behaves
> reluctantly: Flink emits the match without A as soon as the next variable
> accepts the row. With {{PATTERN (A? B)}}, both conditions true and two rows,
> Trino returns one match with A=1, B=2 and Flink returns two matches that only
> contain B. {{A\{0,1\}}} behaves the same.
> {{MatchRecognizeITCase#testAggregates}} asserts this for its {{D?}}, so its
> expected output changes with the fix. The fix depends on FLINK-41692, since
> {{greedy()}} does not backtrack. FLINK-33538 describes the same early
> emission in the Pattern API. The logical offsets example for {{PATTERN (A B?
> C)}} in the docs shows the greedy mapping, which Flink does not produce.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)