use sqlparser::ast::{DiscardObject, Statement};
use sqlparser::tokenizer::TokenWithSpan;
use std::sync::Arc;
#[derive(Debug)]
pub struct LocatedStatement {
pub statement: Statement,
pub source: Option<Arc<[TokenWithSpan]>>,
pub(crate) function_projection: bool,
pub(crate) synthetic_select: bool,
pub(crate) recovered_functions: Vec<crate::SqlFunctionCallFact>,
pub(crate) policy_arbiter: Option<crate::source::PolicyArbiter>,
pub complete: bool,
pub(crate) partition_complete: bool,
pub chunk_tokens: Option<Arc<[TokenWithSpan]>>,
pub recovery_failure: Option<super::super::super::types::SqlUnanalyzableStatement>,
}
impl LocatedStatement {
pub(super) fn plain(statement: Statement) -> Self {
Self {
statement,
source: None,
function_projection: false,
synthetic_select: false,
recovered_functions: Vec::new(),
policy_arbiter: None,
complete: false,
partition_complete: false,
chunk_tokens: None,
recovery_failure: None,
}
}
pub(super) fn failed_source(sql: &str, line: usize, column: usize, ordinal: usize) -> Self {
Self {
recovery_failure: Some(super::recover::failed_source(sql, line, column, ordinal)),
..Self::functions(
Statement::Discard {
object_type: DiscardObject::ALL,
},
false,
)
}
}
pub(super) fn functions(statement: Statement, synthetic_select: bool) -> Self {
Self {
function_projection: true,
synthetic_select,
..Self::plain(statement)
}
}
}