use serde::{Deserialize, Serialize};
use crate::row_batches::models::Flatten;
#[derive(Debug, Clone, PartialEq, Deserialize)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PythonSource {
pub name: String,
pub module: String,
pub settings: serde_json::Map<String, serde_json::Value>,
#[serde(default)]
pub http_paths: std::collections::BTreeMap<String, crate::http_source::models::LiteralPaths>,
#[serde(default)]
pub host: Option<serde_json::Value>,
}
impl PythonSource {
pub fn new(
name: impl Into<String>,
module: impl Into<String>,
settings: serde_json::Map<String, serde_json::Value>,
) -> Self {
Self {
name: name.into(),
module: module.into(),
settings,
http_paths: std::collections::BTreeMap::new(),
host: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct TableRead {
pub source: String,
pub table: String,
pub connection: Option<String>,
pub connections: serde_json::Map<String, serde_json::Value>,
pub withheld: Vec<String>,
pub cursor: Option<CursorRead>,
pub logged: bool,
pub state: Option<String>,
pub is_reload: bool,
#[serde(skip)]
pub flatten: Flatten,
pub masked: Vec<String>,
pub arrays: Vec<String>,
#[serde(skip)]
pub naming: (crate::load_naming::models::Naming, Option<usize>),
#[serde(skip)]
pub zone: Option<chrono_tz::Tz>,
#[serde(skip)]
pub source_part: Option<u64>,
pub host: Option<serde_json::Value>,
}
impl TableRead {
pub fn new(source: impl Into<String>, table: impl Into<String>) -> Self {
Self {
source: source.into(),
table: table.into(),
connection: None,
connections: serde_json::Map::new(),
withheld: Vec::new(),
cursor: None,
logged: false,
state: None,
is_reload: false,
flatten: Flatten::default(),
masked: Vec::new(),
arrays: Vec::new(),
naming: (crate::load_naming::models::Naming::default(), None),
zone: None,
source_part: None,
host: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct CursorRead {
pub column: String,
pub column_type: String,
pub start: Option<String>,
pub end: Option<String>,
pub inclusive: bool,
pub timezone: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)]
pub struct TransformContext {
pub unit: &'static str,
pub table: String,
pub path: Option<String>,
pub modified_at: Option<String>,
pub sheet: Option<String>,
pub range: Option<String>,
pub skip_rows: Option<u32>,
pub spreadsheet_id: Option<String>,
pub page: Option<u64>,
pub key: Option<serde_json::Map<String, serde_json::Value>>,
}
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct TransformCall {
pub function: String,
pub context: TransformContext,
pub masked: Vec<String>,
pub arrays: Vec<String>,
#[serde(skip)]
pub naming: (crate::load_naming::models::Naming, Option<usize>),
#[serde(skip)]
pub flatten: Flatten,
}
#[derive(Debug, Clone)]
pub struct TransformRan {
pub dicts: bool,
pub rows_in: u64,
pub seconds: f64,
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct TransformTime {
pub file: String,
pub milliseconds: u64,
pub rows: u64,
pub dicts: bool,
}
#[derive(Debug, Clone)]
pub struct TransformFiles<'a> {
pub host: std::sync::Arc<dyn crate::python_sources::types::PythonHost>,
pub call: TransformCall,
pub files: &'a [crate::files_source::models::DataFile],
pub location: String,
pub encoding: &'a crate::files_source::models::FilesEncoding,
}