1use serde::{Deserialize, Serialize};
2use std::fmt::{Debug, Display, Formatter, Result};
3use utoipa::ToSchema;
4
5pub const MAX_WS_FRAME_SIZE: usize = 1024 * 1024 * 2;
7
8#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy, ToSchema)]
10#[serde(rename_all = "snake_case")]
11pub enum AdHocResultFormat {
12 Text,
14 Json,
16 Parquet,
18 ArrowIpc,
20}
21
22impl Display for AdHocResultFormat {
23 fn fmt(&self, f: &mut Formatter<'_>) -> Result {
24 match self {
25 AdHocResultFormat::Text => write!(f, "text"),
26 AdHocResultFormat::Json => write!(f, "json"),
27 AdHocResultFormat::Parquet => write!(f, "parquet"),
28 AdHocResultFormat::ArrowIpc => write!(f, "arrow_ipc"),
29 }
30 }
31}
32
33impl Default for AdHocResultFormat {
34 fn default() -> Self {
35 Self::Text
36 }
37}
38
39fn default_format() -> AdHocResultFormat {
40 AdHocResultFormat::default()
41}
42
43#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ToSchema)]
54pub struct AdhocQueryArgs {
55 #[serde(default)]
57 pub sql: String,
58 #[serde(default = "default_format")]
60 pub format: AdHocResultFormat,
61}