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