nooberfsh / prusto

A presto/trino client library written in rust.
MIT License
37 stars 23 forks source link

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

Closed derrley closed 5 months ago

derrley commented 5 months ago

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,
}
derrley commented 5 months ago

This example did not work because Prusto does not have support for datetimes with timezones.