[
https://issues.apache.org/jira/browse/CALCITE-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16903462#comment-16903462
]
Julian Hyde commented on CALCITE-1935:
--------------------------------------
* RelBuilder: I made the those changes. They look fine.
* CircularArrayList: I added it. It has a similar purpose to your Memory
class. I'll remove it.
* blank.iq: works OK for me. (Sometimes ExtensionSqlParser doesn't get rebuilt
properly in a dev sandbox. The solution is to clean and rebuild.)
* RexImpTable: It's definitely wrong to implement FINAL by calling "abs". It
fails if a measure is a string, for example. I don't see any other changes.
* Match: If I back out the hack, going back to {{.item("partition",
getPartitionKeys())}}, then {{testMatch}} fails only because the list "[]"
prints as a set "{}". I'm going to go with {{.item("partition",
getPartitionKeys().asList())}} unless you object.
* {{RexAction}} and {{RexPattern}} are very old classes, nothing to do with
{{MATCH_RECOGNIZE}} and they are and should remain deprecated.
My biggest remaining concern is that I can't get any MATCH_RECOGNIZE queries to
work in {{match.iq}}. I want to get at least one working, then we can iterate.
I've tried to make the simplest possible:
{code:java}
SELECT *
FROM "scott".emp MATCH_RECOGNIZE(
ORDER BY hiredate
MEASURES 1 AS m1
PATTERN (s up)
DEFINE up AS up.deptno < prev(up.deptno));
!ok
{code}
but I get a compilation error due to {{final int p8 = new int();}}
> Reference implementation for MATCH_RECOGNIZE
> --------------------------------------------
>
> Key: CALCITE-1935
> URL: https://issues.apache.org/jira/browse/CALCITE-1935
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Assignee: Julian Feinauer
> Priority: Major
> Labels: match
>
> We now have comprehensive support for parsing and validating MATCH_RECOGNIZE
> queries (see CALCITE-1570 and sub-tasks) but we cannot execute them. I know
> the purpose of this work is to do CEP within Flink, but a reference
> implementation that works on non-streaming data would be valuable.
> I propose that we add a class EnumerableMatch that can generate Java code to
> evaluate MATCH_RECOGNIZE queries on Enumerable data. It does not need to be
> efficient. I don't mind if it (say) buffers all the data in memory and makes
> O(n ^ 3) passes over it. People can make it more efficient over time.
> When we have a reference implementation, people can start playing with this
> feature. And we can start building a corpus of data sets, queries, and their
> expected result. The Flink implementation will be able to test against those
> same queries, and should give the same results, even though Flink will be
> reading streaming data.
> Let's create {{match.iq}} with the following query based on
> https://oracle-base.com/articles/12c/pattern-matching-in-oracle-database-12cr1:
> {code}
> !set outputformat mysql
> !use match
> SELECT *
> FROM sales_history MATCH_RECOGNIZE (
> PARTITION BY product
> ORDER BY tstamp
> MEASURES STRT.tstamp AS start_tstamp,
> LAST(UP.tstamp) AS peak_tstamp,
> LAST(DOWN.tstamp) AS end_tstamp,
> MATCH_NUMBER() AS mno
> ONE ROW PER MATCH
> AFTER MATCH SKIP TO LAST DOWN
> PATTERN (STRT UP+ FLAT* DOWN+)
> DEFINE
> UP AS UP.units_sold > PREV(UP.units_sold),
> FLAT AS FLAT.units_sold = PREV(FLAT.units_sold),
> DOWN AS DOWN.units_sold < PREV(DOWN.units_sold)
> ) MR
> ORDER BY MR.product, MR.start_tstamp;
> PRODUCT START_TSTAM PEAK_TSTAMP END_TSTAMP MNO
> ---------- ----------- ----------- ----------- ----------
> TWINKIES 01-OCT-2014 03-OCT-2014 06-OCT-2014 1
> TWINKIES 06-OCT-2014 08-OCT-2014 09-OCT-2014 2
> TWINKIES 09-OCT-2014 13-OCT-2014 16-OCT-2014 3
> TWINKIES 16-OCT-2014 18-OCT-2014 20-OCT-2014 4
> 4 rows selected.
> !ok
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)