aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/match_recognize
diff options
context:
space:
mode:
authorudovichenko-r <udovichenko-r@yandex-team.com>2024-11-19 14:58:38 +0300
committerudovichenko-r <udovichenko-r@yandex-team.com>2024-11-19 15:16:27 +0300
commit24521403b1c44303e043ba540c09b1fe991c7474 (patch)
tree341d1e7206bc7c143d04d2d96f05b6dc0655606d /yql/essentials/tests/sql/suites/match_recognize
parent72b3cd51dc3fb9d16975d353ea82fd85701393cc (diff)
downloadydb-24521403b1c44303e043ba540c09b1fe991c7474.tar.gz
YQL-19206 Move contrib/ydb/library/yql/tests/sql/suites -> yql/essentials/tests/sql/suites
commit_hash:d0ef1f92b09c94db7c2408f946d2a4c62b603f00
Diffstat (limited to 'yql/essentials/tests/sql/suites/match_recognize')
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/after_match_skip_past_last_row.sql19
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/alerts-streaming.sql61
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/alerts.sql61
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/alerts_without_order.sql60
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/default.cfg0
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/permute.sql35
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/simple_paritioning-streaming.sql45
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/simple_paritioning.sql46
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/test_type-streaming.sql75
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/test_type.sql76
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/test_type_predicate.cfg1
-rw-r--r--yql/essentials/tests/sql/suites/match_recognize/test_type_predicate.sql18
12 files changed, 497 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/match_recognize/after_match_skip_past_last_row.sql b/yql/essentials/tests/sql/suites/match_recognize/after_match_skip_past_last_row.sql
new file mode 100644
index 0000000000..79d9c76220
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/after_match_skip_past_last_row.sql
@@ -0,0 +1,19 @@
+pragma FeatureR010="prototype";
+pragma config.flags("MatchRecognizeStream", "disable");
+
+$input = SELECT * FROM AS_TABLE([
+ <|time:0|>,
+ <|time:1|>,
+ <|time:2|>,
+ <|time:3|>,
+]);
+
+SELECT * FROM $input MATCH_RECOGNIZE(
+ ORDER BY CAST(time as Timestamp)
+ MEASURES
+ FIRST(X.time) as first_time,
+ LAST(X.time) as last_time
+ PATTERN (X{2})
+ DEFINE
+ X as True
+);
diff --git a/yql/essentials/tests/sql/suites/match_recognize/alerts-streaming.sql b/yql/essentials/tests/sql/suites/match_recognize/alerts-streaming.sql
new file mode 100644
index 0000000000..efa5bef17a
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/alerts-streaming.sql
@@ -0,0 +1,61 @@
+$osquery_data = [
+<|dt:1688910000, host:"fqdn1", ev_type:"someEv", ev_status:"", user:"", vpn:false, |>,
+<|dt:1688910050, host:"fqdn2", ev_type:"login", ev_status:"success", user:"", vpn:true, |>,
+<|dt:1688910100, host:"fqdn1", ev_type:"login", ev_status:"success", user:"", vpn:true, |>,
+<|dt:1688910220, host:"fqdn1", ev_type:"login", ev_status:"success", user:"", vpn:false, |>,
+<|dt:1688910300, host:"fqdn1", ev_type:"delete_all", ev_status:"", user:"", vpn:false, |>,
+<|dt:1688910400, host:"fqdn2", ev_type:"delete_all", ev_status:"", user:"", vpn:false, |>,
+<|dt:1688910500, host:"fqdn1", ev_type:"login", ev_status:"failed", user:"user1", vpn:false, |>,
+<|dt:1688910500, host:"fqdn1", ev_type:"login", ev_status:"failed", user:"user2", vpn:false, |>,
+<|dt:1688910600, host:"fqdn", ev_type:"someEv", ev_status:"", user:"user1", vpn:false, |>,
+<|dt:1688910800, host:"fqdn2", ev_type:"login", ev_status:"failed", user:"user1", vpn:false, |>,
+<|dt:1688910900, host:"fqdn2", ev_type:"login", ev_status:"failed", user:"user2", vpn:false, |>,
+<|dt:1688911000, host:"fqdn2", ev_type:"login", ev_status:"success", user:"user1", vpn:false, |>,
+];
+
+pragma FeatureR010="prototype";
+pragma config.flags("MatchRecognizeStream", "force");
+
+SELECT *
+FROM AS_TABLE($osquery_data) MATCH_RECOGNIZE(
+ ORDER BY CAST(dt as Timestamp)
+ MEASURES
+ LAST(SUSPICIOUS_ACTION_SOON.dt) as suspicious_action_dt,
+ LAST(LOGIN_SUCCESS_REMOTE.host) as remote_login_host,
+ LAST(LOGIN_SUCCESS_REMOTE.user) as remote_login_user,
+ LAST(LOGIN_SUCCESS_REMOTE.dt) as t,
+ FIRST(LOGIN_FAILED_SAME_USER.dt) as brutforce_begin,
+ FIRST(LOGIN_SUCCESS_SAME_USER.dt) as brutforce_end,
+ LAST(LOGIN_SUCCESS_SAME_USER.user) as brutforce_login
+
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ LOGIN_SUCCESS_REMOTE ANY_ROW* (SUSPICIOUS_ACTION_SOON | SUSPICIOUS_ACTION_TIMEOUT) |
+ (LOGIN_FAILED_SAME_USER ANY_ROW*){2,} LOGIN_SUCCESS_SAME_USER
+ )
+ DEFINE
+ LOGIN_SUCCESS_REMOTE as
+ LOGIN_SUCCESS_REMOTE.ev_type = "login" and
+ LOGIN_SUCCESS_REMOTE.ev_status = "success" and
+ LOGIN_SUCCESS_REMOTE.vpn = true,
+ SUSPICIOUS_ACTION_SOON as
+ SUSPICIOUS_ACTION_SOON.host = LAST(LOGIN_SUCCESS_REMOTE.host) and
+ SUSPICIOUS_ACTION_SOON.ev_type = "delete_all" and
+ SUSPICIOUS_ACTION_SOON.dt - LAST(LOGIN_SUCCESS_REMOTE.dt) < 1000,
+ SUSPICIOUS_ACTION_TIMEOUT as
+ SUSPICIOUS_ACTION_TIMEOUT.dt - LAST(LOGIN_SUCCESS_REMOTE.dt) >= 1000,
+
+ LOGIN_FAILED_SAME_USER as
+ LOGIN_FAILED_SAME_USER.ev_type = "login" and
+ LOGIN_FAILED_SAME_USER.ev_status <> "success" and
+ (LAST(LOGIN_FAILED_SAME_USER.user) IS NULL
+ or LAST(LOGIN_FAILED_SAME_USER.user) = LOGIN_FAILED_SAME_USER.user
+ ),
+ LOGIN_SUCCESS_SAME_USER as
+ LOGIN_SUCCESS_SAME_USER.ev_type = "login" and
+ LOGIN_SUCCESS_SAME_USER.ev_status = "success" and
+ LOGIN_SUCCESS_SAME_USER.user = LAST(LOGIN_FAILED_SAME_USER.user)
+) AS MATCHED
+;
+
diff --git a/yql/essentials/tests/sql/suites/match_recognize/alerts.sql b/yql/essentials/tests/sql/suites/match_recognize/alerts.sql
new file mode 100644
index 0000000000..65aac91efd
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/alerts.sql
@@ -0,0 +1,61 @@
+$osquery_data = [
+<|dt:1688910000, host:"fqdn1", ev_type:"someEv", ev_status:"", user:"", vpn:false, |>,
+<|dt:1688910050, host:"fqdn2", ev_type:"login", ev_status:"success", user:"", vpn:true, |>,
+<|dt:1688910100, host:"fqdn1", ev_type:"login", ev_status:"success", user:"", vpn:true, |>,
+<|dt:1688910220, host:"fqdn1", ev_type:"login", ev_status:"success", user:"", vpn:false, |>,
+<|dt:1688910300, host:"fqdn1", ev_type:"delete_all", ev_status:"", user:"", vpn:false, |>,
+<|dt:1688910400, host:"fqdn2", ev_type:"delete_all", ev_status:"", user:"", vpn:false, |>,
+<|dt:1688910500, host:"fqdn1", ev_type:"login", ev_status:"failed", user:"user1", vpn:false, |>,
+<|dt:1688910500, host:"fqdn1", ev_type:"login", ev_status:"failed", user:"user2", vpn:false, |>,
+<|dt:1688910600, host:"fqdn", ev_type:"someEv", ev_status:"", user:"user1", vpn:false, |>,
+<|dt:1688910800, host:"fqdn2", ev_type:"login", ev_status:"failed", user:"user1", vpn:false, |>,
+<|dt:1688910900, host:"fqdn2", ev_type:"login", ev_status:"failed", user:"user2", vpn:false, |>,
+<|dt:1688911000, host:"fqdn2", ev_type:"login", ev_status:"success", user:"user1", vpn:false, |>,
+];
+
+pragma FeatureR010="prototype";
+pragma config.flags("MatchRecognizeStream", "disable");
+
+SELECT *
+FROM AS_TABLE($osquery_data) MATCH_RECOGNIZE(
+ ORDER BY CAST(dt as Timestamp)
+ MEASURES
+ LAST(SUSPICIOUS_ACTION_SOON.dt) as suspicious_action_dt,
+ LAST(LOGIN_SUCCESS_REMOTE.host) as remote_login_host,
+ LAST(LOGIN_SUCCESS_REMOTE.user) as remote_login_user,
+ LAST(LOGIN_SUCCESS_REMOTE.dt) as t,
+ FIRST(LOGIN_FAILED_SAME_USER.dt) as brutforce_begin,
+ FIRST(LOGIN_SUCCESS_SAME_USER.dt) as brutforce_end,
+ LAST(LOGIN_SUCCESS_SAME_USER.user) as brutforce_login
+
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ LOGIN_SUCCESS_REMOTE ANY_ROW* (SUSPICIOUS_ACTION_SOON | SUSPICIOUS_ACTION_TIMEOUT) |
+ (LOGIN_FAILED_SAME_USER ANY_ROW*){2,} LOGIN_SUCCESS_SAME_USER
+ )
+ DEFINE
+ LOGIN_SUCCESS_REMOTE as
+ LOGIN_SUCCESS_REMOTE.ev_type = "login" and
+ LOGIN_SUCCESS_REMOTE.ev_status = "success" and
+ LOGIN_SUCCESS_REMOTE.vpn = true,
+ SUSPICIOUS_ACTION_SOON as
+ SUSPICIOUS_ACTION_SOON.host = LAST(LOGIN_SUCCESS_REMOTE.host) and
+ SUSPICIOUS_ACTION_SOON.ev_type = "delete_all" and
+ SUSPICIOUS_ACTION_SOON.dt - LAST(LOGIN_SUCCESS_REMOTE.dt) < 1000,
+ SUSPICIOUS_ACTION_TIMEOUT as
+ SUSPICIOUS_ACTION_TIMEOUT.dt - LAST(LOGIN_SUCCESS_REMOTE.dt) >= 1000,
+
+ LOGIN_FAILED_SAME_USER as
+ LOGIN_FAILED_SAME_USER.ev_type = "login" and
+ LOGIN_FAILED_SAME_USER.ev_status <> "success" and
+ (LAST(LOGIN_FAILED_SAME_USER.user) IS NULL
+ or LAST(LOGIN_FAILED_SAME_USER.user) = LOGIN_FAILED_SAME_USER.user
+ ),
+ LOGIN_SUCCESS_SAME_USER as
+ LOGIN_SUCCESS_SAME_USER.ev_type = "login" and
+ LOGIN_SUCCESS_SAME_USER.ev_status = "success" and
+ LOGIN_SUCCESS_SAME_USER.user = LAST(LOGIN_FAILED_SAME_USER.user)
+) AS MATCHED
+;
+
diff --git a/yql/essentials/tests/sql/suites/match_recognize/alerts_without_order.sql b/yql/essentials/tests/sql/suites/match_recognize/alerts_without_order.sql
new file mode 100644
index 0000000000..4773e16588
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/alerts_without_order.sql
@@ -0,0 +1,60 @@
+$osquery_data = [
+<|dt:1688910000, host:"fqdn1", ev_type:"someEv", ev_status:"", user:"", vpn:false, |>,
+<|dt:1688910050, host:"fqdn2", ev_type:"login", ev_status:"success", user:"", vpn:true, |>,
+<|dt:1688910100, host:"fqdn1", ev_type:"login", ev_status:"success", user:"", vpn:true, |>,
+<|dt:1688910220, host:"fqdn1", ev_type:"login", ev_status:"success", user:"", vpn:false, |>,
+<|dt:1688910300, host:"fqdn1", ev_type:"delete_all", ev_status:"", user:"", vpn:false, |>,
+<|dt:1688910400, host:"fqdn2", ev_type:"delete_all", ev_status:"", user:"", vpn:false, |>,
+<|dt:1688910500, host:"fqdn1", ev_type:"login", ev_status:"failed", user:"user1", vpn:false, |>,
+<|dt:1688910500, host:"fqdn1", ev_type:"login", ev_status:"failed", user:"user2", vpn:false, |>,
+<|dt:1688910600, host:"fqdn", ev_type:"someEv", ev_status:"", user:"user1", vpn:false, |>,
+<|dt:1688910800, host:"fqdn2", ev_type:"login", ev_status:"failed", user:"user1", vpn:false, |>,
+<|dt:1688910900, host:"fqdn2", ev_type:"login", ev_status:"failed", user:"user2", vpn:false, |>,
+<|dt:1688911000, host:"fqdn2", ev_type:"login", ev_status:"success", user:"user1", vpn:false, |>,
+];
+
+pragma FeatureR010="prototype";
+pragma config.flags("MatchRecognizeStream", "disable");
+
+SELECT *
+FROM AS_TABLE($osquery_data) MATCH_RECOGNIZE(
+ MEASURES
+ LAST(SUSPICIOUS_ACTION_SOON.dt) as suspicious_action_dt,
+ LAST(LOGIN_SUCCESS_REMOTE.host) as remote_login_host,
+ LAST(LOGIN_SUCCESS_REMOTE.user) as remote_login_user,
+ LAST(LOGIN_SUCCESS_REMOTE.dt) as t,
+ FIRST(LOGIN_FAILED_SAME_USER.dt) as brutforce_begin,
+ FIRST(LOGIN_SUCCESS_SAME_USER.dt) as brutforce_end,
+ LAST(LOGIN_SUCCESS_SAME_USER.user) as brutforce_login
+
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ LOGIN_SUCCESS_REMOTE ANY_ROW* (SUSPICIOUS_ACTION_SOON | SUSPICIOUS_ACTION_TIMEOUT) |
+ (LOGIN_FAILED_SAME_USER ANY_ROW*){2,} LOGIN_SUCCESS_SAME_USER
+ )
+ DEFINE
+ LOGIN_SUCCESS_REMOTE as
+ LOGIN_SUCCESS_REMOTE.ev_type = "login" and
+ LOGIN_SUCCESS_REMOTE.ev_status = "success" and
+ LOGIN_SUCCESS_REMOTE.vpn = true,
+ SUSPICIOUS_ACTION_SOON as
+ SUSPICIOUS_ACTION_SOON.host = LAST(LOGIN_SUCCESS_REMOTE.host) and
+ SUSPICIOUS_ACTION_SOON.ev_type = "delete_all" and
+ SUSPICIOUS_ACTION_SOON.dt - LAST(LOGIN_SUCCESS_REMOTE.dt) < 1000,
+ SUSPICIOUS_ACTION_TIMEOUT as
+ SUSPICIOUS_ACTION_TIMEOUT.dt - LAST(LOGIN_SUCCESS_REMOTE.dt) >= 1000,
+
+ LOGIN_FAILED_SAME_USER as
+ LOGIN_FAILED_SAME_USER.ev_type = "login" and
+ LOGIN_FAILED_SAME_USER.ev_status <> "success" and
+ (LAST(LOGIN_FAILED_SAME_USER.user) IS NULL
+ or LAST(LOGIN_FAILED_SAME_USER.user) = LOGIN_FAILED_SAME_USER.user
+ ),
+ LOGIN_SUCCESS_SAME_USER as
+ LOGIN_SUCCESS_SAME_USER.ev_type = "login" and
+ LOGIN_SUCCESS_SAME_USER.ev_status = "success" and
+ LOGIN_SUCCESS_SAME_USER.user = LAST(LOGIN_FAILED_SAME_USER.user)
+) AS MATCHED
+;
+
diff --git a/yql/essentials/tests/sql/suites/match_recognize/default.cfg b/yql/essentials/tests/sql/suites/match_recognize/default.cfg
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/default.cfg
diff --git a/yql/essentials/tests/sql/suites/match_recognize/permute.sql b/yql/essentials/tests/sql/suites/match_recognize/permute.sql
new file mode 100644
index 0000000000..614f5b77e0
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/permute.sql
@@ -0,0 +1,35 @@
+$data = [
+<|dt:1688910000, event:"A"|>,
+<|dt:1688910100, event:"B"|>,
+<|dt:1688910200, event:"C"|>,
+<|dt:1688910300, event:"A"|>,
+<|dt:1688910400, event:"C"|>,
+<|dt:1688910500, event:"D"|>,
+<|dt:1688910500, event:"C"|>,
+<|dt:1688910600, event:"B"|>,
+<|dt:1688910800, event:"A"|>,
+<|dt:1688910900, event:"C"|>,
+<|dt:1688911000, event:"B"|>,
+];
+
+pragma FeatureR010="prototype";
+
+SELECT *
+FROM AS_TABLE($data) MATCH_RECOGNIZE(
+ ORDER BY CAST(dt as Timestamp)
+ MEASURES
+ FIRST(A.dt) as a,
+ FIRST(B.dt) as b,
+ FIRST(C.dt) as c
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ PERMUTE(A, B, C)
+ )
+ DEFINE
+ A as A.event = "A",
+ B as B.event = "B",
+ C as C.event = "C"
+ ) AS MATCHED
+;
+
diff --git a/yql/essentials/tests/sql/suites/match_recognize/simple_paritioning-streaming.sql b/yql/essentials/tests/sql/suites/match_recognize/simple_paritioning-streaming.sql
new file mode 100644
index 0000000000..460af6b5da
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/simple_paritioning-streaming.sql
@@ -0,0 +1,45 @@
+pragma FeatureR010="prototype";
+pragma config.flags("MatchRecognizeStream", "force");
+USE plato;
+
+$data = [
+<|dt:15, host:"fqdn1", key:0|>,
+<|dt:16, host:"fqdn1", key:1|>,
+<|dt:17, host:"fqdn1", key:2|>,
+<|dt:18, host:"fqdn1", key:3|>,
+<|dt:19, host:"fqdn1", key:4|>,
+<|dt:20, host:"fqdn1", key:5|>,
+<|dt:21, host:"fqdn1", key:6|>,
+<|dt:22, host:"fqdn1", key:7|>,
+<|dt:23, host:"fqdn_2", key:0|>,
+<|dt:24, host:"fqdn1", key:8|>,
+<|dt:25, host:"fqdn1", key:9|>,
+<|dt:26, host:"fqdn1", key:10|>,
+<|dt:27, host:"fqdn__3", key:30|>,
+<|dt:28, host:"fqdn__3", key:1|>,
+<|dt:29, host:"fqdn__3", key:2|>,
+<|dt:30, host:"fqdn__3", key:3|>,
+<|dt:31, host:"fqdn__3", key:4|>,
+<|dt:32, host:"fqdn1", key:11|>,
+<|dt:33, host:"fqdn1", key:12|>,
+<|dt:34, host:"fqdn1", key:13|>,
+<|dt:35, host:"fqdn1", key:14|>,
+<|dt:36, host:"fqdn__3", key:15|>
+];
+
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ PARTITION BY host
+ ORDER BY CAST(dt as Timestamp)
+ MEASURES
+ Last(Q.dt) as T,
+ First(Y.key) as Key
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ (Y Q)
+ )
+ DEFINE
+ Y as (Y.key) % 3 = 0,
+ Q as (Q.key) % 3 <> 0
+ ) as MR
+ORDER BY MR.T;
diff --git a/yql/essentials/tests/sql/suites/match_recognize/simple_paritioning.sql b/yql/essentials/tests/sql/suites/match_recognize/simple_paritioning.sql
new file mode 100644
index 0000000000..1c60d89462
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/simple_paritioning.sql
@@ -0,0 +1,46 @@
+pragma FeatureR010="prototype";
+pragma config.flags("MatchRecognizeStream", "disable");
+
+USE plato;
+
+$data = [
+<|dt:15, host:"fqdn1", key:0|>,
+<|dt:16, host:"fqdn1", key:1|>,
+<|dt:17, host:"fqdn1", key:2|>,
+<|dt:18, host:"fqdn1", key:3|>,
+<|dt:19, host:"fqdn1", key:4|>,
+<|dt:20, host:"fqdn1", key:5|>,
+<|dt:21, host:"fqdn1", key:6|>,
+<|dt:22, host:"fqdn1", key:7|>,
+<|dt:23, host:"fqdn_2", key:0|>,
+<|dt:24, host:"fqdn1", key:8|>,
+<|dt:25, host:"fqdn1", key:9|>,
+<|dt:26, host:"fqdn1", key:10|>,
+<|dt:27, host:"fqdn__3", key:30|>,
+<|dt:28, host:"fqdn__3", key:1|>,
+<|dt:29, host:"fqdn__3", key:2|>,
+<|dt:30, host:"fqdn__3", key:3|>,
+<|dt:31, host:"fqdn__3", key:4|>,
+<|dt:32, host:"fqdn1", key:11|>,
+<|dt:33, host:"fqdn1", key:12|>,
+<|dt:34, host:"fqdn1", key:13|>,
+<|dt:35, host:"fqdn1", key:14|>,
+<|dt:36, host:"fqdn__3", key:15|>
+];
+
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ PARTITION BY host
+ ORDER BY dt
+ MEASURES
+ Last(Q.dt) as T,
+ First(Y.key) as Key
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ (Y Q)
+ )
+ DEFINE
+ Y as (Y.key) % 3 = 0,
+ Q as (Q.key) % 3 <> 0
+ ) as MR
+ORDER BY MR.T;
diff --git a/yql/essentials/tests/sql/suites/match_recognize/test_type-streaming.sql b/yql/essentials/tests/sql/suites/match_recognize/test_type-streaming.sql
new file mode 100644
index 0000000000..d742cae284
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/test_type-streaming.sql
@@ -0,0 +1,75 @@
+pragma FeatureR010="prototype";
+pragma config.flags("MatchRecognizeStream", "force");
+USE plato;
+
+$data = [<|dt:4, host:"fqdn1", key:14|>];
+
+-- NoPartitionNoMeasure
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ ORDER BY CAST(dt as Timestamp)
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ Y
+ )
+ DEFINE
+ Y as NULL
+ );
+
+--NoPartitionStringMeasure
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ ORDER BY CAST(dt as Timestamp)
+ MEASURES
+ "SomeString" as Measure1
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ Q
+ )
+ DEFINE
+ Q as TRUE
+ );
+
+--IntPartitionColNoMeasure
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ PARTITION BY key
+ ORDER BY CAST(dt as Timestamp)
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ L
+ )
+ DEFINE
+ L as JUST(TRUE)
+ );
+
+--StringPartitionColStringMeasure
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ PARTITION BY host
+ ORDER BY CAST(dt as Timestamp)
+ MEASURES
+ "SomeString" as Measure1
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ Y
+ )
+ DEFINE
+ Y as TRUE
+ );
+
+--TwoPartitionColsTwoMeasures
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ PARTITION BY host, key
+ ORDER BY CAST(dt as Timestamp)
+ MEASURES
+ "SomeString" as S,
+ 345 as I
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ Q
+ )
+ DEFINE
+ Q as TRUE
+);
diff --git a/yql/essentials/tests/sql/suites/match_recognize/test_type.sql b/yql/essentials/tests/sql/suites/match_recognize/test_type.sql
new file mode 100644
index 0000000000..a92b5672e4
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/test_type.sql
@@ -0,0 +1,76 @@
+pragma FeatureR010="prototype";
+pragma config.flags("MatchRecognizeStream", "disable");
+USE plato;
+
+$data = [<|dt:4, host:"fqdn1", key:14|>];
+
+
+-- NoPartitionNoMeasure
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ ORDER BY CAST(dt as Timestamp)
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ Y
+ )
+ DEFINE
+ Y as NULL
+);
+
+--NoPartitionStringMeasure
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ ORDER BY CAST(dt as Timestamp)
+ MEASURES
+ "SomeString" as Measure1
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ Q
+ )
+ DEFINE
+ Q as TRUE
+);
+
+--IntPartitionColNoMeasure
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ PARTITION BY dt
+ ORDER BY CAST(dt as Timestamp)
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ L
+ )
+ DEFINE
+ L as JUST(TRUE)
+);
+
+--StringPartitionColStringMeasure
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ PARTITION BY host
+ ORDER BY CAST(dt as Timestamp)
+ MEASURES
+ "SomeString" as Measure1
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ Y
+ )
+ DEFINE
+ Y as TRUE
+);
+
+--TwoPartitionColsTwoMeasures
+select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ PARTITION BY host, dt
+ ORDER BY CAST(dt as Timestamp)
+ MEASURES
+ "SomeString" as S,
+ 345 as I
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ Q
+ )
+ DEFINE
+ Q as JUST(TRUE)
+);
diff --git a/yql/essentials/tests/sql/suites/match_recognize/test_type_predicate.cfg b/yql/essentials/tests/sql/suites/match_recognize/test_type_predicate.cfg
new file mode 100644
index 0000000000..5dae597903
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/test_type_predicate.cfg
@@ -0,0 +1 @@
+xfail
diff --git a/yql/essentials/tests/sql/suites/match_recognize/test_type_predicate.sql b/yql/essentials/tests/sql/suites/match_recognize/test_type_predicate.sql
new file mode 100644
index 0000000000..b19e7c6671
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/match_recognize/test_type_predicate.sql
@@ -0,0 +1,18 @@
+pragma FeatureR010="prototype";
+pragma config.flags("MatchRecognizeStream", "disable");
+
+USE plato;
+
+$data = [<||>];
+
+$BadPredicate = select TableRow() from (select * from AS_TABLE($data) MATCH_RECOGNIZE(
+ ONE ROW PER MATCH
+ AFTER MATCH SKIP TO NEXT ROW
+ PATTERN (
+ A
+ )
+ DEFINE
+ A as 123 -- must fail, Bool expected
+));
+
+select FormatType(TypeOf($BadPredicate));