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