vmware-archive / sql-to-dbsp-compiler

Compiler translating SQL view definitions into DBSP circuits (https://github.com/vmware/database-stream-processor)
Other
28 stars 5 forks source link

Query generates invalid Rust #80

Closed ryzhyk closed 1 year ago

ryzhyk commented 1 year ago
CREATE TABLE demographics (
    cc_num FLOAT64,
    first STRING,
    gender STRING,
    street STRING,
    city STRING,
    state STRING,
    zip INTEGER,
    lat FLOAT64,
    long FLOAT64,
    city_pop INTEGER,
    job STRING,
    dob DATE
);

CREATE TABLE transactions (
    trans_date_trans_time TIMESTAMP NOT NULL,
    cc_num FLOAT64,
    merchant STRING,
    category STRING,
    amt FLOAT64,
    trans_num STRING,
    unix_time INTEGER,
    merch_lat FLOAT64,
    merch_long FLOAT64,
    is_fraud INTEGER
);

CREATE VIEW transactions_with_demographics as 
    SELECT transactions.*, demographics.first, demographics.city
    FROM
        transactions JOIN demographics
        ON transactions.cc_num = demographics.cc_num;

When compiling generated Rust code, I get:

package:   /home/leonid/projects/database-stream-processor/pipeline_server/pipeline_data/cargo_workspace/project3/Cargo.toml
workspace: /home/leonid/projects/database-stream-processor/pipeline_server/pipeline_data/cargo_workspace/Cargo.toml
   Compiling project3 v0.1.0 (/home/leonid/projects/database-stream-processor/pipeline_server/pipeline_data/cargo_workspace/project3)
error[E0107]: this struct takes 12 generic arguments but 11 generic arguments were supplied
  --> project3/src/main.rs:80:41
   |
80 | ...et<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
   |       ^^^^^^^ -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 11 generic arguments
   |       |
   |       expected 12 generic arguments
   |
note: struct defined here, with 12 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`
  --> project3/src/main.rs:60:5
   |
60 |     Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---
help: add missing generic argument
   |
80 |         let stream17: Stream<_, OrdZSet<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T11, >, Weight>> = DEMOGRAPHICS.flat_map(move |r: &Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >, | -> Option<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >> {
   |                                                                                                                                                                                                                +++++

error[E0107]: this struct takes 12 generic arguments but 11 generic arguments were supplied
  --> project3/src/main.rs:95:57
   |
95 | ...), Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
   |       ^^^^^^^ -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 11 generic arguments
   |       |
   |       expected 12 generic arguments
   |
note: struct defined here, with 12 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`
  --> project3/src/main.rs:60:5
   |
60 |     Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---
help: add missing generic argument
   |
95 |         let stream21: Stream<_, OrdIndexedZSet<(F64, ), Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T11, >, Weight>> = stream17.index_with(index1);
   |                                                                                                                                                                                                                                +++++

error[E0107]: this struct takes 22 generic arguments but 21 generic arguments were supplied
   --> project3/src/main.rs:100:41
    |
100 | ...et<Tuple22<Timestamp, Option<F64>, Option<String>, Option<String>, Option<F64>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
    |       ^^^^^^^ ---------  -----------  --------------  --------------  -----------  --------------  -----------  -----------  -----------  -----------  -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 21 generic arguments
    |       |
    |       expected 22 generic arguments
    |
note: struct defined here, with 22 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`, `T12`, `T13`, `T14`, `T15`, `T16`, `T17`, `T18`, `T19`, `T20`, `T21`
   --> project3/src/main.rs:58:5
    |
58  |     Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>,
    |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---  ---  ---  ---  ---  ---  ---  ---  ---  ---  ---
help: add missing generic argument
    |
100 |         let stream23: Stream<_, OrdZSet<Tuple22<Timestamp, Option<F64>, Option<String>, Option<String>, Option<F64>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T21, >, Weight>> = stream19.join::<(), _, _, _>(&stream21, pair0);
    |                                                                                                                                                                                                                                                                                                                                                         +++++

error[E0107]: this struct takes 12 generic arguments but 11 generic arguments were supplied
  --> project3/src/main.rs:71:64
   |
71 | ...::<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
   |       ^^^^^^^ -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 11 generic arguments
   |       |
   |       expected 12 generic arguments
   |
note: struct defined here, with 12 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`
  --> project3/src/main.rs:60:5
   |
60 |     Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---
help: add missing generic argument
   |
71 |         let (DEMOGRAPHICS, handle1) = circuit.add_input_zset::<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T11, >, Weight>();
   |                                                                                                                                                                                                                                       +++++

error[E0107]: this struct takes 12 generic arguments but 11 generic arguments were supplied
  --> project3/src/main.rs:80:440
   |
80 | ...on<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
   |       ^^^^^^^ -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 11 generic arguments
   |       |
   |       expected 12 generic arguments
   |
note: struct defined here, with 12 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`
  --> project3/src/main.rs:60:5
   |
60 |     Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---
help: add missing generic argument
   |
80 |         let stream17: Stream<_, OrdZSet<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >, Weight>> = DEMOGRAPHICS.flat_map(move |r: &Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >, | -> Option<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T11, >> {
   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               +++++

error[E0107]: this struct takes 12 generic arguments but 11 generic arguments were supplied
  --> project3/src/main.rs:80:256
   |
80 | ...: &Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
   |       ^^^^^^^ -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 11 generic arguments
   |       |
   |       expected 12 generic arguments
   |
note: struct defined here, with 12 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`
  --> project3/src/main.rs:60:5
   |
60 |     Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---
help: add missing generic argument
   |
80 |         let stream17: Stream<_, OrdZSet<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >, Weight>> = DEMOGRAPHICS.flat_map(move |r: &Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T11, >, | -> Option<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >> {
   |                                                                                                                                                                                                                                                                                                                                                                                                                                       +++++

error[E0107]: this struct takes 12 generic arguments but 11 generic arguments were supplied
  --> project3/src/main.rs:82:17
   |
82 | ...   Tuple12::<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
   |       ^^^^^^^   -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 11 generic arguments
   |       |
   |       expected 12 generic arguments
   |
note: struct defined here, with 12 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`
  --> project3/src/main.rs:60:5
   |
60 |     Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---
help: add missing generic argument
   |
82 |                 Tuple12::<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T11, >(Some(_), _, _, _, _, _, _, _, _, _, _, _) => Some(r.clone()),
   |                                                                                                                                                                                          +++++

error[E0107]: this struct takes 12 generic arguments but 11 generic arguments were supplied
  --> project3/src/main.rs:83:29
   |
83 | ...::<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, ...
   |       ^^^^^^^ -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 11 generic arguments
   |       |
   |       expected 12 generic arguments
   |
note: struct defined here, with 12 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`
  --> project3/src/main.rs:60:5
   |
60 |     Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---
help: add missing generic argument
   |
83 |                 _ => None::<Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T11, >>,
   |                                                                                                                                                                                                    +++++

error[E0107]: this struct takes 12 generic arguments but 11 generic arguments were supplied
  --> project3/src/main.rs:91:222
   |
91 | ...), Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
   |       ^^^^^^^ -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 11 generic arguments
   |       |
   |       expected 12 generic arguments
   |
note: struct defined here, with 12 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`
  --> project3/src/main.rs:60:5
   |
60 |     Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---
help: add missing generic argument
   |
91 |         let index1: _ = move |r: &Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >, | -> ((F64, ), Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T11, >, ) {
   |                                                                                                                                                                                                                                                                                                                                                                                                     +++++

error[E0107]: this struct takes 12 generic arguments but 11 generic arguments were supplied
  --> project3/src/main.rs:91:35
   |
91 | ...: &Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
   |       ^^^^^^^ -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 11 generic arguments
   |       |
   |       expected 12 generic arguments
   |
note: struct defined here, with 12 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`
  --> project3/src/main.rs:60:5
   |
60 |     Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---
help: add missing generic argument
   |
91 |         let index1: _ = move |r: &Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T11, >, | -> ((F64, ), Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >, ) {
   |                                                                                                                                                                                                          +++++

error[E0107]: this struct takes 22 generic arguments but 21 generic arguments were supplied
  --> project3/src/main.rs:96:374
   |
96 | ...-> Tuple22<Timestamp, Option<F64>, Option<String>, Option<String>, Option<F64>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, ...
   |       ^^^^^^^ ---------  -----------  --------------  --------------  -----------  --------------  -----------  -----------  -----------  -----------  -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 21 generic arguments
   |       |
   |       expected 22 generic arguments
   |
note: struct defined here, with 22 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`, `T12`, `T13`, `T14`, `T15`, `T16`, `T17`, `T18`, `T19`, `T20`, `T21`
  --> project3/src/main.rs:58:5
   |
58 |     Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---  ---  ---  ---  ---  ---  ---  ---  ---  ---  ---
help: add missing generic argument
   |
96 |         let pair0: _ = move |k: &(F64, ), l: &Tuple10<Timestamp, Option<F64>, Option<String>, Option<String>, Option<F64>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>>, r: &Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >, | -> Tuple22<Timestamp, Option<F64>, Option<String>, Option<String>, Option<F64>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T21, > {
   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      +++++

error[E0107]: this struct takes 12 generic arguments but 11 generic arguments were supplied
  --> project3/src/main.rs:96:197
   |
96 | ...: &Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
   |       ^^^^^^^ -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 11 generic arguments
   |       |
   |       expected 12 generic arguments
   |
note: struct defined here, with 12 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`
  --> project3/src/main.rs:60:5
   |
60 |     Tuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>,
   |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---
help: add missing generic argument
   |
96 |         let pair0: _ = move |k: &(F64, ), l: &Tuple10<Timestamp, Option<F64>, Option<String>, Option<String>, Option<F64>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>>, r: &Tuple12<Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T11, >, | -> Tuple22<Timestamp, Option<F64>, Option<String>, Option<String>, Option<F64>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, > {
   |                                                                                                                                                                                                                                                                                                                                                                            +++++

error[E0107]: this struct takes 22 generic arguments but 21 generic arguments were supplied
   --> project3/src/main.rs:101:33
    |
101 | ...: &Tuple22<Timestamp, Option<F64>, Option<String>, Option<String>, Option<F64>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, >...
    |       ^^^^^^^ ---------  -----------  --------------  --------------  -----------  --------------  -----------  -----------  -----------  -----------  -----------  --------------  --------------  --------------  --------------  --------------  -----------  -----------  -----------  -----------  -------------- supplied 21 generic arguments
    |       |
    |       expected 22 generic arguments
    |
note: struct defined here, with 22 generic parameters: `T0`, `T1`, `T2`, `T3`, `T4`, `T5`, `T6`, `T7`, `T8`, `T9`, `T10`, `T11`, `T12`, `T13`, `T14`, `T15`, `T16`, `T17`, `T18`, `T19`, `T20`, `T21`
   --> project3/src/main.rs:58:5
    |
58  |     Tuple22<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>,
    |     ^^^^^^^ --  --  --  --  --  --  --  --  --  --  ---  ---  ---  ---  ---  ---  ---  ---  ---  ---  ---  ---
help: add missing generic argument
    |
101 |         let map0: _ = move |t: &Tuple22<Timestamp, Option<F64>, Option<String>, Option<String>, Option<F64>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<F64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, T21, >, | -> Tuple12<Timestamp, Option<F64>, Option<String>, Option<String>, Option<F64>, Option<String>, Option<i32>, Option<F64>, Option<F64>, Option<i32>, Option<String>, Option<String>> {
    |                                                                                                                                                                                                                                                                                                                                                 +++++

For more information about this error, try `rustc --explain E0107`.
error: could not compile `project3` due to 13 previous errors

exit code: exit status: 101
mihaibudiu commented 1 year ago

that is strange, we have run a few million join queries

ryzhyk commented 1 year ago

It looks like it doesn't like the DATE column

ryzhyk commented 1 year ago

When I change its type to STRING, compilation succeeds.