hotdata 0.15.0

Powerful data platform API for datasets, queries, and analytics.
Documentation
/*
 * Hotdata API
 *
 * Powerful data platform API for instant databases, queries, and analytics.
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: developers@hotdata.dev
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// QueryRunInfo : Single query run for listing
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct QueryRunInfo {
    /// Bytes this query actually fetched from storage. Not a measure of how much data the query covered — it counts the reads that reached storage, so the same SQL over the same rows reports a different number depending on what was already cached.  `null` means the query touched no table at all (for example a constant expression like `SELECT 1`).  `0` means the query read a table but fetched nothing from storage. It is a normal, common answer, not an error or a missing measurement, and it does not mean the query did no work — `rows_scanned` shows the rows it went through. The usual cause is a warm cache: re-running a query whose data or file metadata is already held in memory reports far fewer bytes than the first run, frequently `0`, with `rows_scanned` unchanged. A query answered from table statistics alone (a row count, say) also reports `0`.  Because of this, `bytes_scanned` is not a proxy for query cost or query volume. `GET /v1/usage` sums this field over a period, so that total is the storage read a workspace caused, not the work its queries did: repeating one query cheaply adds little or nothing to it.
    #[serde(
        rename = "bytes_scanned",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub bytes_scanned: Option<Option<i64>>,
    #[serde(
        rename = "completed_at",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub completed_at: Option<Option<String>>,
    #[serde(rename = "created_at")]
    pub created_at: String,
    #[serde(
        rename = "error_message",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub error_message: Option<Option<String>>,
    #[serde(
        rename = "execution_time_ms",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub execution_time_ms: Option<Option<i64>>,
    #[serde(rename = "id")]
    pub id: String,
    #[serde(
        rename = "result_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub result_id: Option<Option<String>>,
    #[serde(
        rename = "row_count",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub row_count: Option<Option<i64>>,
    /// Total rows read from storage to run this query, before any filtering or aggregation. Distinct from `row_count`, which is how many rows the query returned. `null` when the query reads no table data from storage.
    #[serde(
        rename = "rows_scanned",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub rows_scanned: Option<Option<i64>>,
    #[serde(
        rename = "saved_query_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub saved_query_id: Option<Option<String>>,
    #[serde(
        rename = "saved_query_version",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub saved_query_version: Option<Option<i32>>,
    /// Total server-side processing time for this query (milliseconds). Measured from query start to result ready. Includes SQL execution, task spawning, and result preparation. Does not include network transit. Populated for all completed query runs (sync and async).
    #[serde(
        rename = "server_processing_ms",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub server_processing_ms: Option<Option<i64>>,
    #[serde(rename = "snapshot_id")]
    pub snapshot_id: String,
    #[serde(rename = "sql_hash")]
    pub sql_hash: String,
    #[serde(rename = "sql_text")]
    pub sql_text: String,
    #[serde(rename = "status")]
    pub status: String,
    #[serde(
        rename = "trace_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub trace_id: Option<Option<String>>,
    /// Who ran this query: the account id from the access token the request was made with. Use it to group a caller's query history.  Requests made with a credential that identifies no account instead record an opaque `user_`-prefixed identifier, which is stable for that credential but cannot be resolved to an account.
    #[serde(
        rename = "user_public_id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub user_public_id: Option<Option<String>>,
    #[serde(
        rename = "warning_message",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub warning_message: Option<Option<String>>,
}

impl QueryRunInfo {
    /// Single query run for listing
    pub fn new(
        created_at: String,
        id: String,
        snapshot_id: String,
        sql_hash: String,
        sql_text: String,
        status: String,
    ) -> QueryRunInfo {
        QueryRunInfo {
            bytes_scanned: None,
            completed_at: None,
            created_at,
            error_message: None,
            execution_time_ms: None,
            id,
            result_id: None,
            row_count: None,
            rows_scanned: None,
            saved_query_id: None,
            saved_query_version: None,
            server_processing_ms: None,
            snapshot_id,
            sql_hash,
            sql_text,
            status,
            trace_id: None,
            user_public_id: None,
            warning_message: None,
        }
    }
}