ArroyoSystems / arroyo

Distributed stream processing engine in Rust

Home Page:https://arroyo.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQL compilation error when computing watermark in create table with string syntax

mwylde opened this issue · comments

We have two syntaxes for creating an interval:

  • INTERVAL '5' second
  • '5 seconds'

Both work as arguments to window functions:

tumble(interval '5' second)
tumble('5 seconds')

But when performing calculations, only the first style plans in normal expressions:

-- plans
select event_time - interval '5' seconds from stream;
-- errors with "Cannot coerce arithmetic expression Timestamp(Nanosecond, None) - Utf8 to valid types"
select event_time - '5 seconds' from stream;

However, when computing virtual columns of a create table (for example for defining a watermark) both syntaxes plan, but the second one produces a compilation error:

CREATE TABLE (
  ...
  watermark TIMESTAMP GENERATED ALWAYS AS (CAST(timestamp as TIMESTAMP) - '5 seconds'),
error[E0277]: cannot subtract `std::string::String` from `SystemTime`
  --> pipeline/src/main.rs:98:39
   |
98 | ...                   } - "5 seconds".to_string()),
   |                         ^ no implementation for `SystemTime - std::string::String`
   |