//! Example: mix eq/neq/gt/lt/in conditions in a single fetch.
use athena_rs::client::backend::QueryResult;
use athena_rs::{AthenaClient, OrderDirection};
use serde_json::json;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let client: AthenaClient =
        AthenaClient::new("http://localhost:4052", "secret", "reporting").await?;

    let result: QueryResult = client
        .fetch("events")
        .columns(["id", "event_type", "source", "created_at_epoch"])
        .where_eq("workspace_id", "ws_123")
        .where_neq("source", "internal")
        .where_gt("created_at_epoch", 1_700_000_000_i64)
        .where_lt("created_at_epoch", 1_800_000_000_i64)
        .where_in(
            "event_type",
            vec![json!("login"), json!("purchase"), json!("invite")],
        )
        .order_by("created_at_epoch", OrderDirection::Desc)
        .limit(100)
        .offset(0)
        .execute()
        .await?;

    println!("Rows: {}", result.rows.len());
    Ok(())
}
