#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default)]
#[non_exhaustive]
pub enum Dialect {
#[default]
Snowflake,
Databricks,
}
impl Dialect {
#[must_use]
pub fn supports_dollar_quoting(self) -> bool {
matches!(self, Dialect::Snowflake)
}
#[must_use]
pub fn supports_flow_operator(self) -> bool {
matches!(self, Dialect::Snowflake)
}
#[must_use]
pub fn supports_copy_into(self) -> bool {
matches!(self, Dialect::Snowflake)
}
#[must_use]
pub fn supports_double_slash_comments(self) -> bool {
matches!(self, Dialect::Snowflake)
}
#[must_use]
pub fn supports_semantic_view(self) -> bool {
matches!(self, Dialect::Snowflake)
}
#[must_use]
pub fn supports_scripting_blocks(self) -> bool {
matches!(self, Dialect::Snowflake | Dialect::Databricks)
}
#[must_use]
pub fn supports_stage_refs(self) -> bool {
matches!(self, Dialect::Snowflake)
}
#[must_use]
pub fn supports_backtick_identifiers(self) -> bool {
matches!(self, Dialect::Databricks)
}
#[must_use]
pub fn supports_prefixed_strings(self) -> bool {
matches!(self, Dialect::Databricks)
}
#[must_use]
pub fn supports_null_safe_eq(self) -> bool {
matches!(self, Dialect::Databricks)
}
#[must_use]
pub fn supports_lateral_view(self) -> bool {
matches!(self, Dialect::Databricks)
}
#[must_use]
pub fn supports_delta_table_options(self) -> bool {
matches!(self, Dialect::Databricks)
}
#[must_use]
pub fn supports_lambda_expr(self) -> bool {
matches!(self, Dialect::Databricks)
}
#[must_use]
pub fn supports_as_of_travel(self) -> bool {
matches!(self, Dialect::Databricks)
}
#[must_use]
pub fn supports_databricks_query_clauses(self) -> bool {
matches!(self, Dialect::Databricks)
}
#[must_use]
pub fn supports_delta_commands(self) -> bool {
matches!(self, Dialect::Databricks)
}
}
#[cfg(test)]
mod tests {
use super::Dialect;
#[test]
fn default_is_snowflake() {
assert_eq!(Dialect::default(), Dialect::Snowflake);
}
#[test]
fn snowflake_only_predicates() {
let s = Dialect::Snowflake;
assert!(s.supports_dollar_quoting());
assert!(s.supports_flow_operator());
assert!(s.supports_copy_into());
assert!(s.supports_double_slash_comments());
assert!(s.supports_semantic_view());
assert!(s.supports_scripting_blocks());
assert!(s.supports_stage_refs());
assert!(!s.supports_backtick_identifiers());
assert!(!s.supports_prefixed_strings());
assert!(!s.supports_null_safe_eq());
assert!(!s.supports_lateral_view());
assert!(!s.supports_delta_table_options());
assert!(!s.supports_lambda_expr());
assert!(!s.supports_as_of_travel());
assert!(!s.supports_databricks_query_clauses());
assert!(!s.supports_delta_commands());
}
#[test]
fn databricks_only_predicates() {
let d = Dialect::Databricks;
assert!(!d.supports_dollar_quoting());
assert!(!d.supports_flow_operator());
assert!(!d.supports_copy_into());
assert!(!d.supports_double_slash_comments());
assert!(!d.supports_semantic_view());
assert!(d.supports_scripting_blocks());
assert!(!d.supports_stage_refs());
assert!(d.supports_backtick_identifiers());
assert!(d.supports_prefixed_strings());
assert!(d.supports_null_safe_eq());
assert!(d.supports_lateral_view());
assert!(d.supports_delta_table_options());
assert!(d.supports_lambda_expr());
assert!(d.supports_as_of_travel());
assert!(d.supports_databricks_query_clauses());
assert!(d.supports_delta_commands());
}
}