ArroyoSystems / arroyo

Distributed stream processing engine in Rust
https://arroyo.dev
Apache License 2.0
3.8k stars 220 forks source link

syntax error with INSERT INTO TUMBLE #785

Closed xmlking closed 3 days ago

xmlking commented 1 week ago

why I am getting syntax error with this?

https://github.com/ducthuy-ng/bigdata-sem241/blob/main/pipeline.arroyo.sql

mwylde commented 3 days ago

Discussed in Discord, but for posterity, there is a missing SELECT on line 25. Here's the corrected query:

CREATE TABLE mastodon (
    id TEXT,
    uri TEXT,
    content TEXT
) WITH (
    connector = 'sse',
    format = 'json',
    endpoint = 'http://mastodon.arroyo.dev/api/v1/streaming/public',
    events = 'update'
);

CREATE TABLE output_table
WITH (
    connector = 'blackhole'
);

INSERT INTO output_table 
WITH post_filtering AS (
    SELECT 
        id
        , arrow_cast(REGEXP_LIKE(content, '(kamala|har{1,3}is)', 'i'), 'Int64') AS harris_mentioned
        , arrow_cast(REGEXP_LIKE(content, 'trumps?', 'i'), 'Int64') AS trump_mentioned
    FROM mastodon
)
SELECT
    TUMBLE(interval '30 seconds') AS window
    , SUM(harris_mentioned) AS number_of_post_mention_harris
    , SUM(trump_mentioned) AS number_of_post_mention_trump
FROM post_filtering
GROUP BY window