1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345 |
- package processors
- import (
- "github.com/emqx/kuiper/xstream"
- "github.com/emqx/kuiper/xstream/api"
- "testing"
- )
- func TestWindow(t *testing.T) {
- //Reset
- streamList := []string{"demo", "demoError", "demo1", "sessionDemo"}
- handleStream(false, streamList, t)
- var tests = []ruleTest{
- {
- name: `TestWindowRule1`,
- sql: `SELECT * FROM demo GROUP BY HOPPINGWINDOW(ss, 2, 1)`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- "size": float64(3),
- "ts": float64(1541152486013),
- }, {
- "color": "blue",
- "size": float64(6),
- "ts": float64(1541152486822),
- }},
- {{
- "color": "red",
- "size": float64(3),
- "ts": float64(1541152486013),
- }, {
- "color": "blue",
- "size": float64(6),
- "ts": float64(1541152486822),
- }, {
- "color": "blue",
- "size": float64(2),
- "ts": float64(1541152487632),
- }},
- {{
- "color": "blue",
- "size": float64(2),
- "ts": float64(1541152487632),
- }, {
- "color": "yellow",
- "size": float64(4),
- "ts": float64(1541152488442),
- }},
- {{
- "color": "yellow",
- "size": float64(4),
- "ts": float64(1541152488442),
- }, {
- "color": "red",
- "size": float64(1),
- "ts": float64(1541152489252),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demo_0_exceptions_total": int64(0),
- "op_1_preprocessor_demo_0_process_latency_us": int64(0),
- "op_1_preprocessor_demo_0_records_in_total": int64(5),
- "op_1_preprocessor_demo_0_records_out_total": int64(5),
- "op_3_project_0_exceptions_total": int64(0),
- "op_3_project_0_process_latency_us": int64(0),
- "op_3_project_0_records_in_total": int64(4),
- "op_3_project_0_records_out_total": int64(4),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(4),
- "sink_mockSink_0_records_out_total": int64(4),
- "source_demo_0_exceptions_total": int64(0),
- "source_demo_0_records_in_total": int64(5),
- "source_demo_0_records_out_total": int64(5),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(5),
- "op_2_window_0_records_out_total": int64(4),
- },
- }, {
- name: `TestWindowRule2`,
- sql: `SELECT color, ts FROM demo where size > 2 GROUP BY tumblingwindow(ss, 1)`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- "ts": float64(1541152486013),
- }, {
- "color": "blue",
- "ts": float64(1541152486822),
- }},
- {{
- "color": "yellow",
- "ts": float64(1541152488442),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demo_0_exceptions_total": int64(0),
- "op_1_preprocessor_demo_0_process_latency_us": int64(0),
- "op_1_preprocessor_demo_0_records_in_total": int64(5),
- "op_1_preprocessor_demo_0_records_out_total": int64(5),
- "op_4_project_0_exceptions_total": int64(0),
- "op_4_project_0_process_latency_us": int64(0),
- "op_4_project_0_records_in_total": int64(2),
- "op_4_project_0_records_out_total": int64(2),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(2),
- "sink_mockSink_0_records_out_total": int64(2),
- "source_demo_0_exceptions_total": int64(0),
- "source_demo_0_records_in_total": int64(5),
- "source_demo_0_records_out_total": int64(5),
- "op_3_window_0_exceptions_total": int64(0),
- "op_3_window_0_process_latency_us": int64(0),
- "op_3_window_0_records_in_total": int64(3),
- "op_3_window_0_records_out_total": int64(2),
- "op_2_filter_0_exceptions_total": int64(0),
- "op_2_filter_0_process_latency_us": int64(0),
- "op_2_filter_0_records_in_total": int64(5),
- "op_2_filter_0_records_out_total": int64(3),
- },
- }, {
- name: `TestWindowRule3`,
- sql: `SELECT color, temp, ts FROM demo INNER JOIN demo1 ON demo.ts = demo1.ts GROUP BY SlidingWindow(ss, 1)`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- "temp": 25.5,
- "ts": float64(1541152486013),
- }}, {{
- "color": "red",
- "temp": 25.5,
- "ts": float64(1541152486013),
- }}, {{
- "color": "red",
- "temp": 25.5,
- "ts": float64(1541152486013),
- }}, {{
- "color": "blue",
- "temp": 28.1,
- "ts": float64(1541152487632),
- }}, {{
- "color": "blue",
- "temp": 28.1,
- "ts": float64(1541152487632),
- }}, {{
- "color": "blue",
- "temp": 28.1,
- "ts": float64(1541152487632),
- }, {
- "color": "yellow",
- "temp": 27.4,
- "ts": float64(1541152488442),
- }}, {{
- "color": "yellow",
- "temp": 27.4,
- "ts": float64(1541152488442),
- }}, {{
- "color": "yellow",
- "temp": 27.4,
- "ts": float64(1541152488442),
- }, {
- "color": "red",
- "temp": 25.5,
- "ts": float64(1541152489252),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demo_0_exceptions_total": int64(0),
- "op_1_preprocessor_demo_0_process_latency_us": int64(0),
- "op_1_preprocessor_demo_0_records_in_total": int64(5),
- "op_1_preprocessor_demo_0_records_out_total": int64(5),
- "op_2_preprocessor_demo1_0_exceptions_total": int64(0),
- "op_2_preprocessor_demo1_0_process_latency_us": int64(0),
- "op_2_preprocessor_demo1_0_records_in_total": int64(5),
- "op_2_preprocessor_demo1_0_records_out_total": int64(5),
- "op_5_project_0_exceptions_total": int64(0),
- "op_5_project_0_process_latency_us": int64(0),
- "op_5_project_0_records_in_total": int64(8),
- "op_5_project_0_records_out_total": int64(8),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(8),
- "sink_mockSink_0_records_out_total": int64(8),
- "source_demo_0_exceptions_total": int64(0),
- "source_demo_0_records_in_total": int64(5),
- "source_demo_0_records_out_total": int64(5),
- "source_demo1_0_exceptions_total": int64(0),
- "source_demo1_0_records_in_total": int64(5),
- "source_demo1_0_records_out_total": int64(5),
- "op_3_window_0_exceptions_total": int64(0),
- "op_3_window_0_process_latency_us": int64(0),
- "op_3_window_0_records_in_total": int64(10),
- "op_3_window_0_records_out_total": int64(10),
- "op_4_join_0_exceptions_total": int64(0),
- "op_4_join_0_process_latency_us": int64(0),
- "op_4_join_0_records_in_total": int64(10),
- "op_4_join_0_records_out_total": int64(8),
- },
- t: &xstream.PrintableTopo{
- Sources: []string{"source_demo", "source_demo1"},
- Edges: map[string][]string{
- "source_demo": {"op_1_preprocessor_demo"},
- "source_demo1": {"op_2_preprocessor_demo1"},
- "op_1_preprocessor_demo": {"op_3_window"},
- "op_2_preprocessor_demo1": {"op_3_window"},
- "op_3_window": {"op_4_join"},
- "op_4_join": {"op_5_project"},
- "op_5_project": {"sink_mockSink"},
- },
- },
- }, {
- name: `TestWindowRule4`,
- sql: `SELECT color FROM demo GROUP BY SlidingWindow(ss, 2), color ORDER BY color`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- }}, {{
- "color": "blue",
- }, {
- "color": "red",
- }}, {{
- "color": "blue",
- }, {
- "color": "red",
- }}, {{
- "color": "blue",
- }, {
- "color": "yellow",
- }}, {{
- "color": "blue",
- }, {
- "color": "red",
- }, {
- "color": "yellow",
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demo_0_exceptions_total": int64(0),
- "op_1_preprocessor_demo_0_process_latency_us": int64(0),
- "op_1_preprocessor_demo_0_records_in_total": int64(5),
- "op_1_preprocessor_demo_0_records_out_total": int64(5),
- "op_5_project_0_exceptions_total": int64(0),
- "op_5_project_0_process_latency_us": int64(0),
- "op_5_project_0_records_in_total": int64(5),
- "op_5_project_0_records_out_total": int64(5),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(5),
- "sink_mockSink_0_records_out_total": int64(5),
- "source_demo_0_exceptions_total": int64(0),
- "source_demo_0_records_in_total": int64(5),
- "source_demo_0_records_out_total": int64(5),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(5),
- "op_2_window_0_records_out_total": int64(5),
- "op_3_aggregate_0_exceptions_total": int64(0),
- "op_3_aggregate_0_process_latency_us": int64(0),
- "op_3_aggregate_0_records_in_total": int64(5),
- "op_3_aggregate_0_records_out_total": int64(5),
- "op_4_order_0_exceptions_total": int64(0),
- "op_4_order_0_process_latency_us": int64(0),
- "op_4_order_0_records_in_total": int64(5),
- "op_4_order_0_records_out_total": int64(5),
- },
- }, {
- name: `TestWindowRule5`,
- sql: `SELECT temp FROM sessionDemo GROUP BY SessionWindow(ss, 2, 1) `,
- r: [][]map[string]interface{}{
- {{
- "temp": 25.5,
- }, {
- "temp": 27.5,
- }}, {{
- "temp": 28.1,
- }, {
- "temp": 27.4,
- }, {
- "temp": 25.5,
- }}, {{
- "temp": 26.2,
- }, {
- "temp": 26.8,
- }, {
- "temp": 28.9,
- }, {
- "temp": 29.1,
- }, {
- "temp": 32.2,
- }}, {{
- "temp": 30.9,
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_sessionDemo_0_exceptions_total": int64(0),
- "op_1_preprocessor_sessionDemo_0_process_latency_us": int64(0),
- "op_1_preprocessor_sessionDemo_0_records_in_total": int64(11),
- "op_1_preprocessor_sessionDemo_0_records_out_total": int64(11),
- "op_3_project_0_exceptions_total": int64(0),
- "op_3_project_0_process_latency_us": int64(0),
- "op_3_project_0_records_in_total": int64(4),
- "op_3_project_0_records_out_total": int64(4),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(4),
- "sink_mockSink_0_records_out_total": int64(4),
- "source_sessionDemo_0_exceptions_total": int64(0),
- "source_sessionDemo_0_records_in_total": int64(11),
- "source_sessionDemo_0_records_out_total": int64(11),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(11),
- "op_2_window_0_records_out_total": int64(4),
- },
- }, {
- name: `TestWindowRule6`,
- sql: `SELECT max(temp) as m, count(color) as c FROM demo INNER JOIN demo1 ON demo.ts = demo1.ts GROUP BY SlidingWindow(ss, 1)`,
- r: [][]map[string]interface{}{
- {{
- "m": 25.5,
- "c": float64(1),
- }}, {{
- "m": 25.5,
- "c": float64(1),
- }}, {{
- "m": 25.5,
- "c": float64(1),
- }}, {{
- "m": 28.1,
- "c": float64(1),
- }}, {{
- "m": 28.1,
- "c": float64(1),
- }}, {{
- "m": 28.1,
- "c": float64(2),
- }}, {{
- "m": 27.4,
- "c": float64(1),
- }}, {{
- "m": 27.4,
- "c": float64(2),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demo_0_exceptions_total": int64(0),
- "op_1_preprocessor_demo_0_process_latency_us": int64(0),
- "op_1_preprocessor_demo_0_records_in_total": int64(5),
- "op_1_preprocessor_demo_0_records_out_total": int64(5),
- "op_2_preprocessor_demo1_0_exceptions_total": int64(0),
- "op_2_preprocessor_demo1_0_process_latency_us": int64(0),
- "op_2_preprocessor_demo1_0_records_in_total": int64(5),
- "op_2_preprocessor_demo1_0_records_out_total": int64(5),
- "op_6_project_0_exceptions_total": int64(0),
- "op_6_project_0_process_latency_us": int64(0),
- "op_6_project_0_records_in_total": int64(8),
- "op_6_project_0_records_out_total": int64(8),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(8),
- "sink_mockSink_0_records_out_total": int64(8),
- "source_demo_0_exceptions_total": int64(0),
- "source_demo_0_records_in_total": int64(5),
- "source_demo_0_records_out_total": int64(5),
- "source_demo1_0_exceptions_total": int64(0),
- "source_demo1_0_records_in_total": int64(5),
- "source_demo1_0_records_out_total": int64(5),
- "op_3_window_0_exceptions_total": int64(0),
- "op_3_window_0_process_latency_us": int64(0),
- "op_3_window_0_records_in_total": int64(10),
- "op_3_window_0_records_out_total": int64(10),
- "op_4_join_0_exceptions_total": int64(0),
- "op_4_join_0_process_latency_us": int64(0),
- "op_4_join_0_records_in_total": int64(10),
- "op_4_join_0_records_out_total": int64(8),
- },
- }, {
- name: `TestWindowRule7`,
- sql: `SELECT * FROM demoError GROUP BY HOPPINGWINDOW(ss, 2, 1)`,
- r: [][]map[string]interface{}{
- {{
- "error": "error in preprocessor: invalid data type for color, expect string but found int(3)",
- }},
- {{
- "color": "blue",
- "size": float64(6),
- "ts": float64(1541152486822),
- }},
- {{
- "color": "blue",
- "size": float64(6),
- "ts": float64(1541152486822),
- }, {
- "color": "blue",
- "size": float64(2),
- "ts": float64(1541152487632),
- }},
- {{
- "error": "error in preprocessor: invalid data type for color, expect string but found int(7)",
- }},
- {{
- "color": "blue",
- "size": float64(2),
- "ts": float64(1541152487632),
- }},
- {{
- "error": "error in preprocessor: invalid data type for size, expect bigint but found string(blue)",
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demoError_0_exceptions_total": int64(3),
- "op_1_preprocessor_demoError_0_process_latency_us": int64(0),
- "op_1_preprocessor_demoError_0_records_in_total": int64(5),
- "op_1_preprocessor_demoError_0_records_out_total": int64(2),
- "op_3_project_0_exceptions_total": int64(3),
- "op_3_project_0_process_latency_us": int64(0),
- "op_3_project_0_records_in_total": int64(6),
- "op_3_project_0_records_out_total": int64(3),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(6),
- "sink_mockSink_0_records_out_total": int64(6),
- "source_demoError_0_exceptions_total": int64(0),
- "source_demoError_0_records_in_total": int64(5),
- "source_demoError_0_records_out_total": int64(5),
- "op_2_window_0_exceptions_total": int64(3),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(5),
- "op_2_window_0_records_out_total": int64(3),
- },
- }, {
- name: `TestWindowRule8`,
- sql: `SELECT color, ts, count(*) as c FROM demo where size > 2 GROUP BY tumblingwindow(ss, 1) having c > 1`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- "ts": float64(1541152486013),
- "c": float64(2),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demo_0_exceptions_total": int64(0),
- "op_1_preprocessor_demo_0_process_latency_us": int64(0),
- "op_1_preprocessor_demo_0_records_in_total": int64(5),
- "op_1_preprocessor_demo_0_records_out_total": int64(5),
- "op_6_project_0_exceptions_total": int64(0),
- "op_6_project_0_process_latency_us": int64(0),
- "op_6_project_0_records_in_total": int64(1),
- "op_6_project_0_records_out_total": int64(1),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(1),
- "sink_mockSink_0_records_out_total": int64(1),
- "source_demo_0_exceptions_total": int64(0),
- "source_demo_0_records_in_total": int64(5),
- "source_demo_0_records_out_total": int64(5),
- "op_3_window_0_exceptions_total": int64(0),
- "op_3_window_0_process_latency_us": int64(0),
- "op_3_window_0_records_in_total": int64(3),
- "op_3_window_0_records_out_total": int64(2),
- "op_2_filter_0_exceptions_total": int64(0),
- "op_2_filter_0_process_latency_us": int64(0),
- "op_2_filter_0_records_in_total": int64(5),
- "op_2_filter_0_records_out_total": int64(3),
- "op_4_aggregate_0_exceptions_total": int64(0),
- "op_4_aggregate_0_process_latency_us": int64(0),
- "op_4_aggregate_0_records_in_total": int64(2),
- "op_4_aggregate_0_records_out_total": int64(2),
- "op_5_having_0_exceptions_total": int64(0),
- "op_5_having_0_process_latency_us": int64(0),
- "op_5_having_0_records_in_total": int64(2),
- "op_5_having_0_records_out_total": int64(1),
- },
- }, {
- name: `TestWindowRule9`,
- sql: `SELECT * FROM demo GROUP BY HOPPINGWINDOW(ss, 2, 1) FILTER( WHERE size > 2)`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- "size": float64(3),
- "ts": float64(1541152486013),
- }, {
- "color": "blue",
- "size": float64(6),
- "ts": float64(1541152486822),
- }},
- {{
- "color": "red",
- "size": float64(3),
- "ts": float64(1541152486013),
- }, {
- "color": "blue",
- "size": float64(6),
- "ts": float64(1541152486822),
- }},
- {{
- "color": "yellow",
- "size": float64(4),
- "ts": float64(1541152488442),
- }},
- {{
- "color": "yellow",
- "size": float64(4),
- "ts": float64(1541152488442),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demo_0_exceptions_total": int64(0),
- "op_1_preprocessor_demo_0_process_latency_us": int64(0),
- "op_1_preprocessor_demo_0_records_in_total": int64(5),
- "op_1_preprocessor_demo_0_records_out_total": int64(5),
- "op_4_project_0_exceptions_total": int64(0),
- "op_4_project_0_process_latency_us": int64(0),
- "op_4_project_0_records_in_total": int64(4),
- "op_4_project_0_records_out_total": int64(4),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(4),
- "sink_mockSink_0_records_out_total": int64(4),
- "source_demo_0_exceptions_total": int64(0),
- "source_demo_0_records_in_total": int64(5),
- "source_demo_0_records_out_total": int64(5),
- "op_3_window_0_exceptions_total": int64(0),
- "op_3_window_0_process_latency_us": int64(0),
- "op_3_window_0_records_in_total": int64(3),
- "op_3_window_0_records_out_total": int64(4),
- },
- }, {
- name: `TestCountWindowRule1`,
- sql: `SELECT collect(*)[0]->color as c FROM demo GROUP BY COUNTWINDOW(3)`,
- r: [][]map[string]interface{}{
- {{
- "c": "red",
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demo_0_exceptions_total": int64(0),
- "op_1_preprocessor_demo_0_process_latency_us": int64(0),
- "op_1_preprocessor_demo_0_records_in_total": int64(5),
- "op_1_preprocessor_demo_0_records_out_total": int64(5),
- "op_4_project_0_exceptions_total": int64(0),
- "op_4_project_0_process_latency_us": int64(0),
- "op_4_project_0_records_in_total": int64(1),
- "op_4_project_0_records_out_total": int64(1),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(1),
- "sink_mockSink_0_records_out_total": int64(1),
- "source_demo_0_exceptions_total": int64(0),
- "source_demo_0_records_in_total": int64(5),
- "source_demo_0_records_out_total": int64(5),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(5),
- "op_2_window_0_records_out_total": int64(1),
- },
- }, {
- name: `TestWindowRule10`,
- sql: `SELECT deduplicate(color, false)->color as c FROM demo GROUP BY SlidingWindow(hh, 1)`,
- r: [][]map[string]interface{}{
- {{
- "c": "red",
- }}, {{
- "c": "blue",
- }}, {{}}, {{
- "c": "yellow",
- }}, {{}},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demo_0_exceptions_total": int64(0),
- "op_1_preprocessor_demo_0_process_latency_us": int64(0),
- "op_1_preprocessor_demo_0_records_in_total": int64(5),
- "op_1_preprocessor_demo_0_records_out_total": int64(5),
- "op_4_project_0_exceptions_total": int64(0),
- "op_4_project_0_process_latency_us": int64(0),
- "op_4_project_0_records_in_total": int64(5),
- "op_4_project_0_records_out_total": int64(5),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(5),
- "sink_mockSink_0_records_out_total": int64(5),
- "source_demo_0_exceptions_total": int64(0),
- "source_demo_0_records_in_total": int64(5),
- "source_demo_0_records_out_total": int64(5),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(5),
- "op_2_window_0_records_out_total": int64(5),
- },
- },
- }
- handleStream(true, streamList, t)
- options := []*api.RuleOption{
- {
- BufferLength: 100,
- SendError: true,
- }, {
- BufferLength: 100,
- SendError: true,
- Qos: api.AtLeastOnce,
- CheckpointInterval: 5000,
- }, {
- BufferLength: 100,
- SendError: true,
- Qos: api.ExactlyOnce,
- CheckpointInterval: 5000,
- },
- }
- for j, opt := range options {
- doRuleTest(t, tests, j, opt)
- }
- }
- func TestEventWindow(t *testing.T) {
- //Reset
- streamList := []string{"demoE", "demoErr", "demo1E", "sessionDemoE"}
- handleStream(false, streamList, t)
- var tests = []ruleTest{
- {
- name: `TestEventWindowRule1`,
- sql: `SELECT * FROM demoE GROUP BY HOPPINGWINDOW(ss, 2, 1)`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- "size": float64(3),
- "ts": float64(1541152486013),
- }},
- {{
- "color": "red",
- "size": float64(3),
- "ts": float64(1541152486013),
- }, {
- "color": "blue",
- "size": float64(2),
- "ts": float64(1541152487632),
- }},
- {{
- "color": "blue",
- "size": float64(2),
- "ts": float64(1541152487632),
- }, {
- "color": "yellow",
- "size": float64(4),
- "ts": float64(1541152488442),
- }}, {{
- "color": "yellow",
- "size": float64(4),
- "ts": float64(1541152488442),
- }, {
- "color": "red",
- "size": float64(1),
- "ts": float64(1541152489252),
- }}, {{
- "color": "red",
- "size": float64(1),
- "ts": float64(1541152489252),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demoE_0_exceptions_total": int64(0),
- "op_1_preprocessor_demoE_0_process_latency_us": int64(0),
- "op_1_preprocessor_demoE_0_records_in_total": int64(6),
- "op_1_preprocessor_demoE_0_records_out_total": int64(6),
- "op_3_project_0_exceptions_total": int64(0),
- "op_3_project_0_process_latency_us": int64(0),
- "op_3_project_0_records_in_total": int64(5),
- "op_3_project_0_records_out_total": int64(5),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(5),
- "sink_mockSink_0_records_out_total": int64(5),
- "source_demoE_0_exceptions_total": int64(0),
- "source_demoE_0_records_in_total": int64(6),
- "source_demoE_0_records_out_total": int64(6),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(6),
- "op_2_window_0_records_out_total": int64(5),
- },
- }, {
- name: `TestEventWindowRule2`,
- sql: `SELECT color, ts FROM demoE where size > 2 GROUP BY tumblingwindow(ss, 1)`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- "ts": float64(1541152486013),
- }},
- {{
- "color": "yellow",
- "ts": float64(1541152488442),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demoE_0_exceptions_total": int64(0),
- "op_1_preprocessor_demoE_0_process_latency_us": int64(0),
- "op_1_preprocessor_demoE_0_records_in_total": int64(6),
- "op_1_preprocessor_demoE_0_records_out_total": int64(6),
- "op_4_project_0_exceptions_total": int64(0),
- "op_4_project_0_process_latency_us": int64(0),
- "op_4_project_0_records_in_total": int64(2),
- "op_4_project_0_records_out_total": int64(2),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(2),
- "sink_mockSink_0_records_out_total": int64(2),
- "source_demoE_0_exceptions_total": int64(0),
- "source_demoE_0_records_in_total": int64(6),
- "source_demoE_0_records_out_total": int64(6),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(6),
- "op_2_window_0_records_out_total": int64(4),
- "op_3_filter_0_exceptions_total": int64(0),
- "op_3_filter_0_process_latency_us": int64(0),
- "op_3_filter_0_records_in_total": int64(4),
- "op_3_filter_0_records_out_total": int64(2),
- },
- }, {
- name: `TestEventWindowRule3`,
- sql: `SELECT color, temp, ts FROM demoE INNER JOIN demo1E ON demoE.ts = demo1E.ts GROUP BY SlidingWindow(ss, 1)`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- "temp": 25.5,
- "ts": float64(1541152486013),
- }}, {{
- "color": "red",
- "temp": 25.5,
- "ts": float64(1541152486013),
- }}, {{
- "color": "blue",
- "temp": 28.1,
- "ts": float64(1541152487632),
- }}, {{
- "color": "blue",
- "temp": 28.1,
- "ts": float64(1541152487632),
- }, {
- "color": "yellow",
- "temp": 27.4,
- "ts": float64(1541152488442),
- }}, {{
- "color": "yellow",
- "temp": 27.4,
- "ts": float64(1541152488442),
- }, {
- "color": "red",
- "temp": 25.5,
- "ts": float64(1541152489252),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demoE_0_exceptions_total": int64(0),
- "op_1_preprocessor_demoE_0_process_latency_us": int64(0),
- "op_1_preprocessor_demoE_0_records_in_total": int64(6),
- "op_1_preprocessor_demoE_0_records_out_total": int64(6),
- "op_2_preprocessor_demo1E_0_exceptions_total": int64(0),
- "op_2_preprocessor_demo1E_0_process_latency_us": int64(0),
- "op_2_preprocessor_demo1E_0_records_in_total": int64(6),
- "op_2_preprocessor_demo1E_0_records_out_total": int64(6),
- "op_5_project_0_exceptions_total": int64(0),
- "op_5_project_0_process_latency_us": int64(0),
- "op_5_project_0_records_in_total": int64(5),
- "op_5_project_0_records_out_total": int64(5),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(5),
- "sink_mockSink_0_records_out_total": int64(5),
- "source_demoE_0_exceptions_total": int64(0),
- "source_demoE_0_records_in_total": int64(6),
- "source_demoE_0_records_out_total": int64(6),
- "source_demo1E_0_exceptions_total": int64(0),
- "source_demo1E_0_records_in_total": int64(6),
- "source_demo1E_0_records_out_total": int64(6),
- "op_3_window_0_exceptions_total": int64(0),
- "op_3_window_0_process_latency_us": int64(0),
- "op_3_window_0_records_in_total": int64(12),
- "op_3_window_0_records_out_total": int64(5),
- "op_4_join_0_exceptions_total": int64(0),
- "op_4_join_0_process_latency_us": int64(0),
- "op_4_join_0_records_in_total": int64(5),
- "op_4_join_0_records_out_total": int64(5),
- },
- }, {
- name: `TestEventWindowRule4`,
- sql: `SELECT color FROM demoE GROUP BY SlidingWindow(ss, 2), color ORDER BY color`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- }}, {{
- "color": "blue",
- }, {
- "color": "red",
- }}, {{
- "color": "blue",
- }, {
- "color": "yellow",
- }}, {{
- "color": "blue",
- }, {
- "color": "red",
- }, {
- "color": "yellow",
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demoE_0_exceptions_total": int64(0),
- "op_1_preprocessor_demoE_0_process_latency_us": int64(0),
- "op_1_preprocessor_demoE_0_records_in_total": int64(6),
- "op_1_preprocessor_demoE_0_records_out_total": int64(6),
- "op_5_project_0_exceptions_total": int64(0),
- "op_5_project_0_process_latency_us": int64(0),
- "op_5_project_0_records_in_total": int64(4),
- "op_5_project_0_records_out_total": int64(4),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(4),
- "sink_mockSink_0_records_out_total": int64(4),
- "source_demoE_0_exceptions_total": int64(0),
- "source_demoE_0_records_in_total": int64(6),
- "source_demoE_0_records_out_total": int64(6),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(6),
- "op_2_window_0_records_out_total": int64(4),
- "op_3_aggregate_0_exceptions_total": int64(0),
- "op_3_aggregate_0_process_latency_us": int64(0),
- "op_3_aggregate_0_records_in_total": int64(4),
- "op_3_aggregate_0_records_out_total": int64(4),
- "op_4_order_0_exceptions_total": int64(0),
- "op_4_order_0_process_latency_us": int64(0),
- "op_4_order_0_records_in_total": int64(4),
- "op_4_order_0_records_out_total": int64(4),
- },
- }, {
- name: `TestEventWindowRule5`,
- sql: `SELECT temp FROM sessionDemoE GROUP BY SessionWindow(ss, 2, 1) `,
- r: [][]map[string]interface{}{
- {{
- "temp": 25.5,
- }}, {{
- "temp": 28.1,
- }, {
- "temp": 27.4,
- }, {
- "temp": 25.5,
- }}, {{
- "temp": 26.2,
- }, {
- "temp": 26.8,
- }, {
- "temp": 28.9,
- }, {
- "temp": 29.1,
- }, {
- "temp": 32.2,
- }}, {{
- "temp": 30.9,
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_sessionDemoE_0_exceptions_total": int64(0),
- "op_1_preprocessor_sessionDemoE_0_process_latency_us": int64(0),
- "op_1_preprocessor_sessionDemoE_0_records_in_total": int64(12),
- "op_1_preprocessor_sessionDemoE_0_records_out_total": int64(12),
- "op_3_project_0_exceptions_total": int64(0),
- "op_3_project_0_process_latency_us": int64(0),
- "op_3_project_0_records_in_total": int64(4),
- "op_3_project_0_records_out_total": int64(4),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(4),
- "sink_mockSink_0_records_out_total": int64(4),
- "source_sessionDemoE_0_exceptions_total": int64(0),
- "source_sessionDemoE_0_records_in_total": int64(12),
- "source_sessionDemoE_0_records_out_total": int64(12),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(12),
- "op_2_window_0_records_out_total": int64(4),
- },
- }, {
- name: `TestEventWindowRule6`,
- sql: `SELECT max(temp) as m, count(color) as c FROM demoE INNER JOIN demo1E ON demoE.ts = demo1E.ts GROUP BY SlidingWindow(ss, 1)`,
- r: [][]map[string]interface{}{
- {{
- "m": 25.5,
- "c": float64(1),
- }}, {{
- "m": 25.5,
- "c": float64(1),
- }}, {{
- "m": 28.1,
- "c": float64(1),
- }}, {{
- "m": 28.1,
- "c": float64(2),
- }}, {{
- "m": 27.4,
- "c": float64(2),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demoE_0_exceptions_total": int64(0),
- "op_1_preprocessor_demoE_0_process_latency_us": int64(0),
- "op_1_preprocessor_demoE_0_records_in_total": int64(6),
- "op_1_preprocessor_demoE_0_records_out_total": int64(6),
- "op_2_preprocessor_demo1E_0_exceptions_total": int64(0),
- "op_2_preprocessor_demo1E_0_process_latency_us": int64(0),
- "op_2_preprocessor_demo1E_0_records_in_total": int64(6),
- "op_2_preprocessor_demo1E_0_records_out_total": int64(6),
- "op_6_project_0_exceptions_total": int64(0),
- "op_6_project_0_process_latency_us": int64(0),
- "op_6_project_0_records_in_total": int64(5),
- "op_6_project_0_records_out_total": int64(5),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(5),
- "sink_mockSink_0_records_out_total": int64(5),
- "source_demoE_0_exceptions_total": int64(0),
- "source_demoE_0_records_in_total": int64(6),
- "source_demoE_0_records_out_total": int64(6),
- "source_demo1E_0_exceptions_total": int64(0),
- "source_demo1E_0_records_in_total": int64(6),
- "source_demo1E_0_records_out_total": int64(6),
- "op_3_window_0_exceptions_total": int64(0),
- "op_3_window_0_records_in_total": int64(12),
- "op_3_window_0_records_out_total": int64(5),
- "op_4_join_0_exceptions_total": int64(0),
- "op_4_join_0_process_latency_us": int64(0),
- "op_4_join_0_records_in_total": int64(5),
- "op_4_join_0_records_out_total": int64(5),
- },
- }, {
- name: `TestEventWindowRule7`,
- sql: `SELECT * FROM demoErr GROUP BY HOPPINGWINDOW(ss, 2, 1)`,
- r: [][]map[string]interface{}{
- {{
- "error": "error in preprocessor: invalid data type for color, expect string but found int(2)",
- }},
- {{
- "color": "red",
- "size": float64(3),
- "ts": float64(1541152486013),
- }},
- {{
- "color": "red",
- "size": float64(3),
- "ts": float64(1541152486013),
- }},
- {{
- "color": "yellow",
- "size": float64(4),
- "ts": float64(1541152488442),
- }}, {{
- "color": "yellow",
- "size": float64(4),
- "ts": float64(1541152488442),
- }, {
- "color": "red",
- "size": float64(1),
- "ts": float64(1541152489252),
- }}, {{
- "color": "red",
- "size": float64(1),
- "ts": float64(1541152489252),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_demoErr_0_exceptions_total": int64(1),
- "op_1_preprocessor_demoErr_0_process_latency_us": int64(0),
- "op_1_preprocessor_demoErr_0_records_in_total": int64(6),
- "op_1_preprocessor_demoErr_0_records_out_total": int64(5),
- "op_3_project_0_exceptions_total": int64(1),
- "op_3_project_0_process_latency_us": int64(0),
- "op_3_project_0_records_in_total": int64(6),
- "op_3_project_0_records_out_total": int64(5),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(6),
- "sink_mockSink_0_records_out_total": int64(6),
- "source_demoErr_0_exceptions_total": int64(0),
- "source_demoErr_0_records_in_total": int64(6),
- "source_demoErr_0_records_out_total": int64(6),
- "op_2_window_0_exceptions_total": int64(1),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(6),
- "op_2_window_0_records_out_total": int64(5),
- },
- },
- }
- handleStream(true, streamList, t)
- options := []*api.RuleOption{
- {
- BufferLength: 100,
- SendError: true,
- IsEventTime: true,
- LateTol: 1000,
- }, {
- BufferLength: 100,
- SendError: true,
- Qos: api.AtLeastOnce,
- CheckpointInterval: 5000,
- IsEventTime: true,
- LateTol: 1000,
- }, {
- BufferLength: 100,
- SendError: true,
- Qos: api.ExactlyOnce,
- CheckpointInterval: 5000,
- IsEventTime: true,
- LateTol: 1000,
- },
- }
- for j, opt := range options {
- doRuleTest(t, tests, j, opt)
- }
- }
- func TestWindowError(t *testing.T) {
- //Reset
- streamList := []string{"ldemo", "ldemo1"}
- handleStream(false, streamList, t)
- var tests = []ruleTest{
- {
- name: `TestWindowErrorRule1`,
- sql: `SELECT size * 3 FROM ldemo GROUP BY TUMBLINGWINDOW(ss, 2)`,
- r: [][]map[string]interface{}{
- {{
- "error": "run Select error: invalid operation string(string) * int64(3)",
- }}, {{
- "rengine_field_0": float64(6),
- }, {}},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_ldemo_0_exceptions_total": int64(0),
- "op_1_preprocessor_ldemo_0_process_latency_us": int64(0),
- "op_1_preprocessor_ldemo_0_records_in_total": int64(5),
- "op_1_preprocessor_ldemo_0_records_out_total": int64(5),
- "op_3_project_0_exceptions_total": int64(1),
- "op_3_project_0_process_latency_us": int64(0),
- "op_3_project_0_records_in_total": int64(2),
- "op_3_project_0_records_out_total": int64(1),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(2),
- "sink_mockSink_0_records_out_total": int64(2),
- "source_ldemo_0_exceptions_total": int64(0),
- "source_ldemo_0_records_in_total": int64(5),
- "source_ldemo_0_records_out_total": int64(5),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(5),
- "op_2_window_0_records_out_total": int64(2),
- },
- }, {
- name: `TestWindowErrorRule2`,
- sql: `SELECT color, ts FROM ldemo where size > 2 GROUP BY tumblingwindow(ss, 1)`,
- r: [][]map[string]interface{}{
- {{
- "error": "run Where error: invalid operation string(string) > int64(2)",
- }}, {{
- "color": "red",
- "ts": float64(1541152486013),
- }}, {{
- "ts": float64(1541152487632),
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_ldemo_0_exceptions_total": int64(0),
- "op_1_preprocessor_ldemo_0_process_latency_us": int64(0),
- "op_1_preprocessor_ldemo_0_records_in_total": int64(5),
- "op_1_preprocessor_ldemo_0_records_out_total": int64(5),
- "op_4_project_0_exceptions_total": int64(1),
- "op_4_project_0_process_latency_us": int64(0),
- "op_4_project_0_records_in_total": int64(3),
- "op_4_project_0_records_out_total": int64(2),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(3),
- "sink_mockSink_0_records_out_total": int64(3),
- "source_ldemo_0_exceptions_total": int64(0),
- "source_ldemo_0_records_in_total": int64(5),
- "source_ldemo_0_records_out_total": int64(5),
- "op_3_window_0_exceptions_total": int64(1),
- "op_3_window_0_process_latency_us": int64(0),
- "op_3_window_0_records_in_total": int64(3),
- "op_3_window_0_records_out_total": int64(2),
- "op_2_filter_0_exceptions_total": int64(1),
- "op_2_filter_0_process_latency_us": int64(0),
- "op_2_filter_0_records_in_total": int64(5),
- "op_2_filter_0_records_out_total": int64(2),
- },
- }, {
- name: `TestWindowErrorRule3`,
- sql: `SELECT color, temp, ts FROM ldemo INNER JOIN ldemo1 ON ldemo.ts = ldemo1.ts GROUP BY SlidingWindow(ss, 1)`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- "temp": 25.5,
- "ts": float64(1541152486013),
- }}, {{
- "color": "red",
- "temp": 25.5,
- "ts": float64(1541152486013),
- }}, {{
- "color": "red",
- "temp": 25.5,
- "ts": float64(1541152486013),
- }}, {{
- "temp": 28.1,
- "ts": float64(1541152487632),
- }}, {{
- "temp": 28.1,
- "ts": float64(1541152487632),
- }}, {{
- "error": "run Join error: invalid operation int64(1541152487632) = string(1541152488442)",
- }}, {{
- "error": "run Join error: invalid operation int64(1541152488442) = string(1541152488442)",
- }}, {{
- "error": "run Join error: invalid operation int64(1541152488442) = string(1541152488442)",
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_ldemo_0_exceptions_total": int64(0),
- "op_1_preprocessor_ldemo_0_process_latency_us": int64(0),
- "op_1_preprocessor_ldemo_0_records_in_total": int64(5),
- "op_1_preprocessor_ldemo_0_records_out_total": int64(5),
- "op_2_preprocessor_ldemo1_0_exceptions_total": int64(0),
- "op_2_preprocessor_ldemo1_0_process_latency_us": int64(0),
- "op_2_preprocessor_ldemo1_0_records_in_total": int64(5),
- "op_2_preprocessor_ldemo1_0_records_out_total": int64(5),
- "op_5_project_0_exceptions_total": int64(3),
- "op_5_project_0_process_latency_us": int64(0),
- "op_5_project_0_records_in_total": int64(8),
- "op_5_project_0_records_out_total": int64(5),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(8),
- "sink_mockSink_0_records_out_total": int64(8),
- "source_ldemo_0_exceptions_total": int64(0),
- "source_ldemo_0_records_in_total": int64(5),
- "source_ldemo_0_records_out_total": int64(5),
- "source_ldemo1_0_exceptions_total": int64(0),
- "source_ldemo1_0_records_in_total": int64(5),
- "source_ldemo1_0_records_out_total": int64(5),
- "op_3_window_0_exceptions_total": int64(0),
- "op_3_window_0_process_latency_us": int64(0),
- "op_3_window_0_records_in_total": int64(10),
- "op_3_window_0_records_out_total": int64(10),
- "op_4_join_0_exceptions_total": int64(3),
- "op_4_join_0_process_latency_us": int64(0),
- "op_4_join_0_records_in_total": int64(10),
- "op_4_join_0_records_out_total": int64(5),
- },
- }, {
- name: `TestWindowErrorRule4`,
- sql: `SELECT color FROM ldemo GROUP BY SlidingWindow(ss, 2), color having size >= 2 order by color`,
- r: [][]map[string]interface{}{
- {{
- "color": "red",
- }}, {{
- "error": "run Having error: invalid operation string(string) >= int64(2)",
- }}, {{
- "error": "run Having error: invalid operation string(string) >= int64(2)",
- }}, {{
- "error": "run Having error: invalid operation string(string) >= int64(2)",
- }}, {{
- "color": float64(49),
- }, {}},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_ldemo_0_exceptions_total": int64(0),
- "op_1_preprocessor_ldemo_0_process_latency_us": int64(0),
- "op_1_preprocessor_ldemo_0_records_in_total": int64(5),
- "op_1_preprocessor_ldemo_0_records_out_total": int64(5),
- "op_6_project_0_exceptions_total": int64(3),
- "op_6_project_0_process_latency_us": int64(0),
- "op_6_project_0_records_in_total": int64(5),
- "op_6_project_0_records_out_total": int64(2),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(5),
- "sink_mockSink_0_records_out_total": int64(5),
- "source_ldemo_0_exceptions_total": int64(0),
- "source_ldemo_0_records_in_total": int64(5),
- "source_ldemo_0_records_out_total": int64(5),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(5),
- "op_2_window_0_records_out_total": int64(5),
- "op_3_aggregate_0_exceptions_total": int64(0),
- "op_3_aggregate_0_process_latency_us": int64(0),
- "op_3_aggregate_0_records_in_total": int64(5),
- "op_3_aggregate_0_records_out_total": int64(5),
- "op_4_having_0_exceptions_total": int64(3),
- "op_4_having_0_process_latency_us": int64(0),
- "op_4_having_0_records_in_total": int64(5),
- "op_4_having_0_records_out_total": int64(2),
- },
- }, {
- name: `TestWindowErrorRule5`,
- sql: `SELECT color, size FROM ldemo GROUP BY tumblingwindow(ss, 1) ORDER BY size`,
- r: [][]map[string]interface{}{
- {{
- "error": "run Order By error: incompatible types for comparison: int and string",
- }}, {{
- "size": float64(3),
- }}, {{
- "color": float64(49),
- "size": float64(2),
- }}, {{
- "color": "red",
- }},
- },
- m: map[string]interface{}{
- "op_1_preprocessor_ldemo_0_exceptions_total": int64(0),
- "op_1_preprocessor_ldemo_0_process_latency_us": int64(0),
- "op_1_preprocessor_ldemo_0_records_in_total": int64(5),
- "op_1_preprocessor_ldemo_0_records_out_total": int64(5),
- "op_4_project_0_exceptions_total": int64(1),
- "op_4_project_0_process_latency_us": int64(0),
- "op_4_project_0_records_in_total": int64(4),
- "op_4_project_0_records_out_total": int64(3),
- "sink_mockSink_0_exceptions_total": int64(0),
- "sink_mockSink_0_records_in_total": int64(4),
- "sink_mockSink_0_records_out_total": int64(4),
- "source_ldemo_0_exceptions_total": int64(0),
- "source_ldemo_0_records_in_total": int64(5),
- "source_ldemo_0_records_out_total": int64(5),
- "op_2_window_0_exceptions_total": int64(0),
- "op_2_window_0_process_latency_us": int64(0),
- "op_2_window_0_records_in_total": int64(5),
- "op_2_window_0_records_out_total": int64(4),
- "op_3_order_0_exceptions_total": int64(1),
- "op_3_order_0_process_latency_us": int64(0),
- "op_3_order_0_records_in_total": int64(4),
- "op_3_order_0_records_out_total": int64(3),
- },
- },
- }
- handleStream(true, streamList, t)
- doRuleTest(t, tests, 0, &api.RuleOption{
- BufferLength: 100,
- SendError: true,
- })
- }
|