GithubHelp home page GithubHelp logo

prusto's Introduction

Prusto

A presto/trino client library written in rust.

Installation

# Cargo.toml
[dependencies]
prusto = "0.5"

In order to use this crate as presto client, enable "presto" feature.

# Cargo.toml
[dependencies]
prusto = { version = "0.5", features = ["presto"] }

Example

use prusto::{ClientBuilder, Presto};

#[derive(Presto, Debug)]
struct Foo {
    a: i64,
    b: f64,
    c: String,
}

#[tokio::main]
async fn main() {
    let cli = ClientBuilder::new("user", "localhost")
        .port(8090)
        .catalog("catalog")
        .build()
        .unwrap();

    let sql = "select 1 as a, cast(1.1 as double) as b, 'bar' as c ";

    let data = cli.get_all::<Foo>(sql.into()).await.unwrap().into_vec();

    for r in data {
        println!("{:?}", r)
    }
}

License

MIT

prusto's People

Contributors

bartek-siudeja avatar choubacha avatar comphead avatar cw-kajiwara avatar exoego avatar nooberfsh avatar samrose-ahmed avatar siudej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

prusto's Issues

The package depends on prusto, with features: presto but prusto does not have these features

Hello,

I am trying to run the example code in the main markdown.

I have installed rustup 1.25.1, rustc 1.68.0-nightly and my toml is

prusto = { version = "0.4.0", features = ["presto"] }

When I cargo run it, I get

failed to select a version for prusto
versions that meet the requirements ^0.4.0 (locked to 0.4.0) are: 0.4.0
the package depends on prusto, with features: presto but prusto does not have these features.

Am I getting something wrong?

Split trino model in a single crate

Do you think it could be a good idea to split your trino model into a single crate?
This will allow people to create clients and implementations using the model

How do you deal with gzip?

I found your crate and I couldn't figure out how you are decompressing the gzip body from the response. Is that done automatically by reqwest?

SHOW CREATE MATERIALIZED VIEW gives empty data

hello,
I need to execute this query
SHOW CREATE MATERIALIZED VIEW view_name

I'm using method get_all, I can see from trino's console that the query is executed and finish properly
but the client gives me empty_data error

I tried both using a String and a struct containing a string as model to map the result but no luck.
how can I achieve this?

thank you

Selecting an optional type results in None?

I have a field that can be Null and I've wrapped the type in an Option, something like:

#[derive(prusto::Presto)]
struct MyRow {
  val: Option<String>,
}

When I select it, I get back no rows! If I remove this field and try again I get the rows.

Support more than 16 fields for Structs

The following struct compiles correctly:


#[derive(Presto)]
struct Foo {
  a1: i16,
  a2: i16,
  a3: i16,
  a4: i16,
  a5: i16,
  a6: i16,
  a7: i16,
  a8: i16,
  a9: i16,
  a10: i16,
  a11: i16,
  a12: i16,
  a13: i16,
  a14: i16,
  a15: i16,
  a16: i16,
}

If we add a17: i16 as an extra struct member we get the following error:


error[E0277]: the trait bound `(&'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16, &'_a i16): Serialize` is not satisfied
  --> src/main.rs:13:10
   |
13 | #[derive(Presto)]
   |          ^^^^^^ the trait `Serialize` is not implemented for `(&i16, &i16, &i16, &i16, &i16, &i16, &i16, &i16, &i16, &i16, &i16, &i16, &i16, &i16, &i16, &i16, &i16)`
   |
   = help: the following other types implement trait `Serialize`:
             ()
             (T0,)
             (T0, T1)
             (T0, T1, T2)
             (T0, T1, T2, T3)
             (T0, T1, T2, T3, T4)
             (T0, T1, T2, T3, T4, T5)
             (T0, T1, T2, T3, T4, T5, T6)
           and 9 others
note: required by a bound in `prusto::Presto::ValueType`
  --> /Users/bogdanstate/.cargo/registry/src/index.crates.io-6f17d22bba15001f/prusto-0.5.1/src/types/mod.rs:69:25
   |
69 |     type ValueType<'a>: Serialize
   |                         ^^^^^^^^^ required by this bound in `Presto::ValueType`
   = note: this error originates in the derive macro `Presto` (in Nightly builds, run with -Z macro-backtrace for more info)

I assume this is due to a the way the derive(Presto) macro is implemented, i.e. by using a tuple as the underlying type.

"simple" example appears to not work: always "empty data"

Create a Trino database with some data in it, and try to select it out with get_all. It doesn't work?

#[tokio::main]
async fn main() {
    let user = "admin".to_string();
    let host = "localhost".to_string();
    let port = 8080;
    let catalog = "iceberg".to_string();
    let sql = "SELECT event_id, timestamp, message FROM simba.events".to_string();

    let cli = ClientBuilder::new(user, host)
        .port(port)
        .catalog(catalog)
        .build()
        .unwrap();

    let data = cli.get_all::<Row>(sql).await.unwrap().into_vec();

    for r in data {
        println!("{:?}", r)
    }
}

Did some digging, and I can see the data coming back in the "data" field, but that doesn't make it into the QueryResult deserialization:

{"id":"20240424_091127_00190_vnqi9","infoUri":"http://localhost:8080/ui/query.html?20240424_091127_00190_vnqi9","partialCancelUri":"http://localhost:8080/v1/statement/executing/partialCancel/20240424_091127_00190_vnqi9/0/yb90d84f2d580220289082106b260e8edfec120c2/1","nextUri":"http://localhost:8080/v1/statement/executing/20240424_091127_00190_vnqi9/yb90d84f2d580220289082106b260e8edfec120c2/1","columns":[{"name":"event_id","type":"varchar","typeSignature":{"rawType":"varchar","arguments":[{"kind":"LONG","value":2147483647}]}},{"name":"timestamp","type":"timestamp(6) with time zone","typeSignature":{"rawType":"timestamp with time zone","arguments":[{"kind":"LONG","value":6}]}},{"name":"message","type":"varchar","typeSignature":{"rawType":"varchar","arguments":[{"kind":"LONG","value":2147483647}]}}],"data":[["w-1","2024-04-24 22:05:45.728000 UTC","what the fuck"],["w-2","2024-04-24 22:05:45.728000 UTC","are we doing"],["w-3","2024-04-23 22:05:45.728000 UTC","what the fuck here, also"]],"stats":{"state":"RUNNING","queued":false,"scheduled":true,"progressPercentage":100.0,"runningPercentage":0.0,"nodes":1,"totalSplits":1,"queuedSplits":0,"runningSplits":0,"completedSplits":1,"cpuTimeMillis":9,"wallTimeMillis":10,"queuedTimeMillis":1,"elapsedTimeMillis":12441,"processedRows":3,"processedBytes":258263,"physicalInputBytes":258263,"physicalWrittenBytes":0,"peakMemoryBytes":590,"spilledBytes":0,"rootStage":{"stageId":"0","state":"RUNNING","done":false,"nodes":1,"totalSplits":1,"queuedSplits":0,"runningSplits":0,"completedSplits":1,"cpuTimeMillis":9,"wallTimeMillis":10,"processedRows":3,"processedBytes":258263,"physicalInputBytes":258263,"failedTasks":0,"coordinatorOnly":false,"subStages":[]}},"warnings":[]}

QueryResult {
    id: "20240424_091127_00190_vnqi9",
    info_uri: "http://localhost:8080/ui/query.html?20240424_091127_00190_vnqi9",
    partial_cancel_uri: Some(
        "http://localhost:8080/v1/statement/executing/partialCancel/20240424_091127_00190_vnqi9/0/yb90d84f2d580220289082106b260e8edfec120c2/1",
    ),
    next_uri: Some(
        "http://localhost:8080/v1/statement/executing/20240424_091127_00190_vnqi9/yb90d84f2d580220289082106b260e8edfec120c2/1",
    ),
    data_set: None,
    error: None,
    stats: Stat {
        state: "RUNNING",
        queued: false,
        scheduled: true,
        nodes: 1,
        total_splits: 1,
        queued_splits: 0,
        running_splits: 0,
        completed_splits: 1,
        cpu_time_millis: 9,
        wall_time_millis: 10,
        queued_time_millis: 1,
        elapsed_time_millis: 12441,
        processed_rows: 3,
        processed_bytes: 258263,
        peak_memory_bytes: 590,
        spilled_bytes: 0,
        root_stage: None,
    },
    warnings: [],
    update_type: None,
    update_count: None,
}

Would it be possible to release 0.5.1?

Hello! I'm experimenting with Trino and Rust, and your crate is very helpful!

I noticed that you fixed a bug in ClientBuilder::schema in 3d0f011. Would it be possible to get an 0.5.1 release of prusto with that fix at some point? (I can use a git version in Cargo.toml, but that would prevent me from ever making an open source release using crates.io.)

Thank you very much for maintaining a Trino/Presto client!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.