sql-dialect-fmt-formatter 1.18.0

Generic Wadler/Prettier-style Doc IR + width-aware printer, plus the Snowflake SQL formatting rules built on the lossless CST.
Documentation
//! Snowflake COPY / object-DDL option key recognition.

/// Whether `word` (case-insensitively) is a canonical Snowflake COPY / object-DDL option key.
///
/// Adding a word here only changes the casing of a recognized key in key position. It never
/// re-spells values, identifiers, or literals.
pub(super) fn is_option_key(word: &str) -> bool {
    OPTION_KEYS
        .binary_search(&word.to_ascii_lowercase().as_str())
        .is_ok()
}

/// A no-value option flag word (`ORDER` / `NOORDER`): a recognized key that stands alone with no
/// `= value`.
pub(super) fn is_option_flag(word: &str) -> bool {
    OPTION_FLAGS
        .binary_search(&word.to_ascii_lowercase().as_str())
        .is_ok()
}

/// Canonical option-key spellings, lower-cased and kept sorted for `binary_search`. Multi-word
/// keys such as `PARTITION BY`, `START WITH`, `CLUSTER BY`, `COPY GRANTS` are recognized via their
/// already-reserved leading keyword and the `WITH`/`BY` connector.
const OPTION_KEYS: &[&str] = &[
    "aggregation_policy",
    "ai_question_categorization",
    "ai_sql_generation",
    "ai_verified_queries",
    "allow_client_mfa_caching",
    "allow_duplicate",
    "allow_id_token",
    "allowed_values",
    "append_only",
    "authentication_policy",
    "auto_compress",
    "auto_refresh",
    "auto_resume",
    "auto_suspend",
    "auto_suspend_secs",
    "base_location",
    "binary_as_text",
    "binary_format",
    "catalog",
    "catalog_sync",
    "change_tracking",
    "classification_profile",
    "comment",
    "compression",
    "config",
    "contact",
    "credentials",
    "data_metric_function",
    "data_metric_schedule",
    "data_retention_time_in_days",
    "date_format",
    "default_database",
    "default_ddl_collation",
    "default_namespace",
    "default_role",
    "default_secondary_roles",
    "default_warehouse",
    "detailed_output",
    "directory",
    "disable_auto_convert",
    "empty_field_as_null",
    "enable",
    "enable_octal",
    "enable_query_acceleration",
    "enable_schema_evolution",
    "encoding",
    "encryption",
    "enforce_length",
    "error_integration",
    "error_on_column_count_mismatch",
    "escape",
    "escape_unenclosed_field",
    "event_table",
    "execute_as",
    "exempt_other_policies",
    "external_table_auto_refresh",
    "external_volume",
    "field_delimiter",
    "field_optionally_enclosed_by",
    "file_extension",
    "file_format",
    "files",
    "finalize",
    "force",
    "format_name",
    "ignore_utf8_errors",
    "include_metadata",
    "include_query_id",
    "increment",
    "initialize",
    "initially_suspended",
    "insert_only",
    "instance_family",
    "join_policy",
    "log_level",
    "master_key",
    "match_by_column_name",
    "max_cluster_count",
    "max_concurrency_level",
    "max_data_extension_time_in_days",
    "max_file_size",
    "max_nodes",
    "min_cluster_count",
    "min_nodes",
    "multi_line",
    "network_policy",
    "null_if",
    "on_error",
    "overlap_policy",
    "overwrite",
    "parallel",
    "parse_header",
    "password_policy",
    "pattern",
    "pipe_execution_paused",
    "preserve_space",
    "projection_policy",
    "propagate",
    "purge",
    "query_acceleration_max_scale_factor",
    "query_tag",
    "record_delimiter",
    "refresh_mode",
    "refresh_on_create",
    "replace_invalid_characters",
    "resource_constraint",
    "resource_monitor",
    "return_failed_only",
    "runtime_version",
    "scaling_policy",
    "schedule",
    "serverless_task_max_statement_size",
    "serverless_task_min_statement_size",
    "session_policy",
    "show_initial_rows",
    "single",
    "size_limit",
    "skip_blank_lines",
    "skip_byte_order_mark",
    "skip_header",
    "snappy_compression",
    "source_compression",
    "start",
    "statement_queued_timeout_in_seconds",
    "statement_timeout_in_seconds",
    "storage_integration",
    "storage_serialization_policy",
    "strip_null_values",
    "strip_outer_array",
    "strip_outer_element",
    "suspend_task_after_num_failures",
    "target_completion_interval",
    "target_file_size",
    "target_lag",
    "task_auto_retry_attempts",
    "time_format",
    "timestamp_format",
    "timestamp_output_format",
    "timezone",
    "trace_level",
    "trim_space",
    "truncatecolumns",
    "type",
    "url",
    "use_logical_type",
    "use_vectorized_scanner",
    "user_task_managed_initial_warehouse_size",
    "user_task_minimum_trigger_interval_in_seconds",
    "user_task_timeout_ms",
    "validation_mode",
    "warehouse",
    "warehouse_size",
    "warehouse_type",
    "week_start",
];

/// No-value option flag words, lower-cased and kept sorted.
const OPTION_FLAGS: &[&str] = &["noorder", "order"];