use serde::{Deserialize, Serialize};
use std::fmt::{Debug, Display, Formatter, Result};
use utoipa::ToSchema;
pub const MAX_WS_FRAME_SIZE: usize = 1024 * 1024 * 2;
pub const WS_SUBPROTOCOL: &str = "feldera-ws-v1";
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy, ToSchema)]
#[serde(rename_all = "snake_case")]
#[derive(Default)]
pub enum AdHocResultFormat {
#[default]
Text,
Json,
Parquet,
ArrowIpc,
Hash,
}
impl Display for AdHocResultFormat {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match self {
AdHocResultFormat::Text => write!(f, "text"),
AdHocResultFormat::Json => write!(f, "json"),
AdHocResultFormat::Parquet => write!(f, "parquet"),
AdHocResultFormat::ArrowIpc => write!(f, "arrow_ipc"),
AdHocResultFormat::Hash => write!(f, "hash"),
}
}
}
fn default_format() -> AdHocResultFormat {
AdHocResultFormat::default()
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ToSchema)]
pub struct AdhocQueryArgs {
#[serde(default)]
pub sql: String,
#[serde(default = "default_format")]
pub format: AdHocResultFormat,
}