Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need Arrays, but both row! macro and Block::column do not work #186

Open
rsalmei opened this issue Jan 26, 2023 · 2 comments
Open

Need Arrays, but both row! macro and Block::column do not work #186

rsalmei opened this issue Jan 26, 2023 · 2 comments

Comments

@rsalmei
Copy link

rsalmei commented Jan 26, 2023

It seems I can't insert Arrays via the row! macro, Array(Float32) in my case.

error[E0277]: the trait bound `clickhouse_rs::types::Value: std::convert::From<std::vec::Vec<f32>>` is not satisfied
   --> src/tasks/clickhouse_pusher.rs:285:18
    |
282 |           block.push(row! {
    |  ____________________-
283 | |             created: created, time_ms: utils::now_ms(),
284 | |             token: id.token.as_ref(),
285 | |             arr: ws.iter().map(|r| r.aps.len() as f32).collect::<Vec<_>>(),
    | |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<std::vec::Vec<f32>>` is not implemented for `clickhouse_rs::types::Value`
286 | |         })?;
    | |_________- required by a bound introduced by this call
    |
    = help: the following other types implement trait `std::convert::From<T>`:
              <clickhouse_rs::types::Value as std::convert::From<&'a str>>
              <clickhouse_rs::types::Value as std::convert::From<&[u8]>>
              <clickhouse_rs::types::Value as std::convert::From<[u8; 16]>>
              <clickhouse_rs::types::Value as std::convert::From<[u8; 4]>>
              <clickhouse_rs::types::Value as std::convert::From<bool>>
              <clickhouse_rs::types::Value as std::convert::From<chrono::Date<chrono_tz::Tz>>>
              <clickhouse_rs::types::Value as std::convert::From<chrono::DateTime<chrono::Utc>>>
              <clickhouse_rs::types::Value as std::convert::From<chrono::DateTime<chrono_tz::Tz>>>
            and 20 others
    = note: required for `std::vec::Vec<f32>` to implement `std::convert::Into<clickhouse_rs::types::Value>`

I found #36 where you included an example but it uses Block::column(). Ok I tried to refactor my whole code to insert columns instead of rows, but now it breaks with this:

error[E0277]: the trait bound `chrono::DateTime<chrono::Utc>: clickhouse_rs::types::stat_buffer::StatBuffer` is not satisfied
   --> src/tasks/clickhouse_pusher.rs:287:28
    |
287 |         .column("created", created)
    |          ------            ^^^^^^^ the trait `clickhouse_rs::types::stat_buffer::StatBuffer` is not implemented for `chrono::DateTime<chrono::Utc>`
    |          |
    |          required by a bound introduced by this call
    |
    = help: the following other types implement trait `clickhouse_rs::types::stat_buffer::StatBuffer`:
              bool
              f32
              f64
              i16
              i32
              i64
              i8
              u16
            and 3 others
    = note: required for `std::vec::Vec<chrono::DateTime<chrono::Utc>>` to implement `clickhouse_rs::types::column::ColumnFrom`
note: required by a bound in `clickhouse_rs::Block::<K>::column`
   --> /Users/rogerio/.cargo/git/checkouts/clickhouse-rs-37da3cb97e01332d/123ec50/src/types/block/mod.rs:237:12
    |
237 |         S: ColumnFrom,
    |            ^^^^^^^^^^ required by this bound in `clickhouse_rs::Block::<K>::column`

I'm sorry to say and thanks for your work, but this is quite confusing.
It seems each kind of data-inserting method has a different subset of supported types...
With row! I can't insert Arrays of floats, and with .column() I can't insert dates. What would I do, please?

@suharev7
Copy link
Owner

Thanks for this issue. I've added support for inserting rows number arrays. Each kind of data-inserting method should have the same set of supported types, but the current implementation may have some leaks to supports some types in different data-inserting methods.

@rsalmei
Copy link
Author

rsalmei commented Feb 2, 2023

Thanks, @suharev7.
So, the row! macro should work now?
I suppose that "chrono StatBuffer trait thing" error remains, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants