Skip to main content

sqruff_lib_dialects/
snowflake.rs

1use itertools::Itertools;
2use sqruff_lib_core::dialects::Dialect;
3use sqruff_lib_core::dialects::init::DialectKind;
4use sqruff_lib_core::dialects::syntax::SyntaxKind;
5use sqruff_lib_core::helpers::{Config, ToMatchable};
6use sqruff_lib_core::parser::grammar::anyof::{
7    AnyNumberOf, any_set_of, one_of, optionally_bracketed,
8};
9use sqruff_lib_core::parser::grammar::conditional::Conditional;
10use sqruff_lib_core::parser::grammar::delimited::Delimited;
11use sqruff_lib_core::parser::grammar::sequence::{Bracketed, Sequence};
12use sqruff_lib_core::parser::grammar::{Nothing, Ref};
13use sqruff_lib_core::parser::lexer::Matcher;
14use sqruff_lib_core::parser::matchable::{Matchable, MatchableTrait};
15use sqruff_lib_core::parser::node_matcher::NodeMatcher;
16use sqruff_lib_core::parser::parsers::{MultiStringParser, RegexParser, StringParser, TypedParser};
17use sqruff_lib_core::parser::segments::generator::SegmentGenerator;
18use sqruff_lib_core::parser::segments::meta::MetaSegment;
19use sqruff_lib_core::parser::types::ParseMode;
20
21use super::ansi::{self, raw_dialect};
22use super::snowflake_keywords::{SNOWFLAKE_RESERVED_KEYWORDS, SNOWFLAKE_UNRESERVED_KEYWORDS};
23use sqruff_lib_core::dialects::init::{DialectConfig, NullDialectConfig};
24use sqruff_lib_core::value::Value;
25
26/// Configuration for the Snowflake dialect.
27pub type SnowflakeDialectConfig = NullDialectConfig;
28
29pub fn dialect(config: Option<&Value>) -> Dialect {
30    // Parse and validate dialect configuration, falling back to defaults on failure
31    let _dialect_config: SnowflakeDialectConfig = config
32        .map(SnowflakeDialectConfig::from_value)
33        .unwrap_or_default();
34    let mut snowflake_dialect = raw_dialect();
35    snowflake_dialect.name = DialectKind::Snowflake;
36
37    snowflake_dialect.replace_grammar(
38        "SelectClauseElementSegment",
39        ansi::select_clause_element().copy(
40            Some(vec![
41                Sequence::new(vec![
42                    Ref::new("SystemFunctionName").to_matchable(),
43                    Bracketed::new(vec![Ref::new("QuotedLiteralSegment").to_matchable()])
44                        .to_matchable(),
45                ])
46                .to_matchable(),
47            ]),
48            None,
49            Some(Ref::new("WildcardExpressionSegment").to_matchable()),
50            None,
51            Vec::new(),
52            false,
53        ),
54    );
55
56    snowflake_dialect.replace_grammar(
57        "FromExpressionElementSegment",
58        Sequence::new(vec![
59            Ref::new("PreTableFunctionKeywordsGrammar")
60                .optional()
61                .to_matchable(),
62            optionally_bracketed(vec![Ref::new("TableExpressionSegment").to_matchable()])
63                .to_matchable(),
64            Ref::new("AliasExpressionSegment")
65                .exclude(one_of(vec![
66                    Ref::new("FromClauseTerminatorGrammar").to_matchable(),
67                    Ref::new("SamplingExpressionSegment").to_matchable(),
68                    Ref::new("ChangesClauseSegment").to_matchable(),
69                    Ref::new("JoinLikeClauseGrammar").to_matchable(),
70                    Ref::keyword("CROSS").to_matchable(),
71                ]))
72                .optional()
73                .to_matchable(),
74            Sequence::new(vec![
75                Ref::keyword("WITH").to_matchable(),
76                Ref::keyword("OFFSET").to_matchable(),
77                Ref::new("AliasExpressionSegment").to_matchable(),
78            ])
79            .config(|this| this.optional())
80            .to_matchable(),
81            Ref::new("SamplingExpressionSegment")
82                .optional()
83                .to_matchable(),
84            Ref::new("PostTableExpressionGrammar")
85                .optional()
86                .to_matchable(),
87        ])
88        .to_matchable(),
89    );
90
91    snowflake_dialect.replace_grammar(
92        "JoinClauseSegment",
93        one_of(vec![
94            Sequence::new(vec![
95                Ref::new("JoinTypeKeywordsGrammar")
96                    .optional()
97                    .to_matchable(),
98                Ref::new("JoinKeywordsGrammar").to_matchable(),
99                MetaSegment::indent().to_matchable(),
100                Ref::new("FromExpressionElementSegment").to_matchable(),
101                AnyNumberOf::new(vec![Ref::new("NestedJoinGrammar").to_matchable()]).to_matchable(),
102                MetaSegment::dedent().to_matchable(),
103                Sequence::new(vec![
104                    Conditional::new(MetaSegment::indent())
105                        .indented_using_on()
106                        .to_matchable(),
107                    one_of(vec![
108                        Ref::new("JoinOnConditionSegment").to_matchable(),
109                        Sequence::new(vec![
110                            Ref::keyword("USING").to_matchable(),
111                            MetaSegment::indent().to_matchable(),
112                            Bracketed::new(vec![
113                                Delimited::new(vec![
114                                    Ref::new("SingleIdentifierGrammar").to_matchable(),
115                                ])
116                                .to_matchable(),
117                            ])
118                            .config(|this| this.parse_mode = ParseMode::Greedy)
119                            .to_matchable(),
120                            MetaSegment::dedent().to_matchable(),
121                        ])
122                        .to_matchable(),
123                    ])
124                    .to_matchable(),
125                    Conditional::new(MetaSegment::dedent())
126                        .indented_using_on()
127                        .to_matchable(),
128                ])
129                .config(|this| this.optional())
130                .to_matchable(),
131            ])
132            .to_matchable(),
133            Sequence::new(vec![
134                Ref::new("NaturalJoinKeywordsGrammar").to_matchable(),
135                Ref::new("JoinKeywordsGrammar").to_matchable(),
136                MetaSegment::indent().to_matchable(),
137                Ref::new("FromExpressionElementSegment").to_matchable(),
138                MetaSegment::dedent().to_matchable(),
139            ])
140            .to_matchable(),
141            Sequence::new(vec![
142                Ref::new("ExtendedNaturalJoinKeywordsGrammar").to_matchable(),
143                MetaSegment::indent().to_matchable(),
144                Ref::new("FromExpressionElementSegment").to_matchable(),
145                MetaSegment::dedent().to_matchable(),
146            ])
147            .to_matchable(),
148            Sequence::new(vec![
149                Ref::keyword("ASOF").to_matchable(),
150                Ref::keyword("JOIN").to_matchable(),
151                MetaSegment::indent().to_matchable(),
152                Ref::new("FromExpressionElementSegment").to_matchable(),
153                AnyNumberOf::new(vec![Ref::new("NestedJoinGrammar").to_matchable()]).to_matchable(),
154                MetaSegment::dedent().to_matchable(),
155                MetaSegment::indent().to_matchable(),
156                Ref::new("MatchConditionSegment").to_matchable(),
157                MetaSegment::dedent().to_matchable(),
158                Sequence::new(vec![
159                    Conditional::new(MetaSegment::indent())
160                        .indented_using_on()
161                        .to_matchable(),
162                    one_of(vec![
163                        Ref::new("JoinOnConditionSegment").to_matchable(),
164                        Sequence::new(vec![
165                            Ref::keyword("USING").to_matchable(),
166                            MetaSegment::indent().to_matchable(),
167                            Bracketed::new(vec![
168                                Delimited::new(vec![
169                                    Ref::new("SingleIdentifierGrammar").to_matchable(),
170                                ])
171                                .to_matchable(),
172                            ])
173                            .config(|this| this.parse_mode = ParseMode::Greedy)
174                            .to_matchable(),
175                            MetaSegment::dedent().to_matchable(),
176                        ])
177                        .to_matchable(),
178                    ])
179                    .to_matchable(),
180                    Conditional::new(MetaSegment::dedent())
181                        .indented_using_on()
182                        .to_matchable(),
183                ])
184                .config(|this| this.optional())
185                .to_matchable(),
186            ])
187            .to_matchable(),
188        ])
189        .to_matchable(),
190    );
191
192    snowflake_dialect.patch_lexer_matchers(vec![
193        Matcher::regex(
194            "single_quote",
195            r"'([^'\\]|\\.|'')*'",
196            SyntaxKind::SingleQuote,
197        ),
198        Matcher::regex(
199            "inline_comment",
200            r"(--|#|//)[^\n]*",
201            SyntaxKind::InlineComment,
202        ),
203    ]);
204
205    snowflake_dialect.insert_lexer_matchers(
206        vec![
207            Matcher::string("parameter_assigner", "=>", SyntaxKind::ParameterAssigner),
208            Matcher::string("function_assigner", "->", SyntaxKind::FunctionAssigner),
209            Matcher::regex(
210                "stage_path",
211                r"(?:@[^\s;)]+|'@[^']+')",
212                SyntaxKind::StagePath,
213            ),
214            Matcher::regex("column_selector", r"\$[0-9]+", SyntaxKind::ColumnSelector),
215            Matcher::regex("dollar_quote", r"\$\$.*\$\$", SyntaxKind::DollarQuote),
216            Matcher::regex(
217                "dollar_literal",
218                r"[$][a-zA-Z0-9_.]*",
219                SyntaxKind::DollarLiteral,
220            ),
221            Matcher::regex(
222                "inline_dollar_sign",
223                r"[a-zA-Z_][a-zA-Z0-9_$]*\$[a-zA-Z0-9_$]*",
224                SyntaxKind::Raw,
225            ),
226            Matcher::regex(
227                "unquoted_file_path",
228                r"file://(?:[a-zA-Z]+:|/)+(?:[0-9a-zA-Z\\/_*?-]+)(?:\.[0-9a-zA-Z]+)?",
229                SyntaxKind::UnquotedFilePath,
230            ),
231            Matcher::string("question_mark", "?", SyntaxKind::QuestionMark),
232            Matcher::string("exclude_bracket_open", "{-", SyntaxKind::ExcludeBracketOpen),
233            Matcher::string(
234                "exclude_bracket_close",
235                "-}",
236                SyntaxKind::ExcludeBracketClose,
237            ),
238        ],
239        "like_operator",
240    );
241
242    snowflake_dialect.insert_lexer_matchers(
243        vec![Matcher::string(
244            "walrus_operator",
245            ":=",
246            SyntaxKind::WalrusOperator,
247        )],
248        "equals",
249    );
250
251    snowflake_dialect.bracket_sets_mut("bracket_pairs").insert((
252        "exclude",
253        "StartExcludeBracketSegment",
254        "EndExcludeBracketSegment",
255        true,
256    ));
257
258    snowflake_dialect.sets_mut("bare_functions").clear();
259    snowflake_dialect.sets_mut("bare_functions").extend([
260        "CURRENT_DATE",
261        "CURRENT_TIME",
262        "CURRENT_TIMESTAMP",
263        "CURRENT_USER",
264        "LOCALTIME",
265        "LOCALTIMESTAMP",
266    ]);
267
268    snowflake_dialect.sets_mut("compression_types").clear();
269    snowflake_dialect.sets_mut("compression_types").extend([
270        "AUTO",
271        "AUTO_DETECT",
272        "GZIP",
273        "BZ2",
274        "BROTLI",
275        "ZSTD",
276        "DEFLATE",
277        "RAW_DEFLATE",
278        "LZO",
279        "NONE",
280        "SNAPPY",
281    ]);
282
283    snowflake_dialect.sets_mut("files_types").clear();
284    snowflake_dialect
285        .sets_mut("files_types")
286        .extend(["CSV", "JSON", "AVRO", "ORC", "PARQUET", "XML"]);
287
288    snowflake_dialect.sets_mut("warehouse_types").clear();
289    snowflake_dialect
290        .sets_mut("warehouse_types")
291        .extend(["STANDARD", "SNOWPARK-OPTIMIZED"]);
292
293    snowflake_dialect.sets_mut("warehouse_sizes").clear();
294    snowflake_dialect.sets_mut("warehouse_sizes").extend([
295        "XSMALL", "SMALL", "MEDIUM", "LARGE", "XLARGE", "XXLARGE", "X2LARGE", "XXXLARGE",
296        "X3LARGE", "X4LARGE", "X5LARGE", "X6LARGE", "X-SMALL", "X-LARGE", "2X-LARGE", "3X-LARGE",
297        "4X-LARGE", "5X-LARGE", "6X-LARGE",
298    ]);
299
300    snowflake_dialect
301        .sets_mut("warehouse_scaling_policies")
302        .clear();
303    snowflake_dialect
304        .sets_mut("warehouse_scaling_policies")
305        .extend(["STANDARD", "ECONOMY"]);
306
307    // Snowflake supports CTEs with DML statements (INSERT, UPDATE, DELETE, MERGE)
308    // We add these to NonWithSelectableGrammar so WithCompoundStatementSegment can use them
309    snowflake_dialect.add([(
310        "NonWithSelectableGrammar".into(),
311        one_of(vec![
312            Ref::new("SetExpressionSegment").to_matchable(),
313            optionally_bracketed(vec![Ref::new("SelectStatementSegment").to_matchable()])
314                .to_matchable(),
315            Ref::new("NonSetSelectableGrammar").to_matchable(),
316            Ref::new("UpdateStatementSegment").to_matchable(),
317            Ref::new("InsertStatementSegment").to_matchable(),
318            Ref::new("DeleteStatementSegment").to_matchable(),
319            Ref::new("MergeStatementSegment").to_matchable(),
320        ])
321        .to_matchable()
322        .into(),
323    )]);
324
325    snowflake_dialect.add([
326        (
327            "ParameterAssignerSegment".into(),
328            StringParser::new(
329                "=>",
330                SyntaxKind::ParameterAssigner
331            )
332            .to_matchable()
333            .into(),
334        ),
335        (
336            "FunctionAssignerSegment".into(),
337            StringParser::new(
338                "->",
339                SyntaxKind::FunctionAssigner
340            )
341            .to_matchable()
342            .into(),
343        ),
344        (
345            "WalrusOperatorSegment".into(),
346            StringParser::new(
347                ":=",
348                SyntaxKind::AssignmentOperator
349            )
350            .to_matchable()
351            .into(),
352        ),
353        (
354            "QuotedStarSegment".into(),
355            StringParser::new(
356                "'*'",
357                SyntaxKind::QuotedStar
358            )
359            .to_matchable()
360            .into(),
361        ),
362        (
363            "NakedSemiStructuredElementSegment".into(),
364            RegexParser::new(
365                "[A-Z0-9_]*",
366                SyntaxKind::SemiStructuredElement
367            )
368            .to_matchable()
369            .into(),
370        ),
371        (
372            "QuotedSemiStructuredElementSegment".into(),
373            TypedParser::new(
374                SyntaxKind::DoubleQuote,
375                SyntaxKind::SemiStructuredElement,
376            )
377            .to_matchable()
378            .into(),
379        ),
380        (
381            "ColumnIndexIdentifierSegment".into(),
382            RegexParser::new(
383                r"\$[0-9]+",
384                SyntaxKind::ColumnIndexIdentifierSegment
385            )
386            .to_matchable()
387            .into(),
388        ),
389        (
390            "LocalVariableNameSegment".into(),
391            RegexParser::new(
392                r"[a-zA-Z0-9_]*",
393                SyntaxKind::Variable
394            )
395            .to_matchable()
396            .into(),
397        ),
398        (
399            "ReferencedVariableNameSegment".into(),
400            RegexParser::new(
401                r"\$[A-Z_][A-Z0-9_]*",
402                SyntaxKind::Variable
403            )
404            .to_matchable()
405            .into(),
406        ),
407        (
408            "WarehouseType".into(),
409            one_of(vec![
410                MultiStringParser::new(
411                    snowflake_dialect
412                        .sets("warehouse_types")
413                        .into_iter()
414                        .filter(|it| !it.contains('-'))
415                        .map_into()
416                        .collect_vec(),
417                    SyntaxKind::WarehouseSize
418                ).to_matchable(),
419                MultiStringParser::new(
420                    snowflake_dialect
421                        .sets("warehouse_types")
422                        .into_iter()
423                        .map(|it| format!("'{it}'"))
424                        .collect_vec(),
425                    SyntaxKind::WarehouseSize
426                ).to_matchable()
427            ])
428            .to_matchable()
429            .into(),
430        ),
431        (
432            "WarehouseSize".into(),
433            one_of(vec![
434                MultiStringParser::new(
435                    snowflake_dialect
436                        .sets("warehouse_sizes")
437                        .into_iter()
438                        .filter(|it| !it.contains('-'))
439                        .map_into()
440                        .collect_vec(),
441                   SyntaxKind::WarehouseSize
442                ).to_matchable(),
443                MultiStringParser::new(
444                    snowflake_dialect
445                        .sets("warehouse_sizes")
446                        .into_iter()
447                        .map(|it| format!("'{it}'"))
448                        .collect_vec(),
449                    SyntaxKind::WarehouseSize
450                ).to_matchable()
451            ])
452            .to_matchable()
453            .into(),
454        ),
455        (
456            "CompressionType".into(),
457            one_of(vec![
458                MultiStringParser::new(
459                    snowflake_dialect
460                        .sets("compression_types")
461                        .into_iter()
462                        .map_into()
463                        .collect_vec(),
464                   SyntaxKind::CompressionType
465
466                ).to_matchable(),
467                MultiStringParser::new(
468                    snowflake_dialect
469                        .sets("compression_types")
470                        .into_iter()
471                        .map(|it| format!("'{it}'"))
472                        .collect_vec(),
473                   SyntaxKind::CompressionType
474                ).to_matchable()
475            ])
476            .to_matchable()
477            .into(),
478        ),
479        (
480            "ScalingPolicy".into(),
481            one_of(vec![
482                MultiStringParser::new(
483                    snowflake_dialect
484                        .sets("warehouse_scaling_policies")
485                        .into_iter()
486                        .filter(|it| !it.contains('-'))
487                        .map_into()
488                        .collect_vec(),
489                   SyntaxKind::ScalingPolicy
490                ).to_matchable(),
491                MultiStringParser::new(
492                    snowflake_dialect
493                        .sets("warehouse_scaling_policies")
494                        .into_iter()
495                        .map(|it| format!("'{it}'"))
496                        .collect_vec(),
497                   SyntaxKind::ScalingPolicy
498                ).to_matchable()
499            ])
500            .to_matchable()
501            .into(),
502        ),
503        (
504            "ValidationModeOptionSegment".into(),
505            RegexParser::new(
506                r"'?RETURN_(?:\d+_ROWS|ERRORS|ALL_ERRORS)'?",
507                SyntaxKind::ValidationModeOption
508            )
509            .to_matchable()
510            .into(),
511        ),
512        (
513            "CopyOptionOnErrorSegment".into(),
514            RegexParser::new(
515                r"'?CONTINUE'?|'?SKIP_FILE(?:_[0-9]+%?)?'?|'?ABORT_STATEMENT'?",
516                SyntaxKind::CopyOnErrorOption
517            )
518            .to_matchable()
519            .into(),
520        ),
521        (
522            "DoubleQuotedUDFBody".into(),
523            TypedParser::new(
524                SyntaxKind::DoubleQuote,
525                SyntaxKind::UdfBody,
526            )
527            .to_matchable()
528            .into(),
529        ),
530        (
531            "SingleQuotedUDFBody".into(),
532            TypedParser::new(
533                SyntaxKind::SingleQuote,
534                SyntaxKind::UdfBody,
535            )
536            .to_matchable()
537            .into(),
538        ),
539        (
540            "DollarQuotedUDFBody".into(),
541            TypedParser::new(
542                SyntaxKind::DollarQuote,
543                SyntaxKind::UdfBody,
544            )
545            .to_matchable()
546            .into(),
547        ),
548        (
549            "StagePath".into(),
550            RegexParser::new(
551                r"(?:@[^\s;)]+|'@[^']+')",
552                SyntaxKind::StagePath
553            )
554            .to_matchable()
555            .into(),
556        ),
557        (
558            "S3Path".into(),
559            RegexParser::new(
560                r"'s3://[a-z0-9][a-z0-9\.-]{1,61}[a-z0-9](?:/.*)?'",
561                SyntaxKind::BucketPath
562            )
563            .to_matchable()
564            .into(),
565        ),
566        (
567            "GCSPath".into(),
568            RegexParser::new(
569                r"'gcs://[a-z0-9][\w\.-]{1,61}[a-z0-9](?:/.+)?'",
570                SyntaxKind::BucketPath
571            )
572            .to_matchable()
573            .into(),
574        ),
575        (
576            "AzureBlobStoragePath".into(),
577            RegexParser::new(
578                r"'azure://[a-z0-9][a-z0-9-]{1,61}[a-z0-9]\.blob\.core\.windows\.net/[a-z0-9][a-z0-9\.-]{1,61}[a-z0-9](?:/.+)?'",
579                SyntaxKind::BucketPath
580            )
581            .to_matchable()
582            .into(),
583        ),
584        (
585            "UnquotedFilePath".into(),
586            TypedParser::new(
587                SyntaxKind::UnquotedFilePath,
588                SyntaxKind::UnquotedFilePath,
589            )
590            .to_matchable()
591            .into(),
592        ),
593        (
594            "SnowflakeEncryptionOption".into(),
595            MultiStringParser::new(
596                vec!["'SNOWFLAKE_FULL'".into(), "'SNOWFLAKE_SSE'".into()],
597                SyntaxKind::StageEncryptionOption
598            ).to_matchable().into(),
599        ),
600        (
601            "S3EncryptionOption".into(),
602            MultiStringParser::new(
603                vec!["'AWS_CSE'".into(), "'AWS_SSE_S3'".into(), "'AWS_SSE_KMS'".into()],
604                SyntaxKind::StageEncryptionOption
605            ).to_matchable().into(),
606        ),
607        (
608            "GCSEncryptionOption".into(),
609            MultiStringParser::new(
610                vec!["'GCS_SSE_KMS'".into()],
611                SyntaxKind::StageEncryptionOption
612            ).to_matchable().into(),
613        ),
614        (
615            "AzureBlobStorageEncryptionOption".into(),
616            MultiStringParser::new(
617                vec!["'AZURE_CSE'".into()],
618                SyntaxKind::StageEncryptionOption
619            ).to_matchable().into(),
620        ),
621        (
622            "FileType".into(),
623            one_of(vec![
624                MultiStringParser::new(
625                    snowflake_dialect
626                        .sets("file_types")
627                        .into_iter()
628                        .filter(|it| !it.contains('-'))
629                        .map_into()
630                        .collect_vec(),
631                   SyntaxKind::FileType
632                ).to_matchable(),
633                MultiStringParser::new(
634                    snowflake_dialect
635                        .sets("file_types")
636                        .into_iter()
637                        .map(|it| format!("'{it}'"))
638                        .collect_vec(),
639                  SyntaxKind::FileType
640                ).to_matchable()
641            ])
642            .to_matchable()
643            .into(),
644        ),
645        (
646            "IntegerSegment".into(),
647            RegexParser::new(
648                r"[0-9]+",
649                SyntaxKind::IntegerLiteral
650            )
651            .to_matchable()
652            .into(),
653        ),
654        (
655            "SystemFunctionName".into(),
656            RegexParser::new(
657                r"SYSTEM\$([A-Za-z0-9_]*)",
658                SyntaxKind::SystemFunctionName
659            )
660            .to_matchable()
661            .into(),
662        ),
663        (
664            "GroupByContentsGrammar".into(),
665            Delimited::new(vec![
666                one_of(vec![
667                    Ref::new("ColumnReferenceSegment").to_matchable(),
668                    // Can `GROUP BY 1`
669                    Ref::new("NumericLiteralSegment").to_matchable(),
670                    // Can `GROUP BY coalesce(col, 1)`
671                    Ref::new("ExpressionSegment").to_matchable(),]).to_matchable(),]).config(|this|this.terminators = vec![
672                Ref::keyword("ORDER").to_matchable(),
673                Ref::keyword("LIMIT").to_matchable(),
674                Ref::keyword("FETCH").to_matchable(),
675                Ref::keyword("OFFSET").to_matchable(),
676                Ref::keyword("HAVING").to_matchable(),
677                Ref::keyword("QUALIFY").to_matchable(),
678                Ref::keyword("WINDOW").to_matchable(),]).to_matchable().into()
679        ),
680        (
681            "LimitLiteralGrammar".into(),
682            one_of(vec![
683                Ref::new("NumericLiteralSegment").to_matchable(),
684                Ref::keyword("NULL").to_matchable(),
685                Ref::new("QuotedLiteralSegment").to_matchable()
686            ]).to_matchable().into()
687        ),
688        (
689            "StartExcludeBracketSegment".into(),
690            StringParser::new(
691                "{-",
692                SyntaxKind::StartExcludeBracket
693            )
694            .to_matchable()
695            .into(),
696        ),
697        (
698            "EndExcludeBracketSegment".into(),
699            StringParser::new(
700                "-}",
701                SyntaxKind::EndExcludeBracket
702            )
703            .to_matchable()
704            .into(),
705        ),
706        (
707            "QuestionMarkSegment".into(),
708            StringParser::new(
709                "?",
710                SyntaxKind::QuestionMark
711            )
712            .to_matchable()
713            .into(),
714        ),
715        (
716            "CaretSegment".into(),
717            StringParser::new(
718                "^",
719                SyntaxKind::Caret
720            )
721            .to_matchable()
722            .into(),
723        ),
724        (
725            "DollarSegment".into(),
726            StringParser::new(
727                "$",
728                SyntaxKind::Dollar
729            )
730            .to_matchable()
731            .into(),
732        ),
733        (
734            "PatternQuantifierGrammar".into(),
735            Sequence::new(vec![
736                one_of(vec![
737                    Ref::new("PositiveSegment").to_matchable(),
738                    Ref::new("StarSegment").to_matchable(),
739                    Ref::new("QuestionMarkSegment").to_matchable(),
740                    Bracketed::new(vec![
741                        one_of(vec![
742                            Ref::new("NumericLiteralSegment").to_matchable(),
743                            Sequence::new(vec![
744                                Ref::new("NumericLiteralSegment").to_matchable(),
745                                Ref::new("CommaSegment").to_matchable(),]).to_matchable(),
746                            Sequence::new(vec![
747                                Ref::new("CommaSegment").to_matchable(),
748                                Ref::new("NumericLiteralSegment").to_matchable(),]).to_matchable(),
749                            Sequence::new(vec![
750                                Ref::new("NumericLiteralSegment").to_matchable(),
751                                Ref::new("CommaSegment").to_matchable(),
752                                Ref::new("NumericLiteralSegment").to_matchable(),]).to_matchable(),]).to_matchable(),]).config(|this| {
753                        this.bracket_type = "curly";
754                        this.bracket_pairs_set = "bracket_pairs";
755                    }).to_matchable()
756                ]).to_matchable(),
757                Ref::new("QuestionMarkSegment").optional().to_matchable()
758            ]).config(|this| {
759                this.allow_gaps = false;
760            }).to_matchable().into()
761        ),
762        (
763            "PatternSymbolGrammar".into(),
764            Sequence::new(vec![
765                Ref::new("SingleIdentifierGrammar").to_matchable(),
766                Ref::new("PatternQuantifierGrammar").optional().to_matchable()
767            ]).config(|this| {
768                this.allow_gaps = false;
769            }).to_matchable().into()
770        ),
771        (
772            "PatternOperatorGrammar".into(),
773            one_of(vec![
774                Ref::new("PatternSymbolGrammar").to_matchable(),
775                Sequence::new(vec![
776                    one_of(vec![
777                        Bracketed::new(vec![
778                            one_of(vec![
779                                AnyNumberOf::new(vec![Ref::new("PatternOperatorGrammar").to_matchable(),]).to_matchable(),
780                                Delimited::new(
781                                    vec![
782                                        Ref::new("PatternOperatorGrammar").to_matchable(),]
783                                )
784                                .config(|this|this.delimiter(Ref::new("BitwiseOrSegment"))).to_matchable(),]).to_matchable(),]).config(|this| {
785                            this.bracket_type = "exclude";
786                            this.bracket_pairs_set = "bracket_pairs";
787                        }).to_matchable(),
788                        Bracketed::new(vec![
789                            one_of(vec![
790                                AnyNumberOf::new(vec![Ref::new("PatternOperatorGrammar").to_matchable(),]).to_matchable(),
791                                Delimited::new(
792                                    vec![
793                                        Ref::new("PatternOperatorGrammar").to_matchable(),]
794                                )
795                                .config(|this|this.delimiter(Ref::new("BitwiseOrSegment"))).to_matchable(),]).to_matchable(),]).to_matchable(),
796                        Sequence::new(vec![
797                            Ref::keyword("PERMUTE").to_matchable(),
798                            Bracketed::new(vec![Delimited::new(
799                                vec![
800                                    Ref::new("PatternSymbolGrammar").to_matchable(),]
801                            ).to_matchable(),]).to_matchable(),]).to_matchable(),]).to_matchable(),
802                    Ref::new("PatternQuantifierGrammar").optional().to_matchable()
803                ]).config(|this| {
804                    this.allow_gaps = false;
805                }).to_matchable(),]).to_matchable().into()
806        ),
807        (
808            "ContextHeadersGrammar".into(),
809            one_of(vec![
810                Ref::keyword("CURRENT_ACCOUNT").to_matchable(),
811                Ref::keyword("CURRENT_CLIENT").to_matchable(),
812                Ref::keyword("CURRENT_DATABASE").to_matchable(),
813                Ref::keyword("CURRENT_DATE").to_matchable(),
814                Ref::keyword("CURRENT_IP_ADDRESS").to_matchable(),
815                Ref::keyword("CURRENT_REGION").to_matchable(),
816                Ref::keyword("CURRENT_ROLE").to_matchable(),
817                Ref::keyword("CURRENT_SCHEMA").to_matchable(),
818                Ref::keyword("CURRENT_SCHEMAS").to_matchable(),
819                Ref::keyword("CURRENT_SESSION").to_matchable(),
820                Ref::keyword("CURRENT_STATEMENT").to_matchable(),
821                Ref::keyword("CURRENT_TIME").to_matchable(),
822                Ref::keyword("CURRENT_TIMESTAMP").to_matchable(),
823                Ref::keyword("CURRENT_TRANSACTION").to_matchable(),
824                Ref::keyword("CURRENT_USER").to_matchable(),
825                Ref::keyword("CURRENT_VERSION").to_matchable(),
826                Ref::keyword("CURRENT_WAREHOUSE").to_matchable(),
827                Ref::keyword("LAST_QUERY_ID").to_matchable(),
828                Ref::keyword("LAST_TRANSACTION").to_matchable(),
829                Ref::keyword("LOCALTIME").to_matchable(),
830                Ref::keyword("LOCALTIMESTAMP").to_matchable(),]).to_matchable().into()
831        )
832    ]);
833
834    snowflake_dialect.add([
835        (
836            "NakedIdentifierSegment".into(),
837            SegmentGenerator::new(|dialect| {
838                // Generate the anti template from the set of reserved keywords
839                let reserved_keywords = dialect.sets("reserved_keywords");
840                let pattern = reserved_keywords.iter().join("|");
841                let anti_template = format!("^({pattern})$");
842
843                RegexParser::new("[a-zA-Z_][a-zA-Z0-9_$]*", SyntaxKind::NakedIdentifier)
844                    .anti_template(&anti_template)
845                    .to_matchable()
846            })
847            .into(),
848        ),
849        (
850            "LiteralGrammar".into(),
851            snowflake_dialect
852                .grammar("LiteralGrammar")
853                .copy(
854                    Some(vec![
855                        Ref::new("ReferencedVariableNameSegment").to_matchable(),
856                    ]),
857                    None,
858                    None,
859                    None,
860                    Vec::new(),
861                    false,
862                )
863                .into(),
864        ),
865        (
866            "AccessorGrammar".into(),
867            AnyNumberOf::new(vec![
868                Ref::new("ArrayAccessorSegment").to_matchable(),
869                Ref::new("SemiStructuredAccessorSegment").to_matchable(),
870            ])
871            .to_matchable()
872            .into(),
873        ),
874        (
875            "PreTableFunctionKeywordsGrammar".into(),
876            one_of(vec![Ref::keyword("LATERAL").to_matchable()])
877                .to_matchable()
878                .into(),
879        ),
880        (
881            "FunctionContentsExpressionGrammar".into(),
882            one_of(vec![
883                Ref::new("DatetimeUnitSegment").to_matchable(),
884                Ref::new("NamedParameterExpressionSegment").to_matchable(),
885                Ref::new("ReferencedVariableNameSegment").to_matchable(),
886                Sequence::new(vec![
887                    Ref::new("ExpressionSegment").to_matchable(),
888                    Sequence::new(vec![
889                        one_of(vec![
890                            Ref::keyword("IGNORE").to_matchable(),
891                            Ref::keyword("RESPECT").to_matchable(),
892                        ])
893                        .to_matchable(),
894                        Ref::keyword("NULLS").to_matchable(),
895                    ])
896                    .config(|this| this.optional())
897                    .to_matchable(),
898                ])
899                .to_matchable(),
900            ])
901            .to_matchable()
902            .into(),
903        ),
904        (
905            "JoinLikeClauseGrammar".into(),
906            Sequence::new(vec![
907                any_set_of(vec![
908                    Ref::new("MatchRecognizeClauseSegment").to_matchable(),
909                    Ref::new("ChangesClauseSegment").to_matchable(),
910                    Ref::new("ConnectByClauseSegment").to_matchable(),
911                    Ref::new("FromBeforeExpressionSegment").to_matchable(),
912                    Ref::new("FromPivotExpressionSegment").to_matchable(),
913                    AnyNumberOf::new(vec![
914                        Ref::new("FromUnpivotExpressionSegment").to_matchable(),
915                    ])
916                    .to_matchable(),
917                    Ref::new("SamplingExpressionSegment").to_matchable(),
918                ])
919                .config(|this| this.min_times = 1)
920                .to_matchable(),
921                Ref::new("AliasExpressionSegment").optional().to_matchable(),
922            ])
923            .to_matchable()
924            .into(),
925        ),
926        (
927            "SingleIdentifierGrammar".into(),
928            one_of(vec![
929                Ref::new("NakedIdentifierSegment").to_matchable(),
930                Ref::new("QuotedIdentifierSegment").to_matchable(),
931                Ref::new("ColumnIndexIdentifierSegment").to_matchable(),
932                Ref::new("ReferencedVariableNameSegment").to_matchable(),
933                Ref::new("StagePath").to_matchable(),
934                Sequence::new(vec![
935                    Ref::keyword("IDENTIFIER").to_matchable(),
936                    Bracketed::new(vec![
937                        one_of(vec![
938                            Ref::new("SingleQuotedIdentifierSegment").to_matchable(),
939                            Ref::new("ReferencedVariableNameSegment").to_matchable(),
940                        ])
941                        .to_matchable(),
942                    ])
943                    .to_matchable(),
944                ])
945                .to_matchable(),
946            ])
947            .to_matchable()
948            .into(),
949        ),
950        (
951            "PostFunctionGrammar".into(),
952            Sequence::new(vec![
953                Ref::new("WithinGroupClauseSegment")
954                    .optional()
955                    .to_matchable(),
956                Sequence::new(vec![
957                    one_of(vec![
958                        Ref::keyword("IGNORE").to_matchable(),
959                        Ref::keyword("RESPECT").to_matchable(),
960                    ])
961                    .to_matchable(),
962                    Ref::keyword("NULLS").to_matchable(),
963                ])
964                .config(|this| this.optional())
965                .to_matchable(),
966                Ref::new("OverClauseSegment").optional().to_matchable(),
967            ])
968            .to_matchable()
969            .into(),
970        ),
971        (
972            "TemporaryGrammar".into(),
973            Sequence::new(vec![
974                one_of(vec![
975                    Ref::keyword("LOCAL").to_matchable(),
976                    Ref::keyword("GLOBAL").to_matchable(),
977                ])
978                .config(|this| this.optional())
979                .to_matchable(),
980                one_of(vec![
981                    Ref::keyword("TEMP").to_matchable(),
982                    Ref::keyword("TEMPORARY").to_matchable(),
983                ])
984                .config(|this| this.optional())
985                .to_matchable(),
986                Sequence::new(vec![Ref::keyword("VOLATILE").to_matchable()])
987                    .config(|this| this.optional())
988                    .to_matchable(),
989            ])
990            .config(|this| this.optional())
991            .to_matchable()
992            .into(),
993        ),
994        (
995            "TemporaryTransientGrammar".into(),
996            one_of(vec![
997                Ref::new("TemporaryGrammar").to_matchable(),
998                Ref::keyword("TRANSIENT").to_matchable(),
999            ])
1000            .to_matchable()
1001            .into(),
1002        ),
1003        (
1004            "BaseExpressionElementGrammar".into(),
1005            snowflake_dialect
1006                .grammar("BaseExpressionElementGrammar")
1007                .copy(
1008                    Some(vec![
1009                        Sequence::new(vec![
1010                            Ref::keyword("CONNECT_BY_ROOT").to_matchable(),
1011                            Ref::new("ColumnReferenceSegment").to_matchable(),
1012                        ])
1013                        .to_matchable(),
1014                    ]),
1015                    None,
1016                    Some(Ref::new("LiteralGrammar").to_matchable()),
1017                    None,
1018                    Vec::new(),
1019                    false,
1020                )
1021                .into(),
1022        ),
1023        (
1024            "QuotedLiteralSegment".into(),
1025            one_of(vec![
1026                TypedParser::new(SyntaxKind::SingleQuote, SyntaxKind::QuotedLiteral).to_matchable(),
1027                TypedParser::new(SyntaxKind::DollarQuote, SyntaxKind::QuotedLiteral).to_matchable(),
1028            ])
1029            .to_matchable()
1030            .into(),
1031        ),
1032        (
1033            "LikeGrammar".into(),
1034            one_of(vec![
1035                Sequence::new(vec![
1036                    Ref::keyword("LIKE").to_matchable(),
1037                    one_of(vec![
1038                        Ref::keyword("ALL").to_matchable(),
1039                        Ref::keyword("ANY").to_matchable(),
1040                    ])
1041                    .config(|this| this.optional())
1042                    .to_matchable(),
1043                ])
1044                .to_matchable(),
1045                Ref::keyword("RLIKE").to_matchable(),
1046                Sequence::new(vec![
1047                    Ref::keyword("ILIKE").to_matchable(),
1048                    Ref::keyword("ANY").optional().to_matchable(),
1049                ])
1050                .to_matchable(),
1051                Ref::keyword("REGEXP").to_matchable(),
1052            ])
1053            .to_matchable()
1054            .into(),
1055        ),
1056        (
1057            "SelectClauseTerminatorGrammar".into(),
1058            one_of(vec![
1059                Ref::keyword("FROM").to_matchable(),
1060                Ref::keyword("WHERE").to_matchable(),
1061                Sequence::new(vec![
1062                    Ref::keyword("ORDER").to_matchable(),
1063                    Ref::keyword("BY").to_matchable(),
1064                ])
1065                .to_matchable(),
1066                Ref::keyword("LIMIT").to_matchable(),
1067                Ref::keyword("FETCH").to_matchable(),
1068                Ref::keyword("OFFSET").to_matchable(),
1069                Ref::new("SetOperatorSegment").to_matchable(),
1070            ])
1071            .to_matchable()
1072            .into(),
1073        ),
1074        (
1075            "FromClauseTerminatorGrammar".into(),
1076            one_of(vec![
1077                Ref::keyword("WHERE").to_matchable(),
1078                Ref::keyword("LIMIT").to_matchable(),
1079                Ref::keyword("FETCH").to_matchable(),
1080                Ref::keyword("OFFSET").to_matchable(),
1081                Sequence::new(vec![
1082                    Ref::keyword("GROUP").to_matchable(),
1083                    Ref::keyword("BY").to_matchable(),
1084                ])
1085                .to_matchable(),
1086                Sequence::new(vec![
1087                    Ref::keyword("ORDER").to_matchable(),
1088                    Ref::keyword("BY").to_matchable(),
1089                ])
1090                .to_matchable(),
1091                Ref::keyword("HAVING").to_matchable(),
1092                Ref::keyword("QUALIFY").to_matchable(),
1093                Ref::keyword("WINDOW").to_matchable(),
1094                Ref::new("SetOperatorSegment").to_matchable(),
1095                Ref::new("WithNoSchemaBindingClauseSegment").to_matchable(),
1096                Ref::new("WithDataClauseSegment").to_matchable(),
1097            ])
1098            .to_matchable()
1099            .into(),
1100        ),
1101        (
1102            "WhereClauseTerminatorGrammar".into(),
1103            one_of(vec![
1104                Ref::keyword("LIMIT").to_matchable(),
1105                Ref::keyword("FETCH").to_matchable(),
1106                Ref::keyword("OFFSET").to_matchable(),
1107                Sequence::new(vec![
1108                    Ref::keyword("GROUP").to_matchable(),
1109                    Ref::keyword("BY").to_matchable(),
1110                ])
1111                .to_matchable(),
1112                Sequence::new(vec![
1113                    Ref::keyword("ORDER").to_matchable(),
1114                    Ref::keyword("BY").to_matchable(),
1115                ])
1116                .to_matchable(),
1117                Ref::keyword("HAVING").to_matchable(),
1118                Ref::keyword("QUALIFY").to_matchable(),
1119                Ref::keyword("WINDOW").to_matchable(),
1120                Ref::keyword("OVERLAPS").to_matchable(),
1121            ])
1122            .to_matchable()
1123            .into(),
1124        ),
1125        (
1126            "OrderByClauseTerminators".into(),
1127            one_of(vec![
1128                Ref::keyword("LIMIT").to_matchable(),
1129                Ref::keyword("HAVING").to_matchable(),
1130                Ref::keyword("QUALIFY").to_matchable(),
1131                Ref::keyword("WINDOW").to_matchable(),
1132                Ref::new("FrameClauseUnitGrammar").to_matchable(),
1133                Ref::keyword("SEPARATOR").to_matchable(),
1134                Ref::keyword("FETCH").to_matchable(),
1135                Ref::keyword("OFFSET").to_matchable(),
1136                Ref::keyword("MEASURES").to_matchable(),
1137            ])
1138            .to_matchable()
1139            .into(),
1140        ),
1141        (
1142            "TrimParametersGrammar".into(),
1143            Nothing::new().to_matchable().into(),
1144        ),
1145        (
1146            "GroupByClauseTerminatorGrammar".into(),
1147            one_of(vec![
1148                Ref::keyword("ORDER").to_matchable(),
1149                Ref::keyword("LIMIT").to_matchable(),
1150                Ref::keyword("FETCH").to_matchable(),
1151                Ref::keyword("OFFSET").to_matchable(),
1152                Ref::keyword("HAVING").to_matchable(),
1153                Ref::keyword("QUALIFY").to_matchable(),
1154                Ref::keyword("WINDOW").to_matchable(),
1155            ])
1156            .to_matchable()
1157            .into(),
1158        ),
1159        (
1160            "HavingClauseTerminatorGrammar".into(),
1161            one_of(vec![
1162                Sequence::new(vec![
1163                    Ref::keyword("ORDER").to_matchable(),
1164                    Ref::keyword("BY").to_matchable(),
1165                ])
1166                .to_matchable(),
1167                Ref::keyword("LIMIT").to_matchable(),
1168                Ref::keyword("QUALIFY").to_matchable(),
1169                Ref::keyword("WINDOW").to_matchable(),
1170                Ref::keyword("FETCH").to_matchable(),
1171                Ref::keyword("OFFSET").to_matchable(),
1172            ])
1173            .to_matchable()
1174            .into(),
1175        ),
1176    ]);
1177
1178    snowflake_dialect.sets_mut("unreserved_keywords").clear();
1179    snowflake_dialect.update_keywords_set_from_multiline_string(
1180        "unreserved_keywords",
1181        SNOWFLAKE_UNRESERVED_KEYWORDS,
1182    );
1183
1184    snowflake_dialect.sets_mut("reserved_keywords").clear();
1185    snowflake_dialect.update_keywords_set_from_multiline_string(
1186        "reserved_keywords",
1187        SNOWFLAKE_RESERVED_KEYWORDS,
1188    );
1189
1190    snowflake_dialect.sets_mut("datetime_units").clear();
1191    snowflake_dialect.sets_mut("datetime_units").extend([
1192        "YEAR",
1193        "Y",
1194        "YY",
1195        "YYY",
1196        "YYYY",
1197        "YR",
1198        "YEARS",
1199        "YRS",
1200        "MONTH",
1201        "MM",
1202        "MON",
1203        "MONS",
1204        "MONTHS",
1205        "DAY",
1206        "D",
1207        "DD",
1208        "DAYS",
1209        "DAYOFMONTH",
1210        "DAYOFWEEK",
1211        "WEEKDAY",
1212        "DOW",
1213        "DW",
1214        "DAYOFWEEKISO",
1215        "WEEKDAY_ISO",
1216        "DOW_ISO",
1217        "DW_ISO",
1218        "DAYOFYEAR",
1219        "YEARDAY",
1220        "DOY",
1221        "DY",
1222        "WEEK",
1223        "W",
1224        "WK",
1225        "WEEKOFYEAR",
1226        "WOY",
1227        "WY",
1228        "WEEKISO",
1229        "WEEK_ISO",
1230        "WEEKOFYEARISO",
1231        "WEEKOFYEAR_ISO",
1232        "QUARTER",
1233        "Q",
1234        "QTR",
1235        "QTRS",
1236        "QUARTERS",
1237        "YEAROFWEEK",
1238        "YEAROFWEEKISO",
1239        "HOUR",
1240        "H",
1241        "HH",
1242        "HR",
1243        "HOURS",
1244        "HRS",
1245        "MINUTE",
1246        "M",
1247        "MI",
1248        "MIN",
1249        "MINUTES",
1250        "MINS",
1251        "SECOND",
1252        "S",
1253        "SEC",
1254        "SECONDS",
1255        "SECS",
1256        "MILLISECOND",
1257        "MS",
1258        "MSEC",
1259        "MILLISECONDS",
1260        "MICROSECOND",
1261        "US",
1262        "USEC",
1263        "MICROSECONDS",
1264        "NANOSECOND",
1265        "NS",
1266        "NSEC",
1267        "NANOSEC",
1268        "NSECOND",
1269        "NANOSECONDS",
1270        "NANOSECS",
1271        "NSECONDS",
1272        "EPOCH_SECOND",
1273        "EPOCH",
1274        "EPOCH_SECONDS",
1275        "EPOCH_MILLISECOND",
1276        "EPOCH_MILLISECONDS",
1277        "EPOCH_MICROSECOND",
1278        "EPOCH_MICROSECONDS",
1279        "EPOCH_NANOSECOND",
1280        "EPOCH_NANOSECONDS",
1281        "TIMEZONE_HOUR",
1282        "TZH",
1283        "TIMEZONE_MINUTE",
1284        "TZM",
1285    ]);
1286
1287    snowflake_dialect.replace_grammar(
1288        "FunctionNameSegment",
1289        Sequence::new(vec![
1290            // Project name, schema identifier, etc.
1291            AnyNumberOf::new(vec![
1292                Sequence::new(vec![
1293                    Ref::new("SingleIdentifierGrammar").to_matchable(),
1294                    Ref::new("DotSegment").to_matchable(),
1295                ])
1296                .to_matchable(),
1297            ])
1298            .config(|this| {
1299                this.terminators = vec![Ref::new("BracketedSegment").to_matchable()];
1300            })
1301            .to_matchable(),
1302            // Base function name
1303            one_of(vec![
1304                Ref::new("FunctionNameIdentifierSegment").to_matchable(),
1305                Ref::new("QuotedIdentifierSegment").to_matchable(),
1306                // Snowflake's IDENTIFIER pseudo-function
1307                Sequence::new(vec![
1308                    Ref::keyword("IDENTIFIER").to_matchable(),
1309                    Bracketed::new(vec![
1310                        one_of(vec![
1311                            Ref::new("SingleQuotedIdentifierSegment").to_matchable(),
1312                            Ref::new("ReferencedVariableNameSegment").to_matchable(),
1313                        ])
1314                        .to_matchable(),
1315                    ])
1316                    .to_matchable(),
1317                ])
1318                .to_matchable(),
1319            ])
1320            .to_matchable(),
1321        ])
1322        .config(|this| {
1323            this.allow_gaps = false;
1324        })
1325        .to_matchable(),
1326    );
1327
1328    snowflake_dialect.add([(
1329        "ConnectByClauseSegment".into(),
1330        NodeMatcher::new(SyntaxKind::ConnectbyClause, |_| {
1331            Sequence::new(vec![
1332                Ref::keyword("START").to_matchable(),
1333                Ref::keyword("WITH").to_matchable(),
1334                Ref::new("ExpressionSegment").to_matchable(),
1335                Ref::keyword("CONNECT").to_matchable(),
1336                Ref::keyword("BY").to_matchable(),
1337                Delimited::new(vec![
1338                    Sequence::new(vec![
1339                        Ref::keyword("PRIOR").optional().to_matchable(),
1340                        Ref::new("ColumnReferenceSegment").to_matchable(),
1341                        Ref::new("EqualsSegment").to_matchable(),
1342                        Ref::keyword("PRIOR").optional().to_matchable(),
1343                        Ref::new("ColumnReferenceSegment").to_matchable(),
1344                    ])
1345                    .to_matchable(),
1346                ])
1347                .to_matchable(),
1348            ])
1349            .to_matchable()
1350        })
1351        .to_matchable()
1352        .into(),
1353    )]);
1354
1355    snowflake_dialect.replace_grammar(
1356        "GroupByClauseSegment",
1357        Sequence::new(vec![
1358            Ref::keyword("GROUP").to_matchable(),
1359            Ref::keyword("BY").to_matchable(),
1360            MetaSegment::indent().to_matchable(),
1361            one_of(vec![
1362                Sequence::new(vec![
1363                    one_of(vec![
1364                        Ref::keyword("CUBE").to_matchable(),
1365                        Ref::keyword("ROLLUP").to_matchable(),
1366                        Sequence::new(vec![
1367                            Ref::keyword("GROUPING").to_matchable(),
1368                            Ref::keyword("SETS").to_matchable(),
1369                        ])
1370                        .to_matchable(),
1371                    ])
1372                    .to_matchable(),
1373                    Bracketed::new(vec![Ref::new("GroupByContentsGrammar").to_matchable()])
1374                        .to_matchable(),
1375                ])
1376                .to_matchable(),
1377                Ref::keyword("ALL").to_matchable(),
1378                Ref::new("GroupByContentsGrammar").to_matchable(),
1379            ])
1380            .to_matchable(),
1381            MetaSegment::dedent().to_matchable(),
1382        ])
1383        .to_matchable(),
1384    );
1385
1386    snowflake_dialect.replace_grammar(
1387        "ValuesClauseSegment",
1388        Sequence::new(vec![
1389            Ref::keyword("VALUES").to_matchable(),
1390            Delimited::new(vec![
1391                Bracketed::new(vec![
1392                    Delimited::new(vec![
1393                        Ref::keyword("DEFAULT").to_matchable(),
1394                        Ref::keyword("NULL").to_matchable(),
1395                        Ref::new("ExpressionSegment").to_matchable(),
1396                    ])
1397                    .to_matchable(),
1398                ])
1399                .config(|this| {
1400                    this.parse_mode = ParseMode::Greedy;
1401                })
1402                .to_matchable(),
1403            ])
1404            .to_matchable(),
1405        ])
1406        .to_matchable(),
1407    );
1408
1409    snowflake_dialect.add([(
1410        "InsertStatementSegment".into(),
1411        NodeMatcher::new(SyntaxKind::InsertStatement, |_| {
1412            Sequence::new(vec![
1413                Ref::keyword("INSERT").to_matchable(),
1414                Ref::keyword("OVERWRITE").optional().to_matchable(),
1415                one_of(vec![
1416                    // Single table INSERT INTO
1417                    Sequence::new(vec![
1418                        Ref::keyword("INTO").to_matchable(),
1419                        Ref::new("TableReferenceSegment").to_matchable(),
1420                        Ref::new("BracketedColumnReferenceListGrammar")
1421                            .optional()
1422                            .to_matchable(),
1423                        Ref::new("SelectableGrammar").to_matchable(),
1424                    ])
1425                    .to_matchable(),
1426                    // Unconditional multi-table INSERT INTO
1427                    Sequence::new(vec![
1428                        Ref::keyword("ALL").to_matchable(),
1429                        AnyNumberOf::new(vec![
1430                            Sequence::new(vec![
1431                                Ref::keyword("INTO").to_matchable(),
1432                                Ref::new("TableReferenceSegment").to_matchable(),
1433                                Ref::new("BracketedColumnReferenceListGrammar")
1434                                    .optional()
1435                                    .to_matchable(),
1436                                Ref::new("ValuesClauseSegment").optional().to_matchable(),
1437                            ])
1438                            .to_matchable(),
1439                        ])
1440                        .config(|this| {
1441                            this.min_times = 1;
1442                        })
1443                        .to_matchable(),
1444                        Ref::new("SelectStatementSegment").to_matchable(),
1445                    ])
1446                    .to_matchable(),
1447                    // Conditional multi-table INSERT INTO
1448                    Sequence::new(vec![
1449                        one_of(vec![
1450                            Ref::keyword("FIRST").to_matchable(),
1451                            Ref::keyword("ALL").to_matchable(),
1452                        ])
1453                        .to_matchable(),
1454                        AnyNumberOf::new(vec![
1455                            Sequence::new(vec![
1456                                Ref::keyword("WHEN").to_matchable(),
1457                                Ref::new("ExpressionSegment").to_matchable(),
1458                                Ref::keyword("THEN").to_matchable(),
1459                                AnyNumberOf::new(vec![
1460                                    Sequence::new(vec![
1461                                        Ref::keyword("INTO").to_matchable(),
1462                                        Ref::new("TableReferenceSegment").to_matchable(),
1463                                        Ref::new("BracketedColumnReferenceListGrammar")
1464                                            .optional()
1465                                            .to_matchable(),
1466                                        Ref::new("ValuesClauseSegment").optional().to_matchable(),
1467                                    ])
1468                                    .to_matchable(),
1469                                ])
1470                                .config(|this| {
1471                                    this.min_times = 1;
1472                                })
1473                                .to_matchable(),
1474                            ])
1475                            .to_matchable(),
1476                        ])
1477                        .config(|this| {
1478                            this.min_times = 1;
1479                        })
1480                        .to_matchable(),
1481                        Sequence::new(vec![
1482                            Ref::keyword("ELSE").to_matchable(),
1483                            Ref::keyword("INTO").to_matchable(),
1484                            Ref::new("TableReferenceSegment").to_matchable(),
1485                            Ref::new("BracketedColumnReferenceListGrammar")
1486                                .optional()
1487                                .to_matchable(),
1488                            Ref::new("ValuesClauseSegment").optional().to_matchable(),
1489                        ])
1490                        .config(|this| this.optional())
1491                        .to_matchable(),
1492                        Ref::new("SelectStatementSegment").to_matchable(),
1493                    ])
1494                    .to_matchable(),
1495                ])
1496                .to_matchable(),
1497            ])
1498            .to_matchable()
1499        })
1500        .to_matchable()
1501        .into(),
1502    )]);
1503
1504    snowflake_dialect.replace_grammar(
1505        "FunctionDefinitionGrammar",
1506        Sequence::new(vec![
1507            Ref::keyword("AS").to_matchable(),
1508            Ref::new("QuotedLiteralSegment").to_matchable(),
1509            Sequence::new(vec![
1510                Ref::keyword("LANGUAGE").to_matchable(),
1511                Ref::new("NakedIdentifierSegment").to_matchable(),
1512            ])
1513            .config(|this| this.optional())
1514            .to_matchable(),
1515        ])
1516        .to_matchable(),
1517    );
1518
1519    snowflake_dialect.replace_grammar(
1520        "StatementSegment",
1521        ansi::statement_segment().copy(
1522            Some(vec![
1523                Ref::new("AccessStatementSegment").to_matchable(),
1524                Ref::new("CreateStatementSegment").to_matchable(),
1525                Ref::new("CreateTaskSegment").to_matchable(),
1526                Ref::new("CreateUserSegment").to_matchable(),
1527                Ref::new("CreateCloneStatementSegment").to_matchable(),
1528                Ref::new("CreateProcedureStatementSegment").to_matchable(),
1529                Ref::new("AlterProcedureStatementSegment").to_matchable(),
1530                Ref::new("ScriptingBlockStatementSegment").to_matchable(),
1531                Ref::new("ScriptingLetStatementSegment").to_matchable(),
1532                Ref::new("ReturnStatementSegment").to_matchable(),
1533                Ref::new("ShowStatementSegment").to_matchable(),
1534                Ref::new("AlterAccountStatementSegment").to_matchable(),
1535                Ref::new("AlterUserStatementSegment").to_matchable(),
1536                Ref::new("AlterSessionStatementSegment").to_matchable(),
1537                Ref::new("AlterTaskStatementSegment").to_matchable(),
1538                Ref::new("SetAssignmentStatementSegment").to_matchable(),
1539                Ref::new("CallStoredProcedureSegment").to_matchable(),
1540                Ref::new("MergeStatementSegment").to_matchable(),
1541                Ref::new("CopyIntoTableStatementSegment").to_matchable(),
1542                Ref::new("CopyIntoLocationStatementSegment").to_matchable(),
1543                Ref::new("FormatTypeOptions").to_matchable(),
1544                Ref::new("AlterWarehouseStatementSegment").to_matchable(),
1545                Ref::new("AlterShareStatementSegment").to_matchable(),
1546                Ref::new("CreateExternalTableSegment").to_matchable(),
1547                Ref::new("AlterExternalTableStatementSegment").to_matchable(),
1548                Ref::new("CreateSchemaStatementSegment").to_matchable(),
1549                Ref::new("AlterSchemaStatementSegment").to_matchable(),
1550                Ref::new("CreateFunctionStatementSegment").to_matchable(),
1551                Ref::new("AlterFunctionStatementSegment").to_matchable(),
1552                Ref::new("CreateExternalFunctionStatementSegment").to_matchable(),
1553                Ref::new("CreateStageSegment").to_matchable(),
1554                Ref::new("AlterStageSegment").to_matchable(),
1555                Ref::new("CreateStreamStatementSegment").to_matchable(),
1556                Ref::new("AlterStreamStatementSegment").to_matchable(),
1557                Ref::new("UnsetStatementSegment").to_matchable(),
1558                Ref::new("UndropStatementSegment").to_matchable(),
1559                Ref::new("CommentStatementSegment").to_matchable(),
1560                Ref::new("CallStatementSegment").to_matchable(),
1561                Ref::new("AlterViewStatementSegment").to_matchable(),
1562                Ref::new("AlterMaterializedViewStatementSegment").to_matchable(),
1563                Ref::new("DropProcedureStatementSegment").to_matchable(),
1564                Ref::new("DropExternalTableStatementSegment").to_matchable(),
1565                Ref::new("DropMaterializedViewStatementSegment").to_matchable(),
1566                Ref::new("DropObjectStatementSegment").to_matchable(),
1567                Ref::new("CreateFileFormatSegment").to_matchable(),
1568                Ref::new("AlterFileFormatSegment").to_matchable(),
1569                Ref::new("AlterPipeSegment").to_matchable(),
1570                Ref::new("ListStatementSegment").to_matchable(),
1571                Ref::new("GetStatementSegment").to_matchable(),
1572                Ref::new("PutStatementSegment").to_matchable(),
1573                Ref::new("RemoveStatementSegment").to_matchable(),
1574                Ref::new("CreateDatabaseFromShareStatementSegment").to_matchable(),
1575                Ref::new("AlterRoleStatementSegment").to_matchable(),
1576                Ref::new("AlterStorageIntegrationSegment").to_matchable(),
1577                Ref::new("ExecuteImmediateClauseSegment").to_matchable(),
1578                Ref::new("ExecuteTaskClauseSegment").to_matchable(),
1579                Ref::new("CreateSequenceStatementSegment").to_matchable(),
1580                Ref::new("AlterSequenceStatementSegment").to_matchable(),
1581                Ref::new("CreateResourceMonitorStatementSegment").to_matchable(),
1582                Ref::new("AlterResourceMonitorStatementSegment").to_matchable(),
1583                Ref::new("DropResourceMonitorStatementSegment").to_matchable(),
1584                Ref::new("AlterDatabaseSegment").to_matchable(),
1585                Ref::new("AlterMaskingPolicySegment").to_matchable(),
1586                Ref::new("AlterNetworkPolicyStatementSegment").to_matchable(),
1587            ]),
1588            None,
1589            None,
1590            Some(vec![
1591                Ref::new("CreateIndexStatementSegment").to_matchable(),
1592                Ref::new("DropIndexStatementSegment").to_matchable(),
1593            ]),
1594            Vec::new(),
1595            false,
1596        ),
1597    );
1598
1599    snowflake_dialect.add([
1600        (
1601            "SetAssignmentStatementSegment".into(),
1602            NodeMatcher::new(SyntaxKind::SetStatement, |_| {
1603                one_of(vec![
1604                    Sequence::new(vec![
1605                        Ref::keyword("SET").to_matchable(),
1606                        Ref::new("LocalVariableNameSegment").to_matchable(),
1607                        Ref::new("EqualsSegment").to_matchable(),
1608                        Ref::new("ExpressionSegment").to_matchable(),
1609                    ])
1610                    .to_matchable(),
1611                    Sequence::new(vec![
1612                        Ref::keyword("SET").to_matchable(),
1613                        Bracketed::new(vec![
1614                            Delimited::new(vec![
1615                                Ref::new("LocalVariableNameSegment").to_matchable(),
1616                            ])
1617                            .to_matchable(),
1618                        ])
1619                        .to_matchable(),
1620                        Ref::new("EqualsSegment").to_matchable(),
1621                        Bracketed::new(vec![
1622                            Delimited::new(vec![Ref::new("ExpressionSegment").to_matchable()])
1623                                .to_matchable(),
1624                        ])
1625                        .to_matchable(),
1626                    ])
1627                    .to_matchable(),
1628                ])
1629                .to_matchable()
1630            })
1631            .to_matchable()
1632            .into(),
1633        ),
1634        (
1635            "CallStoredProcedureSegment".into(),
1636            NodeMatcher::new(SyntaxKind::CallSegment, |_| {
1637                Sequence::new(vec![
1638                    Ref::keyword("CALL").to_matchable(),
1639                    Ref::new("FunctionSegment").to_matchable(),
1640                ])
1641                .to_matchable()
1642            })
1643            .to_matchable()
1644            .into(),
1645        ),
1646        (
1647            "WithinGroupClauseSegment".into(),
1648            NodeMatcher::new(SyntaxKind::WithingroupClause, |_| {
1649                Sequence::new(vec![
1650                    Ref::keyword("WITHIN").to_matchable(),
1651                    Ref::keyword("GROUP").to_matchable(),
1652                    Bracketed::new(vec![
1653                        Ref::new("OrderByClauseSegment").optional().to_matchable(),
1654                    ])
1655                    .config(|this| {
1656                        this.parse_mode = ParseMode::Greedy;
1657                    })
1658                    .to_matchable(),
1659                ])
1660                .to_matchable()
1661            })
1662            .to_matchable()
1663            .into(),
1664        ),
1665        (
1666            "PatternSegment".into(),
1667            NodeMatcher::new(SyntaxKind::PatternExpression, |_| {
1668                Sequence::new(vec![
1669                    Ref::new("CaretSegment").optional().to_matchable(),
1670                    one_of(vec![
1671                        AnyNumberOf::new(vec![Ref::new("PatternOperatorGrammar").to_matchable()])
1672                            .to_matchable(),
1673                        Delimited::new(vec![Ref::new("PatternOperatorGrammar").to_matchable()])
1674                            .config(|this| this.delimiter(Ref::new("BitwiseOrSegment")))
1675                            .to_matchable(),
1676                    ])
1677                    .to_matchable(),
1678                    Ref::new("DollarSegment").optional().to_matchable(),
1679                ])
1680                .to_matchable()
1681            })
1682            .to_matchable()
1683            .into(),
1684        ),
1685        (
1686            "MatchRecognizeClauseSegment".into(),
1687            NodeMatcher::new(SyntaxKind::MatchRecognizeClause, |_| {
1688                Sequence::new(vec![
1689                    Ref::keyword("MATCH_RECOGNIZE").to_matchable(),
1690                    Bracketed::new(vec![
1691                        Ref::new("PartitionClauseSegment").optional().to_matchable(),
1692                        Ref::new("OrderByClauseSegment").optional().to_matchable(),
1693                        Sequence::new(vec![
1694                            Ref::keyword("MEASURES").to_matchable(),
1695                            Delimited::new(vec![
1696                                Sequence::new(vec![
1697                                    one_of(vec![
1698                                        Ref::keyword("FINAL").to_matchable(),
1699                                        Ref::keyword("RUNNING").to_matchable(),
1700                                    ])
1701                                    .config(|this| this.optional())
1702                                    .to_matchable(),
1703                                    Ref::new("ExpressionSegment").to_matchable(),
1704                                    Ref::new("AliasExpressionSegment").to_matchable(),
1705                                ])
1706                                .to_matchable(),
1707                            ])
1708                            .to_matchable(),
1709                        ])
1710                        .config(|this| this.optional())
1711                        .to_matchable(),
1712                        one_of(vec![
1713                            Sequence::new(vec![
1714                                Ref::keyword("ONE").to_matchable(),
1715                                Ref::keyword("ROW").to_matchable(),
1716                                Ref::keyword("PER").to_matchable(),
1717                                Ref::keyword("MATCH").to_matchable(),
1718                            ])
1719                            .to_matchable(),
1720                            Sequence::new(vec![
1721                                Ref::keyword("ALL").to_matchable(),
1722                                Ref::keyword("ROWS").to_matchable(),
1723                                Ref::keyword("PER").to_matchable(),
1724                                Ref::keyword("MATCH").to_matchable(),
1725                                one_of(vec![
1726                                    Sequence::new(vec![
1727                                        Ref::keyword("SHOW").to_matchable(),
1728                                        Ref::keyword("EMPTY").to_matchable(),
1729                                        Ref::keyword("MATCHES").to_matchable(),
1730                                    ])
1731                                    .to_matchable(),
1732                                    Sequence::new(vec![
1733                                        Ref::keyword("OMIT").to_matchable(),
1734                                        Ref::keyword("EMPTY").to_matchable(),
1735                                        Ref::keyword("MATCHES").to_matchable(),
1736                                    ])
1737                                    .to_matchable(),
1738                                    Sequence::new(vec![
1739                                        Ref::keyword("WITH").to_matchable(),
1740                                        Ref::keyword("UNMATCHED").to_matchable(),
1741                                        Ref::keyword("ROWS").to_matchable(),
1742                                    ])
1743                                    .to_matchable(),
1744                                ])
1745                                .config(|this| this.optional())
1746                                .to_matchable(),
1747                            ])
1748                            .to_matchable(),
1749                        ])
1750                        .config(|this| this.optional())
1751                        .to_matchable(),
1752                        Sequence::new(vec![
1753                            Ref::keyword("AFTER").to_matchable(),
1754                            Ref::keyword("MATCH").to_matchable(),
1755                            Ref::keyword("SKIP").to_matchable(),
1756                            one_of(vec![
1757                                Sequence::new(vec![
1758                                    Ref::keyword("PAST").to_matchable(),
1759                                    Ref::keyword("LAST").to_matchable(),
1760                                    Ref::keyword("ROW").to_matchable(),
1761                                ])
1762                                .to_matchable(),
1763                                Sequence::new(vec![
1764                                    Ref::keyword("TO").to_matchable(),
1765                                    Ref::keyword("NEXT").to_matchable(),
1766                                    Ref::keyword("ROW").to_matchable(),
1767                                ])
1768                                .to_matchable(),
1769                                Sequence::new(vec![
1770                                    Ref::keyword("TO").to_matchable(),
1771                                    one_of(vec![
1772                                        Ref::keyword("FIRST").to_matchable(),
1773                                        Ref::keyword("LAST").to_matchable(),
1774                                    ])
1775                                    .config(|this| this.optional())
1776                                    .to_matchable(),
1777                                    Ref::new("SingleIdentifierGrammar").to_matchable(),
1778                                ])
1779                                .to_matchable(),
1780                            ])
1781                            .to_matchable(),
1782                        ])
1783                        .config(|this| this.optional())
1784                        .to_matchable(),
1785                        Ref::keyword("PATTERN").to_matchable(),
1786                        Bracketed::new(vec![Ref::new("PatternSegment").to_matchable()])
1787                            .to_matchable(),
1788                        Ref::keyword("DEFINE").to_matchable(),
1789                        Delimited::new(vec![
1790                            Sequence::new(vec![
1791                                Ref::new("SingleIdentifierGrammar").to_matchable(),
1792                                Ref::keyword("AS").to_matchable(),
1793                                Ref::new("ExpressionSegment").to_matchable(),
1794                            ])
1795                            .to_matchable(),
1796                        ])
1797                        .to_matchable(),
1798                    ])
1799                    .to_matchable(),
1800                ])
1801                .to_matchable()
1802            })
1803            .to_matchable()
1804            .into(),
1805        ),
1806        (
1807            "ChangesClauseSegment".into(),
1808            NodeMatcher::new(SyntaxKind::ChangesClause, |_| {
1809                Sequence::new(vec![
1810                    Ref::keyword("CHANGES").to_matchable(),
1811                    Bracketed::new(vec![
1812                        Ref::keyword("INFORMATION").to_matchable(),
1813                        Ref::new("ParameterAssignerSegment").to_matchable(),
1814                        one_of(vec![
1815                            Ref::keyword("DEFAULT").to_matchable(),
1816                            Ref::keyword("APPEND_ONLY").to_matchable(),
1817                        ])
1818                        .to_matchable(),
1819                    ])
1820                    .to_matchable(),
1821                    one_of(vec![
1822                        Sequence::new(vec![
1823                            Ref::keyword("AT").to_matchable(),
1824                            Bracketed::new(vec![
1825                                one_of(vec![
1826                                    Ref::keyword("TIMESTAMP").to_matchable(),
1827                                    Ref::keyword("OFFSET").to_matchable(),
1828                                    Ref::keyword("STATEMENT").to_matchable(),
1829                                ])
1830                                .to_matchable(),
1831                                Ref::new("ParameterAssignerSegment").to_matchable(),
1832                                Ref::new("ExpressionSegment").to_matchable(),
1833                            ])
1834                            .to_matchable(),
1835                        ])
1836                        .to_matchable(),
1837                        Sequence::new(vec![
1838                            Ref::keyword("BEFORE").to_matchable(),
1839                            Bracketed::new(vec![
1840                                Ref::keyword("STATEMENT").to_matchable(),
1841                                Ref::new("ParameterAssignerSegment").to_matchable(),
1842                                Ref::new("ExpressionSegment").to_matchable(),
1843                            ])
1844                            .to_matchable(),
1845                        ])
1846                        .to_matchable(),
1847                    ])
1848                    .to_matchable(),
1849                    Sequence::new(vec![
1850                        Ref::keyword("END").to_matchable(),
1851                        Bracketed::new(vec![
1852                            one_of(vec![
1853                                Ref::keyword("TIMESTAMP").to_matchable(),
1854                                Ref::keyword("OFFSET").to_matchable(),
1855                                Ref::keyword("STATEMENT").to_matchable(),
1856                            ])
1857                            .to_matchable(),
1858                            Ref::new("ParameterAssignerSegment").to_matchable(),
1859                            Ref::new("ExpressionSegment").to_matchable(),
1860                        ])
1861                        .to_matchable(),
1862                    ])
1863                    .config(|this| this.optional())
1864                    .to_matchable(),
1865                ])
1866                .to_matchable()
1867            })
1868            .to_matchable()
1869            .into(),
1870        ),
1871        (
1872            "MatchConditionSegment".into(),
1873            NodeMatcher::new(SyntaxKind::MatchConditionClause, |_| {
1874                Sequence::new(vec![
1875                    Ref::keyword("MATCH_CONDITION").to_matchable(),
1876                    Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
1877                        .to_matchable(),
1878                ])
1879                .to_matchable()
1880            })
1881            .to_matchable()
1882            .into(),
1883        ),
1884        (
1885            "FromAtExpressionSegment".into(),
1886            NodeMatcher::new(SyntaxKind::FromAtExpression, |_| {
1887                Sequence::new(vec![
1888                    Ref::keyword("AT").to_matchable(),
1889                    Bracketed::new(vec![
1890                        one_of(vec![
1891                            Ref::keyword("TIMESTAMP").to_matchable(),
1892                            Ref::keyword("OFFSET").to_matchable(),
1893                            Ref::keyword("STATEMENT").to_matchable(),
1894                        ])
1895                        .to_matchable(),
1896                        Ref::new("ParameterAssignerSegment").to_matchable(),
1897                        Ref::new("ExpressionSegment").to_matchable(),
1898                    ])
1899                    .to_matchable(),
1900                ])
1901                .to_matchable()
1902            })
1903            .to_matchable()
1904            .into(),
1905        ),
1906        (
1907            "FromBeforeExpressionSegment".into(),
1908            NodeMatcher::new(SyntaxKind::FromBeforeExpression, |_| {
1909                Sequence::new(vec![
1910                    Ref::keyword("BEFORE").to_matchable(),
1911                    Bracketed::new(vec![
1912                        one_of(vec![
1913                            Ref::keyword("TIMESTAMP").to_matchable(),
1914                            Ref::keyword("OFFSET").to_matchable(),
1915                            Ref::keyword("STATEMENT").to_matchable(),
1916                        ])
1917                        .to_matchable(),
1918                        Ref::new("ParameterAssignerSegment").to_matchable(),
1919                        Ref::new("ExpressionSegment").to_matchable(),
1920                    ])
1921                    .config(|this| {
1922                        this.parse_mode = ParseMode::Greedy;
1923                    })
1924                    .to_matchable(),
1925                ])
1926                .to_matchable()
1927            })
1928            .to_matchable()
1929            .into(),
1930        ),
1931        (
1932            "FromPivotExpressionSegment".into(),
1933            NodeMatcher::new(SyntaxKind::FromPivotExpression, |_| {
1934                Sequence::new(vec![
1935                    Ref::keyword("PIVOT").to_matchable(),
1936                    Bracketed::new(vec![
1937                        Ref::new("FunctionSegment").to_matchable(),
1938                        Ref::keyword("FOR").to_matchable(),
1939                        Ref::new("SingleIdentifierGrammar").to_matchable(),
1940                        Ref::keyword("IN").to_matchable(),
1941                        Bracketed::new(vec![
1942                            Delimited::new(vec![Ref::new("LiteralGrammar").to_matchable()])
1943                                .to_matchable(),
1944                        ])
1945                        .to_matchable(),
1946                    ])
1947                    .to_matchable(),
1948                ])
1949                .to_matchable()
1950            })
1951            .to_matchable()
1952            .into(),
1953        ),
1954        (
1955            "FromUnpivotExpressionSegment".into(),
1956            NodeMatcher::new(SyntaxKind::FromUnpivotExpression, |_| {
1957                Sequence::new(vec![
1958                    Ref::keyword("UNPIVOT").to_matchable(),
1959                    Bracketed::new(vec![
1960                        Ref::new("SingleIdentifierGrammar").to_matchable(),
1961                        Ref::keyword("FOR").to_matchable(),
1962                        Ref::new("SingleIdentifierGrammar").to_matchable(),
1963                        Ref::keyword("IN").to_matchable(),
1964                        Bracketed::new(vec![
1965                            Delimited::new(vec![
1966                                Ref::new("SingleIdentifierGrammar").to_matchable(),
1967                            ])
1968                            .to_matchable(),
1969                        ])
1970                        .to_matchable(),
1971                    ])
1972                    .to_matchable(),
1973                ])
1974                .to_matchable()
1975            })
1976            .to_matchable()
1977            .into(),
1978        ),
1979    ]);
1980
1981    snowflake_dialect.replace_grammar(
1982        "SamplingExpressionSegment",
1983        Sequence::new(vec![
1984            one_of(vec![
1985                Ref::keyword("SAMPLE").to_matchable(),
1986                Ref::keyword("TABLESAMPLE").to_matchable(),
1987            ])
1988            .to_matchable(),
1989            one_of(vec![
1990                Ref::keyword("BERNOULLI").to_matchable(),
1991                Ref::keyword("ROW").to_matchable(),
1992                Ref::keyword("SYSTEM").to_matchable(),
1993                Ref::keyword("BLOCK").to_matchable(),
1994            ])
1995            .config(|this| this.optional())
1996            .to_matchable(),
1997            Bracketed::new(vec![
1998                one_of(vec![
1999                    Ref::new("NumericLiteralSegment").to_matchable(),
2000                    Ref::new("ReferencedVariableNameSegment").to_matchable(),
2001                ])
2002                .to_matchable(),
2003                Ref::keyword("ROWS").optional().to_matchable(),
2004            ])
2005            .to_matchable(),
2006            Sequence::new(vec![
2007                one_of(vec![
2008                    Ref::keyword("REPEATABLE").to_matchable(),
2009                    Ref::keyword("SEED").to_matchable(),
2010                ])
2011                .to_matchable(),
2012                Bracketed::new(vec![Ref::new("NumericLiteralSegment").to_matchable()])
2013                    .to_matchable(),
2014            ])
2015            .config(|this| this.optional())
2016            .to_matchable(),
2017        ])
2018        .to_matchable(),
2019    );
2020
2021    snowflake_dialect.add([
2022        (
2023            "NamedParameterExpressionSegment".into(),
2024            NodeMatcher::new(SyntaxKind::SnowflakeKeywordExpression, |_| {
2025                Sequence::new(vec![
2026                    Ref::new("ParameterNameSegment").to_matchable(),
2027                    Ref::new("ParameterAssignerSegment").to_matchable(),
2028                    one_of(vec![
2029                        Ref::new("LiteralGrammar").to_matchable(),
2030                        Ref::new("ColumnReferenceSegment").to_matchable(),
2031                        Ref::new("ExpressionSegment").to_matchable(),
2032                    ])
2033                    .to_matchable(),
2034                ])
2035                .to_matchable()
2036            })
2037            .to_matchable()
2038            .into(),
2039        ),
2040        (
2041            "SemiStructuredAccessorSegment".into(),
2042            NodeMatcher::new(SyntaxKind::SemiStructuredExpression, |_| {
2043                Sequence::new(vec![
2044                    one_of(vec![
2045                        Ref::new("DotSegment").to_matchable(),
2046                        Ref::new("ColonSegment").to_matchable(),
2047                    ])
2048                    .to_matchable(),
2049                    one_of(vec![
2050                        Ref::new("NakedSemiStructuredElementSegment").to_matchable(),
2051                        Ref::new("QuotedSemiStructuredElementSegment").to_matchable(),
2052                    ])
2053                    .to_matchable(),
2054                    Ref::new("ArrayAccessorSegment").optional().to_matchable(),
2055                    AnyNumberOf::new(vec![
2056                        Sequence::new(vec![
2057                            one_of(vec![
2058                                Ref::new("DotSegment").to_matchable(),
2059                                Ref::new("ColonSegment").to_matchable(),
2060                            ])
2061                            .to_matchable(),
2062                            one_of(vec![
2063                                Ref::new("NakedSemiStructuredElementSegment").to_matchable(),
2064                                Ref::new("QuotedSemiStructuredElementSegment").to_matchable(),
2065                            ])
2066                            .to_matchable(),
2067                        ])
2068                        .config(|this| {
2069                            this.allow_gaps = true;
2070                        })
2071                        .to_matchable(),
2072                        Ref::new("ArrayAccessorSegment").optional().to_matchable(),
2073                    ])
2074                    .config(|this| {
2075                        this.allow_gaps = true;
2076                    })
2077                    .to_matchable(),
2078                ])
2079                .config(|this| {
2080                    this.allow_gaps = true;
2081                })
2082                .to_matchable()
2083            })
2084            .to_matchable()
2085            .into(),
2086        ),
2087        (
2088            "QualifyClauseSegment".into(),
2089            NodeMatcher::new(SyntaxKind::QualifyClause, |_| {
2090                Sequence::new(vec![
2091                    Ref::keyword("QUALIFY").to_matchable(),
2092                    MetaSegment::indent().to_matchable(),
2093                    one_of(vec![
2094                        Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
2095                            .to_matchable(),
2096                        Ref::new("ExpressionSegment").to_matchable(),
2097                    ])
2098                    .to_matchable(),
2099                    MetaSegment::dedent().to_matchable(),
2100                ])
2101                .to_matchable()
2102            })
2103            .to_matchable()
2104            .into(),
2105        ),
2106    ]);
2107
2108    snowflake_dialect.replace_grammar(
2109        "SelectStatementSegment",
2110        ansi::select_statement().copy(
2111            Some(vec![
2112                Ref::new("QualifyClauseSegment").optional().to_matchable(),
2113            ]),
2114            None,
2115            Some(Ref::new("OrderByClauseSegment").optional().to_matchable()),
2116            None,
2117            Vec::new(),
2118            false,
2119        ),
2120    );
2121
2122    snowflake_dialect.replace_grammar(
2123        "WildcardExpressionSegment",
2124        ansi::wildcard_expression_segment().copy(
2125            Some(vec![
2126                Ref::new("ExcludeClauseSegment").optional().to_matchable(),
2127                Ref::new("ReplaceClauseSegment").optional().to_matchable(),
2128                Ref::new("RenameClauseSegment").optional().to_matchable(),
2129            ]),
2130            None,
2131            None,
2132            None,
2133            Vec::new(),
2134            false,
2135        ),
2136    );
2137
2138    snowflake_dialect.add([
2139        (
2140            "ExcludeClauseSegment".into(),
2141            NodeMatcher::new(SyntaxKind::SelectExcludeClause, |_| {
2142                Sequence::new(vec![
2143                    Ref::keyword("EXCLUDE").to_matchable(),
2144                    one_of(vec![
2145                        Bracketed::new(vec![
2146                            Delimited::new(vec![
2147                                Ref::new("SingleIdentifierGrammar").to_matchable(),
2148                            ])
2149                            .to_matchable(),
2150                        ])
2151                        .to_matchable(),
2152                        Ref::new("SingleIdentifierGrammar").to_matchable(),
2153                    ])
2154                    .to_matchable(),
2155                ])
2156                .to_matchable()
2157            })
2158            .to_matchable()
2159            .into(),
2160        ),
2161        (
2162            "RenameClauseSegment".into(),
2163            NodeMatcher::new(SyntaxKind::SelectRenameClause, |_| {
2164                Sequence::new(vec![
2165                    Ref::keyword("RENAME").to_matchable(),
2166                    one_of(vec![
2167                        Sequence::new(vec![
2168                            Ref::new("SingleIdentifierGrammar").to_matchable(),
2169                            Ref::keyword("AS").to_matchable(),
2170                            Ref::new("SingleIdentifierGrammar").to_matchable(),
2171                        ])
2172                        .to_matchable(),
2173                        Bracketed::new(vec![
2174                            Delimited::new(vec![
2175                                Sequence::new(vec![
2176                                    Ref::new("SingleIdentifierGrammar").to_matchable(),
2177                                    Ref::keyword("AS").to_matchable(),
2178                                    Ref::new("SingleIdentifierGrammar").to_matchable(),
2179                                ])
2180                                .to_matchable(),
2181                            ])
2182                            .to_matchable(),
2183                        ])
2184                        .to_matchable(),
2185                    ])
2186                    .to_matchable(),
2187                ])
2188                .to_matchable()
2189            })
2190            .to_matchable()
2191            .into(),
2192        ),
2193        (
2194            "ReplaceClauseSegment".into(),
2195            NodeMatcher::new(SyntaxKind::SelectReplaceClause, |_| {
2196                Sequence::new(vec![
2197                    Ref::keyword("REPLACE").to_matchable(),
2198                    Bracketed::new(vec![
2199                        Delimited::new(vec![
2200                            Sequence::new(vec![
2201                                Ref::new("ExpressionSegment").to_matchable(),
2202                                Ref::keyword("AS").to_matchable(),
2203                                Ref::new("SingleIdentifierGrammar").to_matchable(),
2204                            ])
2205                            .to_matchable(),
2206                        ])
2207                        .to_matchable(),
2208                    ])
2209                    .to_matchable(),
2210                ])
2211                .to_matchable()
2212            })
2213            .to_matchable()
2214            .into(),
2215        ),
2216    ]);
2217
2218    snowflake_dialect.replace_grammar(
2219        "SelectClauseModifierSegment",
2220        Sequence::new(vec![
2221            one_of(vec![
2222                Ref::keyword("DISTINCT").to_matchable(),
2223                Ref::keyword("ALL").to_matchable(),
2224            ])
2225            .config(|this| this.optional())
2226            .to_matchable(),
2227            Sequence::new(vec![
2228                Ref::keyword("TOP").to_matchable(),
2229                Ref::new("NumericLiteralSegment").to_matchable(),
2230            ])
2231            .config(|this| this.optional())
2232            .to_matchable(),
2233        ])
2234        .to_matchable(),
2235    );
2236
2237    snowflake_dialect.replace_grammar(
2238        "AlterTableStatementSegment",
2239        Sequence::new(vec![
2240            Ref::keyword("ALTER").to_matchable(),
2241            Ref::keyword("TABLE").to_matchable(),
2242            Ref::new("IfExistsGrammar").optional().to_matchable(),
2243            Ref::new("TableReferenceSegment").to_matchable(),
2244            one_of(vec![
2245                // Rename
2246                Sequence::new(vec![
2247                    Ref::keyword("RENAME").to_matchable(),
2248                    Ref::keyword("TO").to_matchable(),
2249                    Ref::new("TableReferenceSegment").to_matchable(),
2250                ])
2251                .to_matchable(),
2252                // Swap With
2253                Sequence::new(vec![
2254                    Ref::keyword("SWAP").to_matchable(),
2255                    Ref::keyword("WITH").to_matchable(),
2256                    Ref::new("TableReferenceSegment").to_matchable(),
2257                ])
2258                .to_matchable(),
2259                // searchOptimizationAction
2260                Sequence::new(vec![
2261                    one_of(vec![
2262                        Ref::keyword("ADD").to_matchable(),
2263                        Ref::keyword("DROP").to_matchable(),
2264                    ])
2265                    .to_matchable(),
2266                    Ref::keyword("SEARCH").to_matchable(),
2267                    Ref::keyword("OPTIMIZATION").to_matchable(),
2268                ])
2269                .to_matchable(),
2270                Ref::new("AlterTableClusteringActionSegment").to_matchable(),
2271                Ref::new("AlterTableConstraintActionSegment").to_matchable(),
2272                // SET Table options
2273                Sequence::new(vec![
2274                    Ref::keyword("SET").to_matchable(),
2275                    one_of(vec![
2276                        Ref::new("ParameterNameSegment").to_matchable(),
2277                        Ref::keyword("COMMENT").to_matchable(),
2278                    ])
2279                    .to_matchable(),
2280                    Ref::new("EqualsSegment").optional().to_matchable(),
2281                    one_of(vec![
2282                        Ref::new("LiteralGrammar").to_matchable(),
2283                        Ref::new("NakedIdentifierSegment").to_matchable(),
2284                        Ref::new("QuotedLiteralSegment").to_matchable(),
2285                    ])
2286                    .to_matchable(),
2287                ])
2288                .to_matchable(),
2289                // Drop primary key
2290                Sequence::new(vec![
2291                    Ref::keyword("DROP").to_matchable(),
2292                    Ref::new("PrimaryKeyGrammar").to_matchable(),
2293                ])
2294                .to_matchable(),
2295                // Add primary key
2296                Sequence::new(vec![
2297                    Ref::keyword("ADD").to_matchable(),
2298                    Ref::new("PrimaryKeyGrammar").to_matchable(),
2299                    Bracketed::new(vec![
2300                        Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
2301                            .config(|this| this.optional())
2302                            .to_matchable(),
2303                    ])
2304                    .to_matchable(),
2305                ])
2306                .to_matchable(),
2307                Ref::new("AlterTableTableColumnActionSegment").to_matchable(),
2308            ])
2309            .to_matchable(),
2310        ])
2311        .to_matchable(),
2312    );
2313
2314    snowflake_dialect.add([
2315        (
2316            "AlterTableTableColumnActionSegment".into(),
2317            NodeMatcher::new(SyntaxKind::AlterTableTableColumnAction, |_| {
2318                one_of(vec![
2319                    // Add Column
2320                    Sequence::new(vec![
2321                        Ref::keyword("ADD").to_matchable(),
2322                        Ref::keyword("COLUMN").optional().to_matchable(),
2323                        Delimited::new(vec![
2324                            Sequence::new(vec![
2325                                Ref::new("ColumnReferenceSegment").to_matchable(),
2326                                Ref::new("DatatypeSegment").to_matchable(),
2327                                one_of(vec![
2328                                    // Default
2329                                    Sequence::new(vec![
2330                                        Ref::keyword("DEFAULT").to_matchable(),
2331                                        Ref::new("ExpressionSegment").to_matchable(),
2332                                    ])
2333                                    .to_matchable(),
2334                                    // Auto-increment/identity column
2335                                    Sequence::new(vec![
2336                                        one_of(vec![
2337                                            Ref::keyword("AUTOINCREMENT").to_matchable(),
2338                                            Ref::keyword("IDENTITY").to_matchable(),
2339                                        ])
2340                                        .to_matchable(),
2341                                        one_of(vec![
2342                                            // ( <start_num>, <step_num> )
2343                                            Bracketed::new(vec![
2344                                                Ref::new("NumericLiteralSegment").to_matchable(),
2345                                                Ref::new("CommaSegment").to_matchable(),
2346                                                Ref::new("NumericLiteralSegment").to_matchable(),
2347                                            ])
2348                                            .to_matchable(),
2349                                            // START <num> INCREMENT <num>
2350                                            Sequence::new(vec![
2351                                                Ref::keyword("START").to_matchable(),
2352                                                Ref::new("NumericLiteralSegment").to_matchable(),
2353                                                Ref::keyword("INCREMENT").to_matchable(),
2354                                                Ref::new("NumericLiteralSegment").to_matchable(),
2355                                            ])
2356                                            .to_matchable(),
2357                                        ])
2358                                        .config(|this| this.optional())
2359                                        .to_matchable(),
2360                                    ])
2361                                    .config(|this| this.optional())
2362                                    .to_matchable(),
2363                                ])
2364                                .config(|this| this.optional())
2365                                .to_matchable(),
2366                                // Masking Policy
2367                                Sequence::new(vec![
2368                                    Ref::keyword("WITH").optional().to_matchable(),
2369                                    Ref::keyword("MASKING").to_matchable(),
2370                                    Ref::keyword("POLICY").to_matchable(),
2371                                    Ref::new("FunctionNameSegment").to_matchable(),
2372                                    Sequence::new(vec![
2373                                        Ref::keyword("USING").to_matchable(),
2374                                        Bracketed::new(vec![
2375                                            Delimited::new(vec![
2376                                                one_of(vec![
2377                                                    Ref::new("ColumnReferenceSegment")
2378                                                        .to_matchable(),
2379                                                    Ref::new("ExpressionSegment").to_matchable(),
2380                                                ])
2381                                                .to_matchable(),
2382                                            ])
2383                                            .to_matchable(),
2384                                        ])
2385                                        .to_matchable(),
2386                                    ])
2387                                    .config(|this| this.optional())
2388                                    .to_matchable(),
2389                                ])
2390                                .config(|this| this.optional())
2391                                .to_matchable(),
2392                                Ref::new("CommentClauseSegment").optional().to_matchable(),
2393                            ])
2394                            .to_matchable(),
2395                        ])
2396                        .to_matchable(),
2397                    ])
2398                    .to_matchable(),
2399                    // Rename column
2400                    Sequence::new(vec![
2401                        Ref::keyword("RENAME").to_matchable(),
2402                        Ref::keyword("COLUMN").to_matchable(),
2403                        Ref::new("ColumnReferenceSegment").to_matchable(),
2404                        Ref::keyword("TO").to_matchable(),
2405                        Ref::new("ColumnReferenceSegment").to_matchable(),
2406                    ])
2407                    .to_matchable(),
2408                    // Alter/Modify column(s)
2409                    Sequence::new(vec![
2410                        one_of(vec![
2411                            Ref::keyword("ALTER").to_matchable(),
2412                            Ref::keyword("MODIFY").to_matchable(),
2413                        ])
2414                        .to_matchable(),
2415                        optionally_bracketed(vec![
2416                            Delimited::new(vec![
2417                                // Add things
2418                                Sequence::new(vec![
2419                                    Ref::keyword("COLUMN").optional().to_matchable(),
2420                                    Ref::new("ColumnReferenceSegment").to_matchable(),
2421                                    one_of(vec![
2422                                        Sequence::new(vec![
2423                                            Ref::keyword("DROP").to_matchable(),
2424                                            Ref::keyword("DEFAULT").to_matchable(),
2425                                        ])
2426                                        .to_matchable(),
2427                                        Sequence::new(vec![
2428                                            Ref::keyword("SET").to_matchable(),
2429                                            Ref::keyword("DEFAULT").to_matchable(),
2430                                            Ref::new("NakedIdentifierSegment").to_matchable(),
2431                                            Ref::new("DotSegment").to_matchable(),
2432                                            Ref::keyword("NEXTVAL").to_matchable(),
2433                                        ])
2434                                        .to_matchable(),
2435                                        Sequence::new(vec![
2436                                            one_of(vec![
2437                                                Ref::keyword("SET").to_matchable(),
2438                                                Ref::keyword("DROP").to_matchable(),
2439                                            ])
2440                                            .config(|this| this.optional())
2441                                            .to_matchable(),
2442                                            Ref::keyword("NOT").to_matchable(),
2443                                            Ref::keyword("NULL").to_matchable(),
2444                                        ])
2445                                        .to_matchable(),
2446                                        Sequence::new(vec![
2447                                            Sequence::new(vec![
2448                                                Sequence::new(vec![
2449                                                    Ref::keyword("SET").to_matchable(),
2450                                                    Ref::keyword("DATA").optional().to_matchable(),
2451                                                ])
2452                                                .to_matchable(),
2453                                                Ref::keyword("TYPE").optional().to_matchable(),
2454                                            ])
2455                                            .to_matchable(),
2456                                            Ref::new("DatatypeSegment").to_matchable(),
2457                                        ])
2458                                        .to_matchable(),
2459                                        Ref::new("CommentClauseSegment").to_matchable(),
2460                                    ])
2461                                    .to_matchable(),
2462                                ])
2463                                .to_matchable(),
2464                                Sequence::new(vec![
2465                                    Ref::keyword("COLUMN").to_matchable(),
2466                                    Ref::new("ColumnReferenceSegment").to_matchable(),
2467                                    Ref::keyword("SET").to_matchable(),
2468                                    Ref::keyword("MASKING").to_matchable(),
2469                                    Ref::keyword("POLICY").to_matchable(),
2470                                    Ref::new("FunctionNameSegment").to_matchable(),
2471                                    Sequence::new(vec![
2472                                        Ref::keyword("USING").to_matchable(),
2473                                        Bracketed::new(vec![
2474                                            Delimited::new(vec![
2475                                                one_of(vec![
2476                                                    Ref::new("ColumnReferenceSegment")
2477                                                        .to_matchable(),
2478                                                    Ref::new("ExpressionSegment").to_matchable(),
2479                                                ])
2480                                                .to_matchable(),
2481                                            ])
2482                                            .to_matchable(),
2483                                        ])
2484                                        .to_matchable(),
2485                                    ])
2486                                    .config(|this| this.optional())
2487                                    .to_matchable(),
2488                                ])
2489                                .to_matchable(),
2490                                Sequence::new(vec![
2491                                    Ref::keyword("COLUMN").to_matchable(),
2492                                    Ref::new("ColumnReferenceSegment").to_matchable(),
2493                                    Ref::keyword("UNSET").to_matchable(),
2494                                    Ref::keyword("MASKING").to_matchable(),
2495                                    Ref::keyword("POLICY").to_matchable(),
2496                                ])
2497                                .to_matchable(),
2498                                Sequence::new(vec![
2499                                    Ref::keyword("COLUMN").to_matchable(),
2500                                    Ref::new("ColumnReferenceSegment").to_matchable(),
2501                                    Ref::keyword("SET").to_matchable(),
2502                                    Ref::keyword("TAG").to_matchable(),
2503                                    Ref::new("TagReferenceSegment").to_matchable(),
2504                                    Ref::new("EqualsSegment").to_matchable(),
2505                                    Ref::new("QuotedLiteralSegment").to_matchable(),
2506                                ])
2507                                .to_matchable(),
2508                                Sequence::new(vec![
2509                                    Ref::keyword("COLUMN").to_matchable(),
2510                                    Ref::new("ColumnReferenceSegment").to_matchable(),
2511                                    Ref::keyword("UNSET").to_matchable(),
2512                                    Ref::keyword("TAG").to_matchable(),
2513                                    Ref::new("TagReferenceSegment").to_matchable(),
2514                                ])
2515                                .to_matchable(),
2516                            ])
2517                            .to_matchable(),
2518                        ])
2519                        .to_matchable(),
2520                    ])
2521                    .to_matchable(),
2522                    // Drop column
2523                    Sequence::new(vec![
2524                        Ref::keyword("DROP").to_matchable(),
2525                        Ref::keyword("COLUMN").optional().to_matchable(),
2526                        Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
2527                            .to_matchable(),
2528                    ])
2529                    .to_matchable(),
2530                    // Add or Modify column
2531                    Sequence::new(vec![
2532                        one_of(vec![
2533                            Ref::keyword("ADD").to_matchable(),
2534                            Ref::keyword("MODIFY").to_matchable(),
2535                        ])
2536                        .to_matchable(),
2537                        Ref::keyword("COLUMN").optional().to_matchable(),
2538                        Ref::new("ColumnDefinitionSegment").to_matchable(),
2539                        one_of(vec![
2540                            Sequence::new(vec![
2541                                one_of(vec![
2542                                    Ref::keyword("FIRST").to_matchable(),
2543                                    Ref::keyword("AFTER").to_matchable(),
2544                                ])
2545                                .to_matchable(),
2546                                Ref::new("ColumnReferenceSegment").to_matchable(),
2547                            ])
2548                            .to_matchable(),
2549                            // Bracketed Version of the same
2550                            Ref::new("BracketedColumnReferenceListGrammar").to_matchable(),
2551                        ])
2552                        .config(|this| this.optional())
2553                        .to_matchable(),
2554                    ])
2555                    .to_matchable(),
2556                ])
2557                .to_matchable()
2558            })
2559            .to_matchable()
2560            .into(),
2561        ),
2562        (
2563            "AlterTableClusteringActionSegment".into(),
2564            NodeMatcher::new(SyntaxKind::AlterTableClusteringAction, |_| {
2565                one_of(vec![
2566                    Sequence::new(vec![
2567                        Ref::keyword("CLUSTER").to_matchable(),
2568                        Ref::keyword("BY").to_matchable(),
2569                        one_of(vec![
2570                            Ref::new("FunctionSegment").to_matchable(),
2571                            Bracketed::new(vec![
2572                                Delimited::new(vec![Ref::new("ExpressionSegment").to_matchable()])
2573                                    .to_matchable(),
2574                            ])
2575                            .to_matchable(),
2576                        ])
2577                        .to_matchable(),
2578                    ])
2579                    .to_matchable(),
2580                    Sequence::new(vec![
2581                        Ref::keyword("RECLUSTER").to_matchable(),
2582                        Sequence::new(vec![
2583                            Ref::keyword("MAX_SIZE").to_matchable(),
2584                            Ref::new("EqualsSegment").to_matchable(),
2585                            Ref::new("NumericLiteralSegment").to_matchable(),
2586                        ])
2587                        .config(|this| this.optional())
2588                        .to_matchable(),
2589                        Ref::new("WhereClauseSegment").optional().to_matchable(),
2590                    ])
2591                    .to_matchable(),
2592                    Sequence::new(vec![
2593                        one_of(vec![
2594                            Ref::keyword("SUSPEND").to_matchable(),
2595                            Ref::keyword("RESUME").to_matchable(),
2596                        ])
2597                        .to_matchable(),
2598                        Ref::keyword("RECLUSTER").to_matchable(),
2599                    ])
2600                    .to_matchable(),
2601                    Sequence::new(vec![
2602                        Ref::keyword("DROP").to_matchable(),
2603                        Ref::keyword("CLUSTERING").to_matchable(),
2604                        Ref::keyword("KEY").to_matchable(),
2605                    ])
2606                    .to_matchable(),
2607                ])
2608                .to_matchable()
2609            })
2610            .to_matchable()
2611            .into(),
2612        ),
2613        (
2614            "AlterTableConstraintActionSegment".into(),
2615            NodeMatcher::new(SyntaxKind::AlterTableConstraintAction, |_| {
2616                one_of(vec![
2617                    // Add Column
2618                    Sequence::new(vec![
2619                        Ref::keyword("ADD").to_matchable(),
2620                        Sequence::new(vec![
2621                            Ref::keyword("CONSTRAINT").to_matchable(),
2622                            one_of(vec![
2623                                Ref::new("NakedIdentifierSegment").to_matchable(),
2624                                Ref::new("QuotedIdentifierSegment").to_matchable(),
2625                            ])
2626                            .config(|this| this.optional())
2627                            .to_matchable(),
2628                        ])
2629                        .to_matchable(),
2630                        one_of(vec![
2631                            Sequence::new(vec![
2632                                Ref::new("PrimaryKeyGrammar").to_matchable(),
2633                                Bracketed::new(vec![
2634                                    Delimited::new(vec![
2635                                        Ref::new("ColumnReferenceSegment").to_matchable(),
2636                                    ])
2637                                    .to_matchable(),
2638                                ])
2639                                .to_matchable(),
2640                            ])
2641                            .to_matchable(),
2642                            Sequence::new(vec![
2643                                Sequence::new(vec![
2644                                    Ref::new("ForeignKeyGrammar").to_matchable(),
2645                                    Bracketed::new(vec![
2646                                        Delimited::new(vec![
2647                                            Ref::new("ColumnReferenceSegment").to_matchable(),
2648                                        ])
2649                                        .to_matchable(),
2650                                    ])
2651                                    .to_matchable(),
2652                                ])
2653                                .to_matchable(),
2654                                Ref::keyword("REFERENCES").to_matchable(),
2655                                Ref::new("TableReferenceSegment").to_matchable(),
2656                                Bracketed::new(vec![
2657                                    Delimited::new(vec![
2658                                        Ref::new("ColumnReferenceSegment").to_matchable(),
2659                                    ])
2660                                    .to_matchable(),
2661                                ])
2662                                .config(|this| this.optional())
2663                                .to_matchable(),
2664                            ])
2665                            .to_matchable(),
2666                            Sequence::new(vec![
2667                                Ref::keyword("UNIQUE").to_matchable(),
2668                                Bracketed::new(vec![
2669                                    Ref::new("ColumnReferenceSegment").to_matchable(),
2670                                ])
2671                                .config(|this| this.optional())
2672                                .to_matchable(),
2673                            ])
2674                            .to_matchable(),
2675                        ])
2676                        .to_matchable(),
2677                    ])
2678                    .to_matchable(),
2679                    Sequence::new(vec![
2680                        Ref::keyword("DROP").to_matchable(),
2681                        Sequence::new(vec![
2682                            Ref::keyword("CONSTRAINT").to_matchable(),
2683                            Ref::new("NakedIdentifierSegment").to_matchable(),
2684                        ])
2685                        .config(|this| this.optional())
2686                        .to_matchable(),
2687                        one_of(vec![
2688                            Ref::new("PrimaryKeyGrammar").to_matchable(),
2689                            Ref::new("ForeignKeyGrammar").to_matchable(),
2690                            Ref::keyword("UNIQUE").to_matchable(),
2691                        ])
2692                        .to_matchable(),
2693                        Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
2694                            .to_matchable(),
2695                    ])
2696                    .to_matchable(),
2697                    Sequence::new(vec![
2698                        Ref::keyword("RENAME").to_matchable(),
2699                        Ref::keyword("CONSTRAINT").to_matchable(),
2700                        Ref::new("NakedIdentifierSegment").to_matchable(),
2701                        Ref::keyword("TO").to_matchable(),
2702                        Ref::new("NakedIdentifierSegment").to_matchable(),
2703                    ])
2704                    .to_matchable(),
2705                ])
2706                .to_matchable()
2707            })
2708            .to_matchable()
2709            .into(),
2710        ),
2711        (
2712            "AlterWarehouseStatementSegment".into(),
2713            NodeMatcher::new(SyntaxKind::AlterWarehouseStatement, |_| {
2714                Sequence::new(vec![
2715                    Ref::keyword("ALTER").to_matchable(),
2716                    Ref::keyword("WAREHOUSE").to_matchable(),
2717                    Sequence::new(vec![
2718                        Ref::keyword("IF").to_matchable(),
2719                        Ref::keyword("EXISTS").to_matchable(),
2720                    ])
2721                    .config(|this| this.optional())
2722                    .to_matchable(),
2723                    one_of(vec![
2724                        Sequence::new(vec![
2725                            Ref::new("ObjectReferenceSegment").optional().to_matchable(),
2726                            one_of(vec![
2727                                Ref::keyword("SUSPEND").to_matchable(),
2728                                Sequence::new(vec![
2729                                    Ref::keyword("RESUME").to_matchable(),
2730                                    Sequence::new(vec![
2731                                        Ref::keyword("IF").to_matchable(),
2732                                        Ref::keyword("SUSPENDED").to_matchable(),
2733                                    ])
2734                                    .config(|this| this.optional())
2735                                    .to_matchable(),
2736                                ])
2737                                .to_matchable(),
2738                            ])
2739                            .to_matchable(),
2740                        ])
2741                        .to_matchable(),
2742                        Sequence::new(vec![
2743                            Ref::new("ObjectReferenceSegment").optional().to_matchable(),
2744                            Sequence::new(vec![
2745                                Ref::keyword("ABORT").to_matchable(),
2746                                Ref::keyword("ALL").to_matchable(),
2747                                Ref::keyword("QUERIES").to_matchable(),
2748                            ])
2749                            .to_matchable(),
2750                        ])
2751                        .to_matchable(),
2752                        Sequence::new(vec![
2753                            Ref::new("ObjectReferenceSegment").to_matchable(),
2754                            Ref::keyword("RENAME").to_matchable(),
2755                            Ref::keyword("TO").to_matchable(),
2756                            Ref::new("ObjectReferenceSegment").to_matchable(),
2757                        ])
2758                        .to_matchable(),
2759                        Sequence::new(vec![
2760                            Ref::new("ObjectReferenceSegment").optional().to_matchable(),
2761                            Ref::keyword("SET").to_matchable(),
2762                            one_of(vec![
2763                                AnyNumberOf::new(vec![
2764                                    Ref::new("CommaSegment").optional().to_matchable(),
2765                                    Ref::new("WarehouseObjectPropertiesSegment").to_matchable(),
2766                                    Ref::new("CommentEqualsClauseSegment").to_matchable(),
2767                                    Ref::new("WarehouseObjectParamsSegment").to_matchable(),
2768                                ])
2769                                .to_matchable(),
2770                                Ref::new("TagEqualsSegment").to_matchable(),
2771                            ])
2772                            .to_matchable(),
2773                        ])
2774                        .to_matchable(),
2775                        Sequence::new(vec![
2776                            Ref::new("ObjectReferenceSegment").to_matchable(),
2777                            Ref::keyword("UNSET").to_matchable(),
2778                            one_of(vec![
2779                                Delimited::new(vec![
2780                                    Ref::new("NakedIdentifierSegment").to_matchable(),
2781                                ])
2782                                .to_matchable(),
2783                                Sequence::new(vec![
2784                                    Ref::keyword("TAG").to_matchable(),
2785                                    Delimited::new(vec![
2786                                        Ref::new("TagReferenceSegment").to_matchable(),
2787                                    ])
2788                                    .to_matchable(),
2789                                ])
2790                                .to_matchable(),
2791                            ])
2792                            .to_matchable(),
2793                        ])
2794                        .to_matchable(),
2795                    ])
2796                    .to_matchable(),
2797                ])
2798                .to_matchable()
2799            })
2800            .to_matchable()
2801            .into(),
2802        ),
2803        (
2804            "AlterShareStatementSegment".into(),
2805            NodeMatcher::new(SyntaxKind::AlterShareStatement, |_| {
2806                Sequence::new(vec![
2807                    Ref::keyword("ALTER").to_matchable(),
2808                    Ref::keyword("SHARE").to_matchable(),
2809                    Sequence::new(vec![
2810                        Ref::keyword("IF").to_matchable(),
2811                        Ref::keyword("EXISTS").to_matchable(),
2812                    ])
2813                    .config(|this| this.optional())
2814                    .to_matchable(),
2815                    Ref::new("NakedIdentifierSegment").to_matchable(),
2816                    one_of(vec![
2817                        Sequence::new(vec![
2818                            one_of(vec![
2819                                Ref::keyword("ADD").to_matchable(),
2820                                Ref::keyword("REMOVE").to_matchable(),
2821                            ])
2822                            .to_matchable(),
2823                            Ref::keyword("ACCOUNTS").to_matchable(),
2824                            Ref::new("EqualsSegment").to_matchable(),
2825                            Delimited::new(vec![Ref::new("NakedIdentifierSegment").to_matchable()])
2826                                .to_matchable(),
2827                            Sequence::new(vec![
2828                                Ref::keyword("SHARE_RESTRICTIONS").to_matchable(),
2829                                Ref::new("EqualsSegment").to_matchable(),
2830                                Ref::new("BooleanLiteralGrammar").to_matchable(),
2831                            ])
2832                            .config(|this| this.optional())
2833                            .to_matchable(),
2834                        ])
2835                        .to_matchable(),
2836                        Sequence::new(vec![
2837                            Ref::keyword("SET").to_matchable(),
2838                            Ref::keyword("ACCOUNTS").to_matchable(),
2839                            Ref::new("EqualsSegment").to_matchable(),
2840                            Delimited::new(vec![Ref::new("NakedIdentifierSegment").to_matchable()])
2841                                .to_matchable(),
2842                            Ref::new("CommentEqualsClauseSegment")
2843                                .optional()
2844                                .to_matchable(),
2845                        ])
2846                        .to_matchable(),
2847                        Sequence::new(vec![
2848                            Ref::keyword("SET").to_matchable(),
2849                            Ref::new("TagEqualsSegment").to_matchable(),
2850                        ])
2851                        .to_matchable(),
2852                        Sequence::new(vec![
2853                            Ref::keyword("UNSET").to_matchable(),
2854                            Ref::keyword("TAG").to_matchable(),
2855                            Ref::new("TagReferenceSegment").to_matchable(),
2856                            AnyNumberOf::new(vec![
2857                                Ref::new("CommaSegment").to_matchable(),
2858                                Ref::new("TagReferenceSegment").to_matchable(),
2859                            ])
2860                            .config(|this| this.optional())
2861                            .to_matchable(),
2862                        ])
2863                        .to_matchable(),
2864                        Sequence::new(vec![
2865                            Ref::keyword("UNSET").to_matchable(),
2866                            Ref::keyword("COMMENT").to_matchable(),
2867                        ])
2868                        .to_matchable(),
2869                    ])
2870                    .to_matchable(),
2871                ])
2872                .to_matchable()
2873            })
2874            .to_matchable()
2875            .into(),
2876        ),
2877        (
2878            "AlterStorageIntegrationSegment".into(),
2879            NodeMatcher::new(SyntaxKind::AlterStorageIntegrationStatement, |_| {
2880                Sequence::new(vec![
2881                    Ref::keyword("ALTER").to_matchable(),
2882                    Ref::keyword("STORAGE").optional().to_matchable(),
2883                    Ref::keyword("INTEGRATION").to_matchable(),
2884                    Ref::new("IfExistsGrammar").optional().to_matchable(),
2885                    Ref::new("ObjectReferenceSegment").to_matchable(),
2886                    one_of(vec![
2887                        Sequence::new(vec![
2888                            Ref::keyword("SET").to_matchable(),
2889                            one_of(vec![
2890                                Ref::new("TagEqualsSegment").optional().to_matchable(),
2891                                any_set_of(vec![
2892                                    Sequence::new(vec![
2893                                        Ref::keyword("COMMENT").to_matchable(),
2894                                        Ref::new("EqualsSegment").to_matchable(),
2895                                        Ref::new("QuotedLiteralSegment").to_matchable(),
2896                                    ])
2897                                    .to_matchable(),
2898                                    Sequence::new(vec![
2899                                        Ref::keyword("ENABLED").to_matchable(),
2900                                        Ref::new("EqualsSegment").to_matchable(),
2901                                        Ref::new("BooleanLiteralGrammar").to_matchable(),
2902                                    ])
2903                                    .to_matchable(),
2904                                    one_of(vec![
2905                                        any_set_of(vec![
2906                                            Sequence::new(vec![
2907                                                Ref::keyword("STORAGE_AWS_ROLE_ARN").to_matchable(),
2908                                                Ref::new("EqualsSegment").to_matchable(),
2909                                                Ref::new("QuotedLiteralSegment").to_matchable(),
2910                                            ])
2911                                            .to_matchable(),
2912                                            Sequence::new(vec![
2913                                                Ref::keyword("STORAGE_AWS_OBJECT_ACL")
2914                                                    .to_matchable(),
2915                                                Ref::new("EqualsSegment").to_matchable(),
2916                                                Ref::new("QuotedLiteralSegment").to_matchable(),
2917                                            ])
2918                                            .to_matchable(),
2919                                        ])
2920                                        .to_matchable(),
2921                                        any_set_of(vec![
2922                                            Sequence::new(vec![
2923                                                Ref::keyword("AZURE_TENANT_ID").to_matchable(),
2924                                                Ref::new("EqualsSegment").to_matchable(),
2925                                                Ref::new("QuotedLiteralSegment").to_matchable(),
2926                                            ])
2927                                            .to_matchable(),
2928                                        ])
2929                                        .to_matchable(),
2930                                    ])
2931                                    .to_matchable(),
2932                                    Sequence::new(vec![
2933                                        Ref::keyword("STORAGE_ALLOWED_LOCATIONS").to_matchable(),
2934                                        Ref::new("EqualsSegment").to_matchable(),
2935                                        one_of(vec![
2936                                            Bracketed::new(vec![
2937                                                Delimited::new(vec![
2938                                                    one_of(vec![
2939                                                        Ref::new("S3Path").to_matchable(),
2940                                                        Ref::new("GCSPath").to_matchable(),
2941                                                        Ref::new("AzureBlobStoragePath")
2942                                                            .to_matchable(),
2943                                                    ])
2944                                                    .to_matchable(),
2945                                                ])
2946                                                .to_matchable(),
2947                                            ])
2948                                            .to_matchable(),
2949                                            Bracketed::new(vec![
2950                                                Ref::new("QuotedStarSegment").to_matchable(),
2951                                            ])
2952                                            .to_matchable(),
2953                                        ])
2954                                        .to_matchable(),
2955                                    ])
2956                                    .to_matchable(),
2957                                    Sequence::new(vec![
2958                                        Ref::keyword("STORAGE_BLOCKED_LOCATIONS").to_matchable(),
2959                                        Ref::new("EqualsSegment").to_matchable(),
2960                                        Bracketed::new(vec![
2961                                            Delimited::new(vec![
2962                                                one_of(vec![
2963                                                    Ref::new("S3Path").to_matchable(),
2964                                                    Ref::new("GCSPath").to_matchable(),
2965                                                    Ref::new("AzureBlobStoragePath").to_matchable(),
2966                                                ])
2967                                                .to_matchable(),
2968                                            ])
2969                                            .to_matchable(),
2970                                        ])
2971                                        .to_matchable(),
2972                                    ])
2973                                    .to_matchable(),
2974                                ])
2975                                .to_matchable(),
2976                            ])
2977                            .to_matchable(),
2978                        ])
2979                        .to_matchable(),
2980                        Sequence::new(vec![
2981                            Ref::keyword("UNSET").to_matchable(),
2982                            one_of(vec![
2983                                Sequence::new(vec![
2984                                    Ref::keyword("TAG").to_matchable(),
2985                                    Delimited::new(vec![
2986                                        Ref::new("TagReferenceSegment").to_matchable(),
2987                                    ])
2988                                    .to_matchable(),
2989                                ])
2990                                .config(|this| this.optional())
2991                                .to_matchable(),
2992                                Ref::keyword("COMMENT").to_matchable(),
2993                                Ref::keyword("ENABLED").to_matchable(),
2994                                Ref::keyword("STORAGE_BLOCKED_LOCATIONS").to_matchable(),
2995                            ])
2996                            .to_matchable(),
2997                        ])
2998                        .to_matchable(),
2999                    ])
3000                    .to_matchable(),
3001                ])
3002                .to_matchable()
3003            })
3004            .to_matchable()
3005            .into(),
3006        ),
3007        (
3008            "AlterExternalTableStatementSegment".into(),
3009            NodeMatcher::new(SyntaxKind::AlterExternalTableStatement, |_| {
3010                Sequence::new(vec![
3011                    Ref::keyword("ALTER").to_matchable(),
3012                    Ref::keyword("EXTERNAL").to_matchable(),
3013                    Ref::keyword("TABLE").to_matchable(),
3014                    Ref::new("IfExistsGrammar").optional().to_matchable(),
3015                    Ref::new("TableReferenceSegment").to_matchable(),
3016                    one_of(vec![
3017                        Sequence::new(vec![
3018                            Ref::keyword("REFRESH").to_matchable(),
3019                            Ref::new("QuotedLiteralSegment").optional().to_matchable(),
3020                        ])
3021                        .to_matchable(),
3022                        Sequence::new(vec![
3023                            one_of(vec![
3024                                Ref::keyword("ADD").to_matchable(),
3025                                Ref::keyword("REMOVE").to_matchable(),
3026                            ])
3027                            .to_matchable(),
3028                            Ref::keyword("FILES").to_matchable(),
3029                            Bracketed::new(vec![
3030                                Delimited::new(vec![
3031                                    Ref::new("QuotedLiteralSegment").to_matchable(),
3032                                ])
3033                                .to_matchable(),
3034                            ])
3035                            .to_matchable(),
3036                        ])
3037                        .to_matchable(),
3038                        Sequence::new(vec![
3039                            Ref::keyword("SET").to_matchable(),
3040                            Sequence::new(vec![
3041                                Ref::keyword("AUTO_REFRESH").to_matchable(),
3042                                Ref::new("EqualsSegment").to_matchable(),
3043                                Ref::new("BooleanLiteralGrammar").to_matchable(),
3044                            ])
3045                            .config(|this| this.optional())
3046                            .to_matchable(),
3047                            Ref::new("TagEqualsSegment").optional().to_matchable(),
3048                        ])
3049                        .to_matchable(),
3050                        Sequence::new(vec![
3051                            Ref::keyword("UNSET").to_matchable(),
3052                            Ref::new("TagEqualsSegment").to_matchable(),
3053                        ])
3054                        .to_matchable(),
3055                        Sequence::new(vec![
3056                            Ref::keyword("DROP").to_matchable(),
3057                            Ref::keyword("PARTITION").to_matchable(),
3058                            Ref::keyword("LOCATION").to_matchable(),
3059                            Ref::new("QuotedLiteralSegment").to_matchable(),
3060                        ])
3061                        .to_matchable(),
3062                        Sequence::new(vec![
3063                            Ref::keyword("ADD").to_matchable(),
3064                            Ref::keyword("PARTITION").to_matchable(),
3065                            Bracketed::new(vec![
3066                                Delimited::new(vec![
3067                                    Sequence::new(vec![
3068                                        Ref::new("ColumnReferenceSegment").to_matchable(),
3069                                        Ref::new("EqualsSegment").to_matchable(),
3070                                        Ref::new("QuotedLiteralSegment").to_matchable(),
3071                                    ])
3072                                    .to_matchable(),
3073                                ])
3074                                .to_matchable(),
3075                            ])
3076                            .to_matchable(),
3077                            Ref::keyword("LOCATION").to_matchable(),
3078                            Ref::new("QuotedLiteralSegment").to_matchable(),
3079                        ])
3080                        .to_matchable(),
3081                    ])
3082                    .to_matchable(),
3083                ])
3084                .to_matchable()
3085            })
3086            .to_matchable()
3087            .into(),
3088        ),
3089        (
3090            "CommentEqualsClauseSegment".into(),
3091            NodeMatcher::new(SyntaxKind::CommentEqualsClause, |_| {
3092                Sequence::new(vec![
3093                    Ref::keyword("COMMENT").to_matchable(),
3094                    Ref::new("EqualsSegment").to_matchable(),
3095                    Ref::new("QuotedLiteralSegment").to_matchable(),
3096                ])
3097                .to_matchable()
3098            })
3099            .to_matchable()
3100            .into(),
3101        ),
3102        (
3103            "TagBracketedEqualsSegment".into(),
3104            NodeMatcher::new(SyntaxKind::TagBracketedEquals, |_| {
3105                Sequence::new(vec![
3106                    Sequence::new(vec![Ref::keyword("WITH").to_matchable()])
3107                        .config(|this| this.optional())
3108                        .to_matchable(),
3109                    Ref::keyword("TAG").to_matchable(),
3110                    Bracketed::new(vec![
3111                        Delimited::new(vec![
3112                            Sequence::new(vec![
3113                                Ref::new("TagReferenceSegment").to_matchable(),
3114                                Ref::new("EqualsSegment").to_matchable(),
3115                                Ref::new("QuotedLiteralSegment").to_matchable(),
3116                            ])
3117                            .to_matchable(),
3118                        ])
3119                        .to_matchable(),
3120                    ])
3121                    .to_matchable(),
3122                ])
3123                .to_matchable()
3124            })
3125            .to_matchable()
3126            .into(),
3127        ),
3128        (
3129            "TagEqualsSegment".into(),
3130            NodeMatcher::new(SyntaxKind::TagEquals, |_| {
3131                Sequence::new(vec![
3132                    Ref::keyword("TAG").to_matchable(),
3133                    Delimited::new(vec![
3134                        Sequence::new(vec![
3135                            Ref::new("TagReferenceSegment").to_matchable(),
3136                            Ref::new("EqualsSegment").to_matchable(),
3137                            Ref::new("QuotedLiteralSegment").to_matchable(),
3138                        ])
3139                        .to_matchable(),
3140                    ])
3141                    .to_matchable(),
3142                ])
3143                .to_matchable()
3144            })
3145            .to_matchable()
3146            .into(),
3147        ),
3148    ]);
3149
3150    snowflake_dialect.replace_grammar(
3151        "UnorderedSelectStatementSegment",
3152        ansi::get_unordered_select_statement_segment_grammar().copy(
3153            Some(vec![
3154                Ref::new("QualifyClauseSegment").optional().to_matchable(),
3155            ]),
3156            None,
3157            Some(Ref::new("OverlapsClauseSegment").optional().to_matchable()),
3158            None,
3159            Vec::new(),
3160            false,
3161        ),
3162    );
3163
3164    snowflake_dialect.add([
3165        (
3166            "AccessStatementSegment".into(),
3167            NodeMatcher::new(SyntaxKind::AccessStatement, |_| {
3168                let global_permissions = one_of(vec![
3169                    Sequence::new(vec![
3170                        Ref::keyword("CREATE").to_matchable(),
3171                        one_of(vec![
3172                            Ref::keyword("ACCOUNT").to_matchable(),
3173                            Ref::keyword("ROLE").to_matchable(),
3174                            Ref::keyword("USER").to_matchable(),
3175                            Ref::keyword("WAREHOUSE").to_matchable(),
3176                            Ref::keyword("DATABASE").to_matchable(),
3177                            Ref::keyword("INTEGRATION").to_matchable(),
3178                            Ref::keyword("SHARE").to_matchable(),
3179                            Sequence::new(vec![
3180                                Ref::keyword("DATA").to_matchable(),
3181                                Ref::keyword("EXCHANGE").to_matchable(),
3182                                Ref::keyword("LISTING").to_matchable(),
3183                            ])
3184                            .to_matchable(),
3185                            Sequence::new(vec![
3186                                Ref::keyword("NETWORK").to_matchable(),
3187                                Ref::keyword("POLICY").to_matchable(),
3188                            ])
3189                            .to_matchable(),
3190                        ])
3191                        .to_matchable(),
3192                    ])
3193                    .to_matchable(),
3194                    Sequence::new(vec![
3195                        Ref::keyword("APPLY").to_matchable(),
3196                        Ref::keyword("MASKING").to_matchable(),
3197                        Ref::keyword("POLICY").to_matchable(),
3198                    ])
3199                    .to_matchable(),
3200                    Sequence::new(vec![
3201                        Ref::keyword("APPLY").to_matchable(),
3202                        Ref::keyword("ROW").to_matchable(),
3203                        Ref::keyword("ACCESS").to_matchable(),
3204                        Ref::keyword("POLICY").to_matchable(),
3205                    ])
3206                    .to_matchable(),
3207                    Sequence::new(vec![
3208                        Ref::keyword("APPLY").to_matchable(),
3209                        Ref::keyword("SESSION").to_matchable(),
3210                        Ref::keyword("POLICY").to_matchable(),
3211                    ])
3212                    .to_matchable(),
3213                    Sequence::new(vec![
3214                        Ref::keyword("APPLY").to_matchable(),
3215                        Ref::keyword("TAG").to_matchable(),
3216                    ])
3217                    .to_matchable(),
3218                    Sequence::new(vec![
3219                        Ref::keyword("ATTACH").to_matchable(),
3220                        Ref::keyword("POLICY").to_matchable(),
3221                    ])
3222                    .to_matchable(),
3223                    Sequence::new(vec![
3224                        Ref::keyword("EXECUTE").to_matchable(),
3225                        Ref::keyword("TASK").to_matchable(),
3226                    ])
3227                    .to_matchable(),
3228                    Sequence::new(vec![
3229                        Ref::keyword("IMPORT").to_matchable(),
3230                        Ref::keyword("SHARE").to_matchable(),
3231                    ])
3232                    .to_matchable(),
3233                    Sequence::new(vec![
3234                        Ref::keyword("MANAGE").to_matchable(),
3235                        one_of(vec![
3236                            Ref::keyword("GRANTS").to_matchable(),
3237                            Sequence::new(vec![
3238                                one_of(vec![
3239                                    Ref::keyword("ACCOUNT").to_matchable(),
3240                                    Ref::keyword("ORGANIZATION").to_matchable(),
3241                                    Ref::keyword("USER").to_matchable(),
3242                                ])
3243                                .to_matchable(),
3244                                Ref::keyword("SUPPORT").to_matchable(),
3245                                Ref::keyword("CASES").to_matchable(),
3246                            ])
3247                            .to_matchable(),
3248                        ])
3249                        .to_matchable(),
3250                    ])
3251                    .to_matchable(),
3252                    Sequence::new(vec![
3253                        Ref::keyword("MONITOR").to_matchable(),
3254                        one_of(vec![
3255                            Ref::keyword("EXECUTION").to_matchable(),
3256                            Ref::keyword("USAGE").to_matchable(),
3257                        ])
3258                        .to_matchable(),
3259                    ])
3260                    .to_matchable(),
3261                    Sequence::new(vec![
3262                        Ref::keyword("OVERRIDE").to_matchable(),
3263                        Ref::keyword("SHARE").to_matchable(),
3264                        Ref::keyword("RESTRICTIONS").to_matchable(),
3265                    ])
3266                    .to_matchable(),
3267                ]);
3268
3269                let schema_object_names = [
3270                    "TABLE",
3271                    "VIEW",
3272                    "STAGE",
3273                    "FUNCTION",
3274                    "PROCEDURE",
3275                    "ROUTINE",
3276                    "SEQUENCE",
3277                    "STREAM",
3278                    "TASK",
3279                    "PIPE",
3280                ];
3281
3282                let schema_object_names_keywrods: Vec<Matchable> = schema_object_names
3283                    .iter()
3284                    .map(|name| Ref::keyword(*name).to_matchable())
3285                    .collect();
3286
3287                let mut schema_object_types = schema_object_names_keywrods.clone();
3288                schema_object_types.append(&mut vec![
3289                    Sequence::new(vec![
3290                        Ref::keyword("MATERIALIZED").to_matchable(),
3291                        Ref::keyword("VIEW").to_matchable(),
3292                    ])
3293                    .to_matchable(),
3294                    Sequence::new(vec![
3295                        Ref::keyword("EXTERNAL").to_matchable(),
3296                        Ref::keyword("TABLE").to_matchable(),
3297                    ])
3298                    .to_matchable(),
3299                    Sequence::new(vec![
3300                        one_of(vec![
3301                            Ref::keyword("TEMP").to_matchable(),
3302                            Ref::keyword("TEMPORARY").to_matchable(),
3303                        ])
3304                        .to_matchable(),
3305                        Ref::keyword("TABLE").to_matchable(),
3306                    ])
3307                    .to_matchable(),
3308                    Sequence::new(vec![
3309                        Ref::keyword("FILE").to_matchable(),
3310                        Ref::keyword("FORMAT").to_matchable(),
3311                    ])
3312                    .to_matchable(),
3313                    Sequence::new(vec![
3314                        Ref::keyword("SESSION").to_matchable(),
3315                        Ref::keyword("POLICY").to_matchable(),
3316                    ])
3317                    .to_matchable(),
3318                    Sequence::new(vec![
3319                        Ref::keyword("MASKING").to_matchable(),
3320                        Ref::keyword("POLICY").to_matchable(),
3321                    ])
3322                    .to_matchable(),
3323                    Sequence::new(vec![
3324                        Ref::keyword("ROW").to_matchable(),
3325                        Ref::keyword("ACCESS").to_matchable(),
3326                        Ref::keyword("POLICY").to_matchable(),
3327                    ])
3328                    .to_matchable(),
3329                ]);
3330
3331                let schema_object_types = one_of(schema_object_types);
3332
3333                let schema_object_types_plural = one_of(
3334                    schema_object_names
3335                        .iter()
3336                        .map(|name| Ref::keyword(format!("{name}S")).to_matchable())
3337                        .collect(),
3338                );
3339
3340                let permissions = Sequence::new(vec![
3341                    one_of(vec![
3342                        Sequence::new(vec![
3343                            Ref::keyword("CREATE").to_matchable(),
3344                            one_of(vec![
3345                                Ref::keyword("SCHEMA").to_matchable(),
3346                                schema_object_types.clone().to_matchable(),
3347                            ])
3348                            .to_matchable(),
3349                        ])
3350                        .to_matchable(),
3351                        Sequence::new(vec![
3352                            Ref::keyword("IMPORTED").to_matchable(),
3353                            Ref::keyword("PRIVILEGES").to_matchable(),
3354                        ])
3355                        .to_matchable(),
3356                        Ref::keyword("APPLY").to_matchable(),
3357                        Ref::keyword("CONNECT").to_matchable(),
3358                        Ref::keyword("CREATE").to_matchable(),
3359                        Ref::keyword("DELETE").to_matchable(),
3360                        Ref::keyword("EXECUTE").to_matchable(),
3361                        Ref::keyword("INSERT").to_matchable(),
3362                        Ref::keyword("MODIFY").to_matchable(),
3363                        Ref::keyword("MONITOR").to_matchable(),
3364                        Ref::keyword("OPERATE").to_matchable(),
3365                        Ref::keyword("OWNERSHIP").to_matchable(),
3366                        Ref::keyword("READ").to_matchable(),
3367                        Ref::keyword("REFERENCE_USAGE").to_matchable(),
3368                        Ref::keyword("REFERENCES").to_matchable(),
3369                        Ref::keyword("SELECT").to_matchable(),
3370                        Ref::keyword("TEMP").to_matchable(),
3371                        Ref::keyword("TEMPORARY").to_matchable(),
3372                        Ref::keyword("TRIGGER").to_matchable(),
3373                        Ref::keyword("TRUNCATE").to_matchable(),
3374                        Ref::keyword("UPDATE").to_matchable(),
3375                        Ref::keyword("USAGE").to_matchable(),
3376                        Ref::keyword("USE_ANY_ROLE").to_matchable(),
3377                        Ref::keyword("WRITE").to_matchable(),
3378                        Sequence::new(vec![
3379                            Ref::keyword("ALL").to_matchable(),
3380                            Ref::keyword("PRIVILEGES").optional().to_matchable(),
3381                        ])
3382                        .to_matchable(),
3383                    ])
3384                    .to_matchable(),
3385                    Ref::new("BracketedColumnReferenceListGrammar")
3386                        .optional()
3387                        .to_matchable(),
3388                ]);
3389
3390                let objects = one_of(vec![
3391                    Ref::keyword("ACCOUNT").to_matchable(),
3392                    Sequence::new(vec![
3393                        one_of(vec![
3394                            Sequence::new(vec![
3395                                Ref::keyword("RESOURCE").to_matchable(),
3396                                Ref::keyword("MONITOR").to_matchable(),
3397                            ])
3398                            .to_matchable(),
3399                            Ref::keyword("WAREHOUSE").to_matchable(),
3400                            Ref::keyword("DATABASE").to_matchable(),
3401                            Ref::keyword("DOMAIN").to_matchable(),
3402                            Ref::keyword("INTEGRATION").to_matchable(),
3403                            Ref::keyword("SCHEMA").to_matchable(),
3404                            Ref::keyword("ROLE").to_matchable(),
3405                            Sequence::new(vec![
3406                                Ref::keyword("ALL").to_matchable(),
3407                                Ref::keyword("SCHEMAS").to_matchable(),
3408                                Ref::keyword("IN").to_matchable(),
3409                                Ref::keyword("DATABASE").to_matchable(),
3410                            ])
3411                            .to_matchable(),
3412                            Sequence::new(vec![
3413                                Ref::keyword("FUTURE").to_matchable(),
3414                                Ref::keyword("SCHEMAS").to_matchable(),
3415                                Ref::keyword("IN").to_matchable(),
3416                                Ref::keyword("DATABASE").to_matchable(),
3417                            ])
3418                            .to_matchable(),
3419                            schema_object_types.clone().to_matchable(),
3420                            Sequence::new(vec![
3421                                Ref::keyword("ALL").to_matchable(),
3422                                one_of(vec![
3423                                    schema_object_types_plural.clone().to_matchable(),
3424                                    Sequence::new(vec![
3425                                        Ref::keyword("MATERIALIZED").to_matchable(),
3426                                        Ref::keyword("VIEWS").to_matchable(),
3427                                    ])
3428                                    .to_matchable(),
3429                                    Sequence::new(vec![
3430                                        Ref::keyword("EXTERNAL").to_matchable(),
3431                                        Ref::keyword("TABLES").to_matchable(),
3432                                    ])
3433                                    .to_matchable(),
3434                                    Sequence::new(vec![
3435                                        Ref::keyword("FILE").to_matchable(),
3436                                        Ref::keyword("FORMATS").to_matchable(),
3437                                    ])
3438                                    .to_matchable(),
3439                                ])
3440                                .to_matchable(),
3441                                Ref::keyword("IN").to_matchable(),
3442                                one_of(vec![
3443                                    Ref::keyword("SCHEMA").to_matchable(),
3444                                    Ref::keyword("DATABASE").to_matchable(),
3445                                ])
3446                                .to_matchable(),
3447                            ])
3448                            .to_matchable(),
3449                            Sequence::new(vec![
3450                                Ref::keyword("FUTURE").to_matchable(),
3451                                one_of(vec![
3452                                    schema_object_types_plural.clone().to_matchable(),
3453                                    Sequence::new(vec![
3454                                        Ref::keyword("MATERIALIZED").to_matchable(),
3455                                        Ref::keyword("VIEWS").to_matchable(),
3456                                    ])
3457                                    .to_matchable(),
3458                                    Sequence::new(vec![
3459                                        Ref::keyword("EXTERNAL").to_matchable(),
3460                                        Ref::keyword("TABLES").to_matchable(),
3461                                    ])
3462                                    .to_matchable(),
3463                                    Sequence::new(vec![
3464                                        Ref::keyword("FILE").to_matchable(),
3465                                        Ref::keyword("FORMATS").to_matchable(),
3466                                    ])
3467                                    .to_matchable(),
3468                                ])
3469                                .to_matchable(),
3470                                Ref::keyword("IN").to_matchable(),
3471                                one_of(vec![
3472                                    Ref::keyword("DATABASE").to_matchable(),
3473                                    Ref::keyword("SCHEMA").to_matchable(),
3474                                ])
3475                                .to_matchable(),
3476                            ])
3477                            .to_matchable(),
3478                        ])
3479                        .config(|this| this.optional())
3480                        .to_matchable(),
3481                        Delimited::new(vec![
3482                            Ref::new("ObjectReferenceSegment").to_matchable(),
3483                            Sequence::new(vec![
3484                                Ref::new("FunctionNameSegment").to_matchable(),
3485                                Ref::new("FunctionParameterListGrammar")
3486                                    .optional()
3487                                    .to_matchable(),
3488                            ])
3489                            .to_matchable(),
3490                        ])
3491                        .config(|this| {
3492                            this.terminators = vec![
3493                                Ref::keyword("TO").to_matchable(),
3494                                Ref::keyword("FROM").to_matchable(),
3495                            ]
3496                        })
3497                        .to_matchable(),
3498                    ])
3499                    .to_matchable(),
3500                ]);
3501
3502                one_of(vec![
3503                    // Grant statement
3504                    Sequence::new(vec![
3505                        Ref::keyword("GRANT").to_matchable(),
3506                        one_of(vec![
3507                            Sequence::new(vec![
3508                                Delimited::new(vec![
3509                                    one_of(vec![
3510                                        global_permissions.clone().to_matchable(),
3511                                        permissions.clone().to_matchable(),
3512                                    ])
3513                                    .to_matchable(),
3514                                ])
3515                                .config(|this| {
3516                                    this.terminators = vec![Ref::keyword("ON").to_matchable()]
3517                                })
3518                                .to_matchable(),
3519                                Ref::keyword("ON").to_matchable(),
3520                                objects.clone().to_matchable(),
3521                            ])
3522                            .to_matchable(),
3523                            Sequence::new(vec![
3524                                Ref::keyword("ROLE").to_matchable(),
3525                                Ref::new("ObjectReferenceSegment").to_matchable(),
3526                            ])
3527                            .to_matchable(),
3528                            Sequence::new(vec![
3529                                Ref::keyword("OWNERSHIP").to_matchable(),
3530                                Ref::keyword("ON").to_matchable(),
3531                                Ref::keyword("USER").to_matchable(),
3532                                Ref::new("ObjectReferenceSegment").to_matchable(),
3533                            ])
3534                            .to_matchable(),
3535                            Sequence::new(vec![
3536                                Ref::keyword("ADD").to_matchable(),
3537                                Ref::keyword("SEARCH").to_matchable(),
3538                                Ref::keyword("OPTIMIZATION").to_matchable(),
3539                                Ref::keyword("ON").to_matchable(),
3540                                Ref::keyword("SCHEMA").to_matchable(),
3541                                Ref::new("SchemaReferenceSegment").to_matchable(),
3542                            ])
3543                            .to_matchable(),
3544                            Ref::new("ObjectReferenceSegment").to_matchable(),
3545                        ])
3546                        .to_matchable(),
3547                        Ref::keyword("TO").to_matchable(),
3548                        Ref::keyword("USER").optional().to_matchable(),
3549                        Ref::keyword("ROLE").optional().to_matchable(),
3550                        Ref::keyword("SHARE").optional().to_matchable(),
3551                        Delimited::new(vec![
3552                            one_of(vec![
3553                                Ref::new("RoleReferenceSegment").to_matchable(),
3554                                Ref::new("FunctionSegment").to_matchable(),
3555                                Ref::keyword("PUBLIC").to_matchable(),
3556                            ])
3557                            .to_matchable(),
3558                        ])
3559                        .to_matchable(),
3560                        one_of(vec![
3561                            Sequence::new(vec![
3562                                Ref::keyword("WITH").to_matchable(),
3563                                Ref::keyword("GRANT").to_matchable(),
3564                                Ref::keyword("OPTION").to_matchable(),
3565                            ])
3566                            .to_matchable(),
3567                            Sequence::new(vec![
3568                                Ref::keyword("WITH").to_matchable(),
3569                                Ref::keyword("ADMIN").to_matchable(),
3570                                Ref::keyword("OPTION").to_matchable(),
3571                            ])
3572                            .to_matchable(),
3573                            Sequence::new(vec![
3574                                one_of(vec![
3575                                    Ref::keyword("REVOKE").to_matchable(),
3576                                    Ref::keyword("COPY").to_matchable(),
3577                                ])
3578                                .to_matchable(),
3579                                Ref::keyword("CURRENT").to_matchable(),
3580                                Ref::keyword("GRANTS").to_matchable(),
3581                            ])
3582                            .config(|this| this.optional())
3583                            .to_matchable(),
3584                        ])
3585                        .config(|this| this.optional())
3586                        .to_matchable(),
3587                        Sequence::new(vec![
3588                            Ref::keyword("GRANTED").to_matchable(),
3589                            Ref::keyword("BY").to_matchable(),
3590                            one_of(vec![
3591                                Ref::keyword("CURRENT_USER").to_matchable(),
3592                                Ref::keyword("SESSION_USER").to_matchable(),
3593                                Ref::new("ObjectReferenceSegment").to_matchable(),
3594                            ])
3595                            .config(|this| this.optional())
3596                            .to_matchable(),
3597                        ])
3598                        .config(|this| this.optional())
3599                        .to_matchable(),
3600                    ])
3601                    .to_matchable(),
3602                    // Revoke statement
3603                    Sequence::new(vec![
3604                        Ref::keyword("REVOKE").to_matchable(),
3605                        Sequence::new(vec![
3606                            Ref::keyword("GRANT").to_matchable(),
3607                            Ref::keyword("OPTION").to_matchable(),
3608                            Ref::keyword("FOR").to_matchable(),
3609                        ])
3610                        .config(|this| this.optional())
3611                        .to_matchable(),
3612                        one_of(vec![
3613                            Sequence::new(vec![
3614                                Delimited::new(vec![
3615                                    one_of(vec![
3616                                        global_permissions.clone().to_matchable(),
3617                                        permissions.clone().to_matchable(),
3618                                    ])
3619                                    .to_matchable(),
3620                                ])
3621                                .config(|this| {
3622                                    this.terminators = vec![Ref::keyword("ON").to_matchable()];
3623                                })
3624                                .to_matchable(),
3625                                Ref::keyword("ON").to_matchable(),
3626                                objects.clone().to_matchable(),
3627                            ])
3628                            .to_matchable(),
3629                            Sequence::new(vec![
3630                                Ref::keyword("ROLE").to_matchable(),
3631                                Ref::new("ObjectReferenceSegment").to_matchable(),
3632                            ])
3633                            .to_matchable(),
3634                            Sequence::new(vec![
3635                                Ref::keyword("OWNERSHIP").to_matchable(),
3636                                Ref::keyword("ON").to_matchable(),
3637                                Ref::keyword("USER").to_matchable(),
3638                                Ref::new("ObjectReferenceSegment").to_matchable(),
3639                            ])
3640                            .to_matchable(),
3641                            Sequence::new(vec![
3642                                Ref::keyword("ADD").to_matchable(),
3643                                Ref::keyword("SEARCH").to_matchable(),
3644                                Ref::keyword("OPTIMIZATION").to_matchable(),
3645                                Ref::keyword("ON").to_matchable(),
3646                                Ref::keyword("SCHEMA").to_matchable(),
3647                                Ref::new("SchemaReferenceSegment").to_matchable(),
3648                            ])
3649                            .to_matchable(),
3650                        ])
3651                        .to_matchable(),
3652                        Ref::keyword("FROM").to_matchable(),
3653                        Ref::keyword("USER").optional().to_matchable(),
3654                        Ref::keyword("ROLE").optional().to_matchable(),
3655                        Ref::keyword("SHARE").optional().to_matchable(),
3656                        Delimited::new(vec![Ref::new("ObjectReferenceSegment").to_matchable()])
3657                            .to_matchable(),
3658                        Ref::new("DropBehaviorGrammar").optional().to_matchable(),
3659                    ])
3660                    .to_matchable(),
3661                ])
3662                .to_matchable()
3663            })
3664            .to_matchable()
3665            .into(),
3666        ),
3667        (
3668            "CreateCloneStatementSegment".into(),
3669            NodeMatcher::new(SyntaxKind::CreateCloneStatement, |_| {
3670                Sequence::new(vec![
3671                    Ref::keyword("CREATE").to_matchable(),
3672                    Sequence::new(vec![
3673                        Ref::keyword("OR").to_matchable(),
3674                        Ref::keyword("REPLACE").to_matchable(),
3675                    ])
3676                    .config(|this| this.optional())
3677                    .to_matchable(),
3678                    one_of(vec![
3679                        Ref::keyword("DATABASE").to_matchable(),
3680                        Ref::keyword("SCHEMA").to_matchable(),
3681                        Ref::keyword("TABLE").to_matchable(),
3682                        Ref::keyword("SEQUENCE").to_matchable(),
3683                        Sequence::new(vec![
3684                            Ref::keyword("FILE").to_matchable(),
3685                            Ref::keyword("FORMAT").to_matchable(),
3686                        ])
3687                        .to_matchable(),
3688                        Ref::keyword("STAGE").to_matchable(),
3689                        Ref::keyword("STREAM").to_matchable(),
3690                        Ref::keyword("TASK").to_matchable(),
3691                    ])
3692                    .to_matchable(),
3693                    Sequence::new(vec![
3694                        Ref::keyword("IF").to_matchable(),
3695                        Ref::keyword("NOT").to_matchable(),
3696                        Ref::keyword("EXISTS").to_matchable(),
3697                    ])
3698                    .config(|this| this.optional())
3699                    .to_matchable(),
3700                    Ref::new("ObjectReferenceSegment").to_matchable(),
3701                    Ref::keyword("CLONE").to_matchable(),
3702                    Ref::new("ObjectReferenceSegment").to_matchable(),
3703                    one_of(vec![
3704                        Ref::new("FromAtExpressionSegment").to_matchable(),
3705                        Ref::new("FromBeforeExpressionSegment").to_matchable(),
3706                    ])
3707                    .config(|this| this.optional())
3708                    .to_matchable(),
3709                ])
3710                .to_matchable()
3711            })
3712            .to_matchable()
3713            .into(),
3714        ),
3715        (
3716            "CreateDatabaseFromShareStatementSegment".into(),
3717            NodeMatcher::new(SyntaxKind::CreateDatabaseFromShareStatement, |_| {
3718                Sequence::new(vec![
3719                    Ref::keyword("CREATE").to_matchable(),
3720                    Ref::keyword("DATABASE").to_matchable(),
3721                    Ref::new("ObjectReferenceSegment").to_matchable(),
3722                    Sequence::new(vec![
3723                        Ref::keyword("FROM").to_matchable(),
3724                        Ref::keyword("SHARE").to_matchable(),
3725                    ])
3726                    .to_matchable(),
3727                    Ref::new("ObjectReferenceSegment").to_matchable(),
3728                ])
3729                .to_matchable()
3730            })
3731            .to_matchable()
3732            .into(),
3733        ),
3734        (
3735            "CreateProcedureStatementSegment".into(),
3736            NodeMatcher::new(SyntaxKind::CreateProcedureStatement, |_| {
3737                Sequence::new(vec![
3738                    Ref::keyword("CREATE").to_matchable(),
3739                    Sequence::new(vec![
3740                        Ref::keyword("OR").to_matchable(),
3741                        Ref::keyword("REPLACE").to_matchable(),
3742                    ])
3743                    .config(|this| this.optional())
3744                    .to_matchable(),
3745                    Sequence::new(vec![Ref::keyword("SECURE").to_matchable()])
3746                        .config(|this| this.optional())
3747                        .to_matchable(),
3748                    Ref::keyword("PROCEDURE").to_matchable(),
3749                    Ref::new("FunctionNameSegment").to_matchable(),
3750                    Ref::new("FunctionParameterListGrammar").to_matchable(),
3751                    Sequence::new(vec![
3752                        Ref::keyword("COPY").to_matchable(),
3753                        Ref::keyword("GRANTS").to_matchable(),
3754                    ])
3755                    .config(|this| this.optional())
3756                    .to_matchable(),
3757                    Ref::keyword("RETURNS").to_matchable(),
3758                    one_of(vec![
3759                        Ref::new("DatatypeSegment").to_matchable(),
3760                        Sequence::new(vec![
3761                            Ref::keyword("TABLE").to_matchable(),
3762                            Bracketed::new(vec![
3763                                Delimited::new(vec![
3764                                    Ref::new("ColumnDefinitionSegment").to_matchable(),
3765                                ])
3766                                .config(|this| this.optional())
3767                                .to_matchable(),
3768                            ])
3769                            .to_matchable(),
3770                        ])
3771                        .to_matchable(),
3772                    ])
3773                    .to_matchable(),
3774                    any_set_of(vec![
3775                        Sequence::new(vec![
3776                            Ref::keyword("NOT").to_matchable(),
3777                            Ref::keyword("NULL").to_matchable(),
3778                        ])
3779                        .config(|this| this.optional())
3780                        .to_matchable(),
3781                        Sequence::new(vec![
3782                            Ref::keyword("LANGUAGE").to_matchable(),
3783                            one_of(vec![
3784                                Ref::keyword("JAVA").to_matchable(),
3785                                Ref::keyword("JAVASCRIPT").to_matchable(),
3786                                Ref::keyword("PYTHON").to_matchable(),
3787                                Ref::keyword("SCALA").to_matchable(),
3788                                Ref::keyword("SQL").to_matchable(),
3789                            ])
3790                            .config(|this| this.optional())
3791                            .to_matchable(),
3792                        ])
3793                        .to_matchable(),
3794                        one_of(vec![
3795                            Sequence::new(vec![
3796                                Ref::keyword("CALLED").to_matchable(),
3797                                Ref::keyword("ON").to_matchable(),
3798                                Ref::keyword("NULL").to_matchable(),
3799                                Ref::keyword("INPUT").to_matchable(),
3800                            ])
3801                            .to_matchable(),
3802                            Sequence::new(vec![
3803                                Ref::keyword("RETURNS").to_matchable(),
3804                                Ref::keyword("NULL").to_matchable(),
3805                                Ref::keyword("ON").to_matchable(),
3806                                Ref::keyword("NULL").to_matchable(),
3807                                Ref::keyword("INPUT").to_matchable(),
3808                            ])
3809                            .to_matchable(),
3810                            Ref::keyword("STRICT").to_matchable(),
3811                        ])
3812                        .config(|this| this.optional())
3813                        .to_matchable(),
3814                        one_of(vec![
3815                            Ref::keyword("VOLATILE").to_matchable(),
3816                            Ref::keyword("IMMUTABLE").to_matchable(),
3817                        ])
3818                        .config(|this| this.optional())
3819                        .to_matchable(),
3820                        Sequence::new(vec![
3821                            Ref::keyword("RUNTIME_VERSION").to_matchable(),
3822                            Ref::new("EqualsSegment").to_matchable(),
3823                            Ref::new("QuotedLiteralSegment").to_matchable(),
3824                        ])
3825                        .config(|this| this.optional())
3826                        .to_matchable(),
3827                        Ref::new("CommentEqualsClauseSegment")
3828                            .optional()
3829                            .to_matchable(),
3830                        Sequence::new(vec![
3831                            Ref::keyword("IMPORTS").to_matchable(),
3832                            Ref::new("EqualsSegment").to_matchable(),
3833                            Bracketed::new(vec![
3834                                Delimited::new(vec![
3835                                    Ref::new("QuotedLiteralSegment").to_matchable(),
3836                                ])
3837                                .to_matchable(),
3838                            ])
3839                            .to_matchable(),
3840                        ])
3841                        .config(|this| this.optional())
3842                        .to_matchable(),
3843                        Sequence::new(vec![
3844                            Ref::keyword("PACKAGES").to_matchable(),
3845                            Ref::new("EqualsSegment").to_matchable(),
3846                            Bracketed::new(vec![
3847                                Delimited::new(vec![
3848                                    Ref::new("QuotedLiteralSegment").to_matchable(),
3849                                ])
3850                                .to_matchable(),
3851                            ])
3852                            .to_matchable(),
3853                        ])
3854                        .config(|this| this.optional())
3855                        .to_matchable(),
3856                        Sequence::new(vec![
3857                            Ref::keyword("HANDLER").to_matchable(),
3858                            Ref::new("EqualsSegment").to_matchable(),
3859                            Ref::new("QuotedLiteralSegment").to_matchable(),
3860                        ])
3861                        .config(|this| this.optional())
3862                        .to_matchable(),
3863                        Sequence::new(vec![
3864                            Ref::keyword("TARGET_PATH").to_matchable(),
3865                            Ref::new("EqualsSegment").to_matchable(),
3866                            Ref::new("QuotedLiteralSegment").to_matchable(),
3867                        ])
3868                        .config(|this| this.optional())
3869                        .to_matchable(),
3870                        Sequence::new(vec![
3871                            Ref::keyword("EXECUTE").to_matchable(),
3872                            Ref::keyword("AS").to_matchable(),
3873                            one_of(vec![
3874                                Ref::keyword("CALLER").to_matchable(),
3875                                Ref::keyword("OWNER").to_matchable(),
3876                            ])
3877                            .to_matchable(),
3878                        ])
3879                        .config(|this| this.optional())
3880                        .to_matchable(),
3881                    ])
3882                    .config(|this| this.optional())
3883                    .to_matchable(),
3884                    Ref::keyword("AS").to_matchable(),
3885                    one_of(vec![
3886                        Ref::new("DoubleQuotedUDFBody").to_matchable(),
3887                        Ref::new("SingleQuotedUDFBody").to_matchable(),
3888                        Ref::new("DollarQuotedUDFBody").to_matchable(),
3889                        Ref::new("ScriptingBlockStatementSegment").to_matchable(),
3890                    ])
3891                    .to_matchable(),
3892                ])
3893                .to_matchable()
3894            })
3895            .to_matchable()
3896            .into(),
3897        ),
3898        (
3899            "AlterProcedureStatementSegment".into(),
3900            NodeMatcher::new(SyntaxKind::AlterProcedureStatement, |_| {
3901                Sequence::new(vec![
3902                    Ref::keyword("ALTER").to_matchable(),
3903                    Ref::keyword("PROCEDURE").to_matchable(),
3904                    Ref::new("IfExistsGrammar").optional().to_matchable(),
3905                    Ref::new("FunctionNameSegment").to_matchable(),
3906                    Ref::new("FunctionParameterListGrammar").to_matchable(),
3907                    one_of(vec![
3908                        Sequence::new(vec![
3909                            Ref::keyword("RENAME").to_matchable(),
3910                            Ref::keyword("TO").to_matchable(),
3911                            Ref::new("FunctionNameSegment").to_matchable(),
3912                        ])
3913                        .to_matchable(),
3914                        Sequence::new(vec![
3915                            Ref::keyword("EXECUTE").to_matchable(),
3916                            Ref::keyword("AS").to_matchable(),
3917                            one_of(vec![
3918                                Ref::keyword("CALLER").to_matchable(),
3919                                Ref::keyword("OWNER").to_matchable(),
3920                            ])
3921                            .to_matchable(),
3922                        ])
3923                        .to_matchable(),
3924                        Sequence::new(vec![
3925                            Ref::keyword("SET").to_matchable(),
3926                            one_of(vec![
3927                                Ref::new("TagEqualsSegment").to_matchable(),
3928                                Ref::new("CommentEqualsClauseSegment").to_matchable(),
3929                            ])
3930                            .to_matchable(),
3931                        ])
3932                        .to_matchable(),
3933                        Sequence::new(vec![
3934                            Ref::keyword("UNSET").to_matchable(),
3935                            one_of(vec![
3936                                Sequence::new(vec![
3937                                    Ref::keyword("TAG").to_matchable(),
3938                                    Delimited::new(vec![
3939                                        Ref::new("TagReferenceSegment").to_matchable(),
3940                                    ])
3941                                    .to_matchable(),
3942                                ])
3943                                .to_matchable(),
3944                                Ref::keyword("COMMENT").to_matchable(),
3945                            ])
3946                            .to_matchable(),
3947                        ])
3948                        .to_matchable(),
3949                    ])
3950                    .to_matchable(),
3951                ])
3952                .to_matchable()
3953            })
3954            .to_matchable()
3955            .into(),
3956        ),
3957        (
3958            "ReturnStatementSegment".into(),
3959            NodeMatcher::new(SyntaxKind::ReturnStatement, |_| {
3960                Sequence::new(vec![
3961                    Ref::keyword("RETURN").to_matchable(),
3962                    Ref::new("ExpressionSegment").to_matchable(),
3963                ])
3964                .to_matchable()
3965            })
3966            .to_matchable()
3967            .into(),
3968        ),
3969        (
3970            "ScriptingBlockStatementSegment".into(),
3971            NodeMatcher::new(SyntaxKind::ScriptingBlockStatement, |_| {
3972                one_of(vec![
3973                    Sequence::new(vec![
3974                        Ref::keyword("BEGIN").to_matchable(),
3975                        Delimited::new(vec![Ref::new("StatementSegment").to_matchable()])
3976                            .to_matchable(),
3977                    ])
3978                    .to_matchable(),
3979                    Sequence::new(vec![Ref::keyword("END").to_matchable()]).to_matchable(),
3980                ])
3981                .to_matchable()
3982            })
3983            .to_matchable()
3984            .into(),
3985        ),
3986        (
3987            "ScriptingLetStatementSegment".into(),
3988            NodeMatcher::new(SyntaxKind::ScriptingLetStatement, |_| {
3989                one_of(vec![
3990                    // Initial declaration and assignment
3991                    Sequence::new(vec![
3992                        Ref::keyword("LET").to_matchable(),
3993                        Ref::new("LocalVariableNameSegment").to_matchable(),
3994                        one_of(vec![
3995                            // Variable assignment
3996                            one_of(vec![
3997                                Sequence::new(vec![
3998                                    Ref::new("DatatypeSegment").to_matchable(),
3999                                    one_of(vec![
4000                                        Ref::keyword("DEFAULT").to_matchable(),
4001                                        Ref::new("WalrusOperatorSegment").to_matchable(),
4002                                    ])
4003                                    .to_matchable(),
4004                                    Ref::new("ExpressionSegment").to_matchable(),
4005                                ])
4006                                .to_matchable(),
4007                                Sequence::new(vec![
4008                                    one_of(vec![
4009                                        Ref::keyword("DEFAULT").to_matchable(),
4010                                        Ref::new("WalrusOperatorSegment").to_matchable(),
4011                                    ])
4012                                    .to_matchable(),
4013                                    Ref::new("ExpressionSegment").to_matchable(),
4014                                ])
4015                                .to_matchable(),
4016                            ])
4017                            .to_matchable(),
4018                            // Cursor assignment
4019                            Sequence::new(vec![
4020                                Ref::keyword("CURSOR").to_matchable(),
4021                                Ref::keyword("FOR").to_matchable(),
4022                                one_of(vec![
4023                                    Ref::new("LocalVariableNameSegment").to_matchable(),
4024                                    Ref::new("SelectableGrammar").to_matchable(),
4025                                ])
4026                                .to_matchable(),
4027                            ])
4028                            .to_matchable(),
4029                            // Resultset assignment
4030                            Sequence::new(vec![
4031                                Ref::keyword("RESULTSET").to_matchable(),
4032                                Ref::new("WalrusOperatorSegment").to_matchable(),
4033                                Bracketed::new(vec![Ref::new("SelectableGrammar").to_matchable()])
4034                                    .to_matchable(),
4035                            ])
4036                            .to_matchable(),
4037                        ])
4038                        .to_matchable(),
4039                    ])
4040                    .to_matchable(),
4041                    // Subsequent assignment
4042                    Sequence::new(vec![
4043                        Ref::new("LocalVariableNameSegment").to_matchable(),
4044                        Ref::new("WalrusOperatorSegment").to_matchable(),
4045                        one_of(vec![
4046                            // Variable reassignment
4047                            Ref::new("ExpressionSegment").to_matchable(),
4048                            // Resultset reassignment
4049                            Bracketed::new(vec![Ref::new("SelectableGrammar").to_matchable()])
4050                                .to_matchable(),
4051                        ])
4052                        .to_matchable(),
4053                    ])
4054                    .to_matchable(),
4055                ])
4056                .to_matchable()
4057            })
4058            .to_matchable()
4059            .into(),
4060        ),
4061        (
4062            "CreateFunctionStatementSegment".into(),
4063            NodeMatcher::new(SyntaxKind::CreateFunctionStatement, |_| {
4064                Sequence::new(vec![
4065                    Ref::keyword("CREATE").to_matchable(),
4066                    Sequence::new(vec![
4067                        Ref::keyword("OR").to_matchable(),
4068                        Ref::keyword("REPLACE").to_matchable(),
4069                    ])
4070                    .config(|this| this.optional())
4071                    .to_matchable(),
4072                    Sequence::new(vec![Ref::keyword("SECURE").to_matchable()])
4073                        .config(|this| this.optional())
4074                        .to_matchable(),
4075                    Ref::keyword("FUNCTION").to_matchable(),
4076                    Ref::new("IfNotExistsGrammar").optional().to_matchable(),
4077                    Ref::new("FunctionNameSegment").to_matchable(),
4078                    Ref::new("FunctionParameterListGrammar").to_matchable(),
4079                    Ref::keyword("RETURNS").to_matchable(),
4080                    one_of(vec![
4081                        Ref::new("DatatypeSegment").to_matchable(),
4082                        Sequence::new(vec![
4083                            Ref::keyword("TABLE").to_matchable(),
4084                            Bracketed::new(vec![
4085                                Delimited::new(vec![
4086                                    Ref::new("ColumnDefinitionSegment").to_matchable(),
4087                                ])
4088                                .to_matchable(),
4089                            ])
4090                            .to_matchable(),
4091                        ])
4092                        .to_matchable(),
4093                    ])
4094                    .to_matchable(),
4095                    any_set_of(vec![
4096                        Sequence::new(vec![
4097                            Ref::keyword("NOT").to_matchable(),
4098                            Ref::keyword("NULL").to_matchable(),
4099                        ])
4100                        .config(|this| this.optional())
4101                        .to_matchable(),
4102                        Sequence::new(vec![
4103                            Ref::keyword("LANGUAGE").to_matchable(),
4104                            one_of(vec![
4105                                Ref::keyword("JAVASCRIPT").to_matchable(),
4106                                Ref::keyword("SQL").to_matchable(),
4107                                Ref::keyword("PYTHON").to_matchable(),
4108                                Ref::keyword("JAVA").to_matchable(),
4109                                Ref::keyword("SCALA").to_matchable(),
4110                            ])
4111                            .config(|this| this.optional())
4112                            .to_matchable(),
4113                        ])
4114                        .to_matchable(),
4115                        one_of(vec![
4116                            Sequence::new(vec![
4117                                Ref::keyword("CALLED").to_matchable(),
4118                                Ref::keyword("ON").to_matchable(),
4119                                Ref::keyword("NULL").to_matchable(),
4120                                Ref::keyword("INPUT").to_matchable(),
4121                            ])
4122                            .to_matchable(),
4123                            Sequence::new(vec![
4124                                Ref::keyword("RETURNS").to_matchable(),
4125                                Ref::keyword("NULL").to_matchable(),
4126                                Ref::keyword("ON").to_matchable(),
4127                                Ref::keyword("NULL").to_matchable(),
4128                                Ref::keyword("INPUT").to_matchable(),
4129                            ])
4130                            .to_matchable(),
4131                            Ref::keyword("STRICT").to_matchable(),
4132                        ])
4133                        .config(|this| this.optional())
4134                        .to_matchable(),
4135                        one_of(vec![
4136                            Ref::keyword("VOLATILE").to_matchable(),
4137                            Ref::keyword("IMMUTABLE").to_matchable(),
4138                        ])
4139                        .config(|this| this.optional())
4140                        .to_matchable(),
4141                        Sequence::new(vec![
4142                            Ref::keyword("RUNTIME_VERSION").to_matchable(),
4143                            Ref::new("EqualsSegment").to_matchable(),
4144                            Ref::new("QuotedLiteralSegment").to_matchable(),
4145                        ])
4146                        .config(|this| this.optional())
4147                        .to_matchable(),
4148                        Ref::new("CommentEqualsClauseSegment")
4149                            .optional()
4150                            .to_matchable(),
4151                        Sequence::new(vec![
4152                            Ref::keyword("IMPORTS").to_matchable(),
4153                            Ref::new("EqualsSegment").to_matchable(),
4154                            Bracketed::new(vec![
4155                                Delimited::new(vec![
4156                                    Ref::new("QuotedLiteralSegment").to_matchable(),
4157                                ])
4158                                .to_matchable(),
4159                            ])
4160                            .to_matchable(),
4161                        ])
4162                        .config(|this| this.optional())
4163                        .to_matchable(),
4164                        Sequence::new(vec![
4165                            Ref::keyword("PACKAGES").to_matchable(),
4166                            Ref::new("EqualsSegment").to_matchable(),
4167                            Bracketed::new(vec![
4168                                Delimited::new(vec![
4169                                    Ref::new("QuotedLiteralSegment").to_matchable(),
4170                                ])
4171                                .to_matchable(),
4172                            ])
4173                            .to_matchable(),
4174                        ])
4175                        .config(|this| this.optional())
4176                        .to_matchable(),
4177                        Sequence::new(vec![
4178                            Ref::keyword("HANDLER").to_matchable(),
4179                            Ref::new("EqualsSegment").to_matchable(),
4180                            Ref::new("QuotedLiteralSegment").to_matchable(),
4181                        ])
4182                        .config(|this| this.optional())
4183                        .to_matchable(),
4184                        Sequence::new(vec![
4185                            Ref::keyword("TARGET_PATH").to_matchable(),
4186                            Ref::new("EqualsSegment").to_matchable(),
4187                            Ref::new("QuotedLiteralSegment").to_matchable(),
4188                        ])
4189                        .config(|this| this.optional())
4190                        .to_matchable(),
4191                    ])
4192                    .config(|this| this.optional())
4193                    .to_matchable(),
4194                    Sequence::new(vec![
4195                        Ref::keyword("AS").to_matchable(),
4196                        one_of(vec![
4197                            // Either a foreign programming language UDF...
4198                            Ref::new("DoubleQuotedUDFBody").to_matchable(),
4199                            Ref::new("SingleQuotedUDFBody").to_matchable(),
4200                            Ref::new("DollarQuotedUDFBody").to_matchable(),
4201                            // ...or a SQL UDF
4202                            Ref::new("ScriptingBlockStatementSegment").to_matchable(),
4203                        ])
4204                        .to_matchable(),
4205                    ])
4206                    .config(|this| this.optional())
4207                    .to_matchable(),
4208                ])
4209                .to_matchable()
4210            })
4211            .to_matchable()
4212            .into(),
4213        ),
4214        (
4215            "AlterFunctionStatementSegment".into(),
4216            NodeMatcher::new(SyntaxKind::AlterFunctionStatement, |_| {
4217                Sequence::new(vec![
4218                    Ref::keyword("ALTER").to_matchable(),
4219                    Ref::keyword("FUNCTION").to_matchable(),
4220                    Sequence::new(vec![
4221                        Ref::keyword("IF").to_matchable(),
4222                        Ref::keyword("EXISTS").to_matchable(),
4223                    ])
4224                    .config(|this| this.optional())
4225                    .to_matchable(),
4226                    Ref::new("FunctionNameSegment").to_matchable(),
4227                    Ref::new("FunctionParameterListGrammar").to_matchable(),
4228                    one_of(vec![
4229                        Sequence::new(vec![
4230                            Ref::keyword("RENAME").to_matchable(),
4231                            Ref::keyword("TO").to_matchable(),
4232                            Ref::new("FunctionNameSegment").to_matchable(),
4233                        ])
4234                        .to_matchable(),
4235                        Sequence::new(vec![
4236                            Ref::keyword("SET").to_matchable(),
4237                            one_of(vec![
4238                                Ref::new("CommentEqualsClauseSegment").to_matchable(),
4239                                Sequence::new(vec![
4240                                    Ref::keyword("API_INTEGRATION").to_matchable(),
4241                                    Ref::new("EqualsSegment").to_matchable(),
4242                                    Ref::new("SingleIdentifierGrammar").to_matchable(),
4243                                ])
4244                                .to_matchable(),
4245                                Sequence::new(vec![
4246                                    Ref::keyword("HEADERS").to_matchable(),
4247                                    Ref::new("EqualsSegment").to_matchable(),
4248                                    Bracketed::new(vec![
4249                                        Delimited::new(vec![
4250                                            Sequence::new(vec![
4251                                                Ref::new("SingleQuotedIdentifierSegment")
4252                                                    .to_matchable(),
4253                                                Ref::new("EqualsSegment").to_matchable(),
4254                                                Ref::new("SingleQuotedIdentifierSegment")
4255                                                    .to_matchable(),
4256                                            ])
4257                                            .to_matchable(),
4258                                        ])
4259                                        .to_matchable(),
4260                                    ])
4261                                    .to_matchable(),
4262                                ])
4263                                .to_matchable(),
4264                                Sequence::new(vec![
4265                                    Ref::keyword("CONTEXT_HEADERS").to_matchable(),
4266                                    Ref::new("EqualsSegment").to_matchable(),
4267                                    Bracketed::new(vec![
4268                                        Delimited::new(vec![
4269                                            Ref::new("ContextHeadersGrammar").to_matchable(),
4270                                        ])
4271                                        .to_matchable(),
4272                                    ])
4273                                    .to_matchable(),
4274                                ])
4275                                .to_matchable(),
4276                                Sequence::new(vec![
4277                                    Ref::keyword("MAX_BATCH_ROWS").to_matchable(),
4278                                    Ref::new("EqualsSegment").to_matchable(),
4279                                    Ref::new("NumericLiteralSegment").to_matchable(),
4280                                ])
4281                                .to_matchable(),
4282                                Sequence::new(vec![
4283                                    Ref::keyword("COMPRESSION").to_matchable(),
4284                                    Ref::new("EqualsSegment").to_matchable(),
4285                                    Ref::new("CompressionType").to_matchable(),
4286                                ])
4287                                .to_matchable(),
4288                                Ref::keyword("SECURE").to_matchable(),
4289                                Sequence::new(vec![
4290                                    one_of(vec![
4291                                        Ref::keyword("REQUEST_TRANSLATOR").to_matchable(),
4292                                        Ref::keyword("RESPONSE_TRANSLATOR").to_matchable(),
4293                                    ])
4294                                    .to_matchable(),
4295                                    Ref::new("EqualsSegment").to_matchable(),
4296                                    Ref::new("FunctionNameSegment").to_matchable(),
4297                                ])
4298                                .to_matchable(),
4299                            ])
4300                            .to_matchable(),
4301                        ])
4302                        .to_matchable(),
4303                        Sequence::new(vec![
4304                            Ref::keyword("UNSET").to_matchable(),
4305                            one_of(vec![
4306                                Ref::keyword("COMMENT").to_matchable(),
4307                                Ref::keyword("HEADERS").to_matchable(),
4308                                Ref::keyword("CONTEXT_HEADERS").to_matchable(),
4309                                Ref::keyword("MAX_BATCH_ROWS").to_matchable(),
4310                                Ref::keyword("COMPRESSION").to_matchable(),
4311                                Ref::keyword("SECURE").to_matchable(),
4312                                Ref::keyword("REQUEST_TRANSLATOR").to_matchable(),
4313                                Ref::keyword("RESPONSE_TRANSLATOR").to_matchable(),
4314                            ])
4315                            .to_matchable(),
4316                        ])
4317                        .to_matchable(),
4318                        Sequence::new(vec![
4319                            Ref::keyword("RENAME").to_matchable(),
4320                            Ref::keyword("TO").to_matchable(),
4321                            Ref::new("SingleIdentifierGrammar").to_matchable(),
4322                        ])
4323                        .to_matchable(),
4324                    ])
4325                    .to_matchable(),
4326                ])
4327                .to_matchable()
4328            })
4329            .to_matchable()
4330            .into(),
4331        ),
4332        (
4333            "CreateExternalFunctionStatementSegment".into(),
4334            NodeMatcher::new(SyntaxKind::CreateExternalFunctionStatement, |_| {
4335                Sequence::new(vec![
4336                    Ref::keyword("CREATE").to_matchable(),
4337                    Sequence::new(vec![
4338                        Ref::keyword("OR").to_matchable(),
4339                        Ref::keyword("REPLACE").to_matchable(),
4340                    ])
4341                    .config(|this| this.optional())
4342                    .to_matchable(),
4343                    Sequence::new(vec![Ref::keyword("SECURE").to_matchable()])
4344                        .config(|this| this.optional())
4345                        .to_matchable(),
4346                    Ref::keyword("EXTERNAL").to_matchable(),
4347                    Ref::keyword("FUNCTION").to_matchable(),
4348                    Ref::new("FunctionNameSegment").to_matchable(),
4349                    Ref::new("FunctionParameterListGrammar").to_matchable(),
4350                    Ref::keyword("RETURNS").to_matchable(),
4351                    Ref::new("DatatypeSegment").to_matchable(),
4352                    Sequence::new(vec![
4353                        Ref::keyword("NOT").optional().to_matchable(),
4354                        Ref::keyword("NULL").to_matchable(),
4355                    ])
4356                    .config(|this| this.optional())
4357                    .to_matchable(),
4358                    one_of(vec![
4359                        Sequence::new(vec![
4360                            Ref::keyword("CALLED").to_matchable(),
4361                            Ref::keyword("ON").to_matchable(),
4362                            Ref::keyword("NULL").to_matchable(),
4363                            Ref::keyword("INPUT").to_matchable(),
4364                        ])
4365                        .to_matchable(),
4366                        Sequence::new(vec![
4367                            Ref::keyword("RETURNS").to_matchable(),
4368                            Ref::keyword("NULL").to_matchable(),
4369                            Ref::keyword("ON").to_matchable(),
4370                            Ref::keyword("NULL").to_matchable(),
4371                            Ref::keyword("INPUT").to_matchable(),
4372                        ])
4373                        .to_matchable(),
4374                        Ref::keyword("STRICT").to_matchable(),
4375                    ])
4376                    .config(|this| this.optional())
4377                    .to_matchable(),
4378                    one_of(vec![
4379                        Ref::keyword("VOLATILE").to_matchable(),
4380                        Ref::keyword("IMMUTABLE").to_matchable(),
4381                    ])
4382                    .config(|this| this.optional())
4383                    .to_matchable(),
4384                    Ref::new("CommentEqualsClauseSegment")
4385                        .optional()
4386                        .to_matchable(),
4387                    Ref::keyword("API_INTEGRATION").to_matchable(),
4388                    Ref::new("EqualsSegment").to_matchable(),
4389                    Ref::new("SingleIdentifierGrammar").to_matchable(),
4390                    Sequence::new(vec![
4391                        Ref::keyword("HEADERS").to_matchable(),
4392                        Ref::new("EqualsSegment").to_matchable(),
4393                        Bracketed::new(vec![
4394                            Delimited::new(vec![
4395                                Sequence::new(vec![
4396                                    Ref::new("SingleQuotedIdentifierSegment").to_matchable(),
4397                                    Ref::new("EqualsSegment").to_matchable(),
4398                                    Ref::new("SingleQuotedIdentifierSegment").to_matchable(),
4399                                ])
4400                                .to_matchable(),
4401                            ])
4402                            .to_matchable(),
4403                        ])
4404                        .to_matchable(),
4405                    ])
4406                    .config(|this| this.optional())
4407                    .to_matchable(),
4408                    Sequence::new(vec![
4409                        Ref::keyword("CONTEXT_HEADERS").to_matchable(),
4410                        Ref::new("EqualsSegment").to_matchable(),
4411                        Bracketed::new(vec![
4412                            Delimited::new(vec![Ref::new("ContextHeadersGrammar").to_matchable()])
4413                                .to_matchable(),
4414                        ])
4415                        .to_matchable(),
4416                    ])
4417                    .config(|this| this.optional())
4418                    .to_matchable(),
4419                    Sequence::new(vec![
4420                        Ref::keyword("MAX_BATCH_ROWS").to_matchable(),
4421                        Ref::new("EqualsSegment").to_matchable(),
4422                        Ref::new("NumericLiteralSegment").to_matchable(),
4423                    ])
4424                    .config(|this| this.optional())
4425                    .to_matchable(),
4426                    Sequence::new(vec![
4427                        Ref::keyword("COMPRESSION").to_matchable(),
4428                        Ref::new("EqualsSegment").to_matchable(),
4429                        Ref::new("CompressionType").to_matchable(),
4430                    ])
4431                    .config(|this| this.optional())
4432                    .to_matchable(),
4433                    Sequence::new(vec![
4434                        Ref::keyword("REQUEST_TRANSLATOR").to_matchable(),
4435                        Ref::new("EqualsSegment").to_matchable(),
4436                        Ref::new("FunctionNameSegment").to_matchable(),
4437                    ])
4438                    .config(|this| this.optional())
4439                    .to_matchable(),
4440                    Sequence::new(vec![
4441                        Ref::keyword("RESPONSE_TRANSLATOR").to_matchable(),
4442                        Ref::new("EqualsSegment").to_matchable(),
4443                        Ref::new("FunctionNameSegment").to_matchable(),
4444                    ])
4445                    .config(|this| this.optional())
4446                    .to_matchable(),
4447                    Ref::keyword("AS").to_matchable(),
4448                    Ref::new("SingleQuotedIdentifierSegment").to_matchable(),
4449                ])
4450                .to_matchable()
4451            })
4452            .to_matchable()
4453            .into(),
4454        ),
4455        (
4456            "WarehouseObjectPropertiesSegment".into(),
4457            NodeMatcher::new(SyntaxKind::WarehouseObjectProperties, |_| {
4458                any_set_of(vec![
4459                    Sequence::new(vec![
4460                        Ref::keyword("WAREHOUSE_TYPE").to_matchable(),
4461                        Ref::new("EqualsSegment").to_matchable(),
4462                        Ref::new("WarehouseType").to_matchable(),
4463                    ])
4464                    .to_matchable(),
4465                    Sequence::new(vec![
4466                        Ref::keyword("WAREHOUSE_SIZE").to_matchable(),
4467                        Ref::new("EqualsSegment").to_matchable(),
4468                        Ref::new("WarehouseSize").to_matchable(),
4469                    ])
4470                    .to_matchable(),
4471                    Sequence::new(vec![
4472                        Ref::keyword("WAIT_FOR_COMPLETION").to_matchable(),
4473                        Ref::new("EqualsSegment").to_matchable(),
4474                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4475                    ])
4476                    .to_matchable(),
4477                    Sequence::new(vec![
4478                        Ref::keyword("MAX_CLUSTER_COUNT").to_matchable(),
4479                        Ref::new("EqualsSegment").to_matchable(),
4480                        Ref::new("NumericLiteralSegment").to_matchable(),
4481                    ])
4482                    .to_matchable(),
4483                    Sequence::new(vec![
4484                        Ref::keyword("MIN_CLUSTER_COUNT").to_matchable(),
4485                        Ref::new("EqualsSegment").to_matchable(),
4486                        Ref::new("NumericLiteralSegment").to_matchable(),
4487                    ])
4488                    .to_matchable(),
4489                    Sequence::new(vec![
4490                        Ref::keyword("SCALING_POLICY").to_matchable(),
4491                        Ref::new("EqualsSegment").to_matchable(),
4492                        Ref::new("ScalingPolicy").to_matchable(),
4493                    ])
4494                    .to_matchable(),
4495                    Sequence::new(vec![
4496                        Ref::keyword("AUTO_SUSPEND").to_matchable(),
4497                        Ref::new("EqualsSegment").to_matchable(),
4498                        one_of(vec![
4499                            Ref::new("NumericLiteralSegment").to_matchable(),
4500                            Ref::keyword("NULL").to_matchable(),
4501                        ])
4502                        .to_matchable(),
4503                    ])
4504                    .to_matchable(),
4505                    Sequence::new(vec![
4506                        Ref::keyword("AUTO_RESUME").to_matchable(),
4507                        Ref::new("EqualsSegment").to_matchable(),
4508                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4509                    ])
4510                    .to_matchable(),
4511                    Sequence::new(vec![
4512                        Ref::keyword("INITIALLY_SUSPENDED").to_matchable(),
4513                        Ref::new("EqualsSegment").to_matchable(),
4514                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4515                    ])
4516                    .to_matchable(),
4517                    Sequence::new(vec![
4518                        Ref::keyword("RESOURCE_MONITOR").to_matchable(),
4519                        Ref::new("EqualsSegment").to_matchable(),
4520                        Ref::new("NakedIdentifierSegment").to_matchable(),
4521                    ])
4522                    .to_matchable(),
4523                ])
4524                .to_matchable()
4525            })
4526            .to_matchable()
4527            .into(),
4528        ),
4529        (
4530            "WarehouseObjectParamsSegment".into(),
4531            NodeMatcher::new(SyntaxKind::WarehouseObjectProperties, |_| {
4532                any_set_of(vec![
4533                    Sequence::new(vec![
4534                        Ref::keyword("MAX_CONCURRENCY_LEVEL").to_matchable(),
4535                        Ref::new("EqualsSegment").to_matchable(),
4536                        Ref::new("NumericLiteralSegment").to_matchable(),
4537                    ])
4538                    .to_matchable(),
4539                    Sequence::new(vec![
4540                        Ref::keyword("STATEMENT_QUEUED_TIMEOUT_IN_SECONDS").to_matchable(),
4541                        Ref::new("EqualsSegment").to_matchable(),
4542                        Ref::new("NumericLiteralSegment").to_matchable(),
4543                    ])
4544                    .to_matchable(),
4545                    Sequence::new(vec![
4546                        Ref::keyword("STATEMENT_TIMEOUT_IN_SECONDS").to_matchable(),
4547                        Ref::new("EqualsSegment").to_matchable(),
4548                        Ref::new("NumericLiteralSegment").to_matchable(),
4549                    ])
4550                    .to_matchable(),
4551                ])
4552                .to_matchable()
4553            })
4554            .to_matchable()
4555            .into(),
4556        ),
4557        (
4558            "ConstraintPropertiesSegment".into(),
4559            NodeMatcher::new(SyntaxKind::ConstraintPropertiesSegment, |_| {
4560                Sequence::new(vec![
4561                    Sequence::new(vec![
4562                        Ref::keyword("CONSTRAINT").to_matchable(),
4563                        Ref::new("QuotedLiteralSegment").to_matchable(),
4564                    ])
4565                    .config(|this| this.optional())
4566                    .to_matchable(),
4567                    one_of(vec![
4568                        Sequence::new(vec![
4569                            Ref::keyword("UNIQUE").to_matchable(),
4570                            Bracketed::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
4571                                .config(|this| this.optional())
4572                                .to_matchable(),
4573                        ])
4574                        .to_matchable(),
4575                        Sequence::new(vec![
4576                            Ref::new("PrimaryKeyGrammar").to_matchable(),
4577                            Bracketed::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
4578                                .config(|this| this.optional())
4579                                .to_matchable(),
4580                        ])
4581                        .to_matchable(),
4582                        Sequence::new(vec![
4583                            Sequence::new(vec![
4584                                Ref::new("ForeignKeyGrammar").to_matchable(),
4585                                Bracketed::new(vec![
4586                                    Ref::new("ColumnReferenceSegment").to_matchable(),
4587                                ])
4588                                .config(|this| this.optional())
4589                                .to_matchable(),
4590                            ])
4591                            .to_matchable(),
4592                            Ref::keyword("REFERENCES").to_matchable(),
4593                            Ref::new("TableReferenceSegment").to_matchable(),
4594                            Bracketed::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
4595                                .to_matchable(),
4596                        ])
4597                        .to_matchable(),
4598                    ])
4599                    .to_matchable(),
4600                    any_set_of(vec![
4601                        one_of(vec![
4602                            Sequence::new(vec![
4603                                Ref::keyword("NOT").optional().to_matchable(),
4604                                Ref::keyword("ENFORCED").to_matchable(),
4605                            ])
4606                            .to_matchable(),
4607                            Sequence::new(vec![
4608                                Ref::keyword("NOT").optional().to_matchable(),
4609                                Ref::keyword("DEFERRABLE").to_matchable(),
4610                            ])
4611                            .to_matchable(),
4612                            Sequence::new(vec![
4613                                Ref::keyword("INITIALLY").to_matchable(),
4614                                one_of(vec![
4615                                    Ref::keyword("DEFERRED").to_matchable(),
4616                                    Ref::keyword("IMMEDIATE").to_matchable(),
4617                                ])
4618                                .to_matchable(),
4619                            ])
4620                            .to_matchable(),
4621                        ])
4622                        .to_matchable(),
4623                    ])
4624                    .to_matchable(),
4625                ])
4626                .to_matchable()
4627            })
4628            .to_matchable()
4629            .into(),
4630        ),
4631    ]);
4632
4633    snowflake_dialect.replace_grammar(
4634        "ColumnConstraintSegment",
4635        any_set_of(vec![
4636            Sequence::new(vec![
4637                Ref::keyword("COLLATE").to_matchable(),
4638                Ref::new("CollationReferenceSegment").to_matchable(),
4639            ])
4640            .to_matchable(),
4641            Sequence::new(vec![
4642                Ref::keyword("DEFAULT").to_matchable(),
4643                Ref::new("ExpressionSegment").to_matchable(),
4644            ])
4645            .to_matchable(),
4646            Sequence::new(vec![
4647                one_of(vec![
4648                    Ref::keyword("AUTOINCREMENT").to_matchable(),
4649                    Ref::keyword("IDENTITY").to_matchable(),
4650                ])
4651                .to_matchable(),
4652                one_of(vec![
4653                    Bracketed::new(vec![
4654                        Delimited::new(vec![Ref::new("NumericLiteralSegment").to_matchable()])
4655                            .to_matchable(),
4656                    ])
4657                    .to_matchable(),
4658                    Sequence::new(vec![
4659                        Ref::keyword("START").to_matchable(),
4660                        Ref::new("NumericLiteralSegment").to_matchable(),
4661                        Ref::keyword("INCREMENT").to_matchable(),
4662                        Ref::new("NumericLiteralSegment").to_matchable(),
4663                    ])
4664                    .to_matchable(),
4665                ])
4666                .config(|this| this.optional())
4667                .to_matchable(),
4668            ])
4669            .to_matchable(),
4670            Sequence::new(vec![
4671                Ref::keyword("NOT").optional().to_matchable(),
4672                Ref::keyword("NULL").to_matchable(),
4673            ])
4674            .to_matchable(),
4675            Sequence::new(vec![
4676                Ref::keyword("WITH").optional().to_matchable(),
4677                Ref::keyword("MASKING").to_matchable(),
4678                Ref::keyword("POLICY").to_matchable(),
4679                Ref::new("FunctionNameSegment").to_matchable(),
4680                Sequence::new(vec![
4681                    Ref::keyword("USING").to_matchable(),
4682                    Bracketed::new(vec![
4683                        Delimited::new(vec![
4684                            one_of(vec![
4685                                Ref::new("ColumnReferenceSegment").to_matchable(),
4686                                Ref::new("ExpressionSegment").to_matchable(),
4687                            ])
4688                            .to_matchable(),
4689                        ])
4690                        .to_matchable(),
4691                    ])
4692                    .to_matchable(),
4693                ])
4694                .config(|this| this.optional())
4695                .to_matchable(),
4696            ])
4697            .to_matchable(),
4698            Ref::new("TagBracketedEqualsSegment")
4699                .optional()
4700                .to_matchable(),
4701            Ref::new("ConstraintPropertiesSegment").to_matchable(),
4702            Sequence::new(vec![
4703                Ref::keyword("CHECK").to_matchable(),
4704                Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()]).to_matchable(),
4705            ])
4706            .to_matchable(),
4707            Sequence::new(vec![
4708                Ref::keyword("REFERENCES").to_matchable(),
4709                Ref::new("ColumnReferenceSegment").to_matchable(),
4710                Ref::new("BracketedColumnReferenceListGrammar")
4711                    .optional()
4712                    .to_matchable(),
4713            ])
4714            .to_matchable(),
4715        ])
4716        .to_matchable(),
4717    );
4718
4719    snowflake_dialect.add([(
4720        "CopyOptionsSegment".into(),
4721        NodeMatcher::new(SyntaxKind::CopyOptions, |_| {
4722            one_of(vec![
4723                any_set_of(vec![
4724                    Sequence::new(vec![
4725                        Ref::keyword("ON_ERROR").to_matchable(),
4726                        Ref::new("EqualsSegment").to_matchable(),
4727                        Ref::new("CopyOptionOnErrorSegment").to_matchable(),
4728                    ])
4729                    .to_matchable(),
4730                    Sequence::new(vec![
4731                        Ref::keyword("SIZE_LIMIT").to_matchable(),
4732                        Ref::new("EqualsSegment").to_matchable(),
4733                        Ref::new("NumericLiteralSegment").to_matchable(),
4734                    ])
4735                    .to_matchable(),
4736                    Sequence::new(vec![
4737                        Ref::keyword("PURGE").to_matchable(),
4738                        Ref::new("EqualsSegment").to_matchable(),
4739                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4740                    ])
4741                    .to_matchable(),
4742                    Sequence::new(vec![
4743                        Ref::keyword("RETURN_FAILED_ONLY").to_matchable(),
4744                        Ref::new("EqualsSegment").to_matchable(),
4745                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4746                    ])
4747                    .to_matchable(),
4748                    Sequence::new(vec![
4749                        Ref::keyword("MATCH_BY_COLUMN_NAME").to_matchable(),
4750                        Ref::new("EqualsSegment").to_matchable(),
4751                        one_of(vec![
4752                            Ref::keyword("CASE_SENSITIVE").to_matchable(),
4753                            Ref::keyword("CASE_INSENSITIVE").to_matchable(),
4754                            Ref::keyword("NONE").to_matchable(),
4755                        ])
4756                        .to_matchable(),
4757                    ])
4758                    .to_matchable(),
4759                    Sequence::new(vec![
4760                        Ref::keyword("ENFORCE_LENGTH").to_matchable(),
4761                        Ref::new("EqualsSegment").to_matchable(),
4762                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4763                    ])
4764                    .to_matchable(),
4765                    Sequence::new(vec![
4766                        Ref::keyword("TRUNCATECOLUMNS").to_matchable(),
4767                        Ref::new("EqualsSegment").to_matchable(),
4768                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4769                    ])
4770                    .to_matchable(),
4771                    Sequence::new(vec![
4772                        Ref::keyword("FORCE").to_matchable(),
4773                        Ref::new("EqualsSegment").to_matchable(),
4774                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4775                    ])
4776                    .to_matchable(),
4777                ])
4778                .to_matchable(),
4779                any_set_of(vec![
4780                    Sequence::new(vec![
4781                        Ref::keyword("OVERWRITE").to_matchable(),
4782                        Ref::new("EqualsSegment").to_matchable(),
4783                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4784                    ])
4785                    .to_matchable(),
4786                    Sequence::new(vec![
4787                        Ref::keyword("SINGLE").to_matchable(),
4788                        Ref::new("EqualsSegment").to_matchable(),
4789                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4790                    ])
4791                    .to_matchable(),
4792                    Sequence::new(vec![
4793                        Ref::keyword("MAX_FILE_SIZE").to_matchable(),
4794                        Ref::new("EqualsSegment").to_matchable(),
4795                        Ref::new("NumericLiteralSegment").to_matchable(),
4796                    ])
4797                    .to_matchable(),
4798                    Sequence::new(vec![
4799                        Ref::keyword("INCLUDE_QUERY_ID").to_matchable(),
4800                        Ref::new("EqualsSegment").to_matchable(),
4801                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4802                    ])
4803                    .to_matchable(),
4804                    Sequence::new(vec![
4805                        Ref::keyword("DETAILED_OUTPUT").to_matchable(),
4806                        Ref::new("EqualsSegment").to_matchable(),
4807                        Ref::new("BooleanLiteralGrammar").to_matchable(),
4808                    ])
4809                    .to_matchable(),
4810                ])
4811                .to_matchable(),
4812            ])
4813            .to_matchable()
4814        })
4815        .to_matchable()
4816        .into(),
4817    )]);
4818
4819    snowflake_dialect.replace_grammar(
4820        "CreateSchemaStatementSegment",
4821        Sequence::new(vec![
4822            Ref::keyword("CREATE").to_matchable(),
4823            Ref::new("OrReplaceGrammar").optional().to_matchable(),
4824            Ref::new("TemporaryTransientGrammar")
4825                .optional()
4826                .to_matchable(),
4827            Ref::keyword("SCHEMA").to_matchable(),
4828            Ref::new("IfNotExistsGrammar").optional().to_matchable(),
4829            Ref::new("SchemaReferenceSegment").to_matchable(),
4830            Sequence::new(vec![
4831                Ref::keyword("WITH").to_matchable(),
4832                Ref::keyword("MANAGED").to_matchable(),
4833                Ref::keyword("ACCESS").to_matchable(),
4834            ])
4835            .config(|this| this.optional())
4836            .to_matchable(),
4837            Ref::new("SchemaObjectParamsSegment")
4838                .optional()
4839                .to_matchable(),
4840            Ref::new("TagBracketedEqualsSegment")
4841                .optional()
4842                .to_matchable(),
4843        ])
4844        .to_matchable(),
4845    );
4846
4847    snowflake_dialect.add([
4848        (
4849            "AlterRoleStatementSegment".into(),
4850            NodeMatcher::new(SyntaxKind::AlterRoleStatement, |_| {
4851                Sequence::new(vec![
4852                    Ref::keyword("ALTER").to_matchable(),
4853                    Ref::keyword("ROLE").to_matchable(),
4854                    Ref::new("IfExistsGrammar").optional().to_matchable(),
4855                    Ref::new("RoleReferenceSegment").to_matchable(),
4856                    one_of(vec![
4857                        Sequence::new(vec![
4858                            Ref::keyword("SET").to_matchable(),
4859                            one_of(vec![
4860                                Ref::new("RoleReferenceSegment").to_matchable(),
4861                                Ref::new("TagEqualsSegment").to_matchable(),
4862                                Sequence::new(vec![
4863                                    Ref::keyword("COMMENT").to_matchable(),
4864                                    Ref::new("EqualsSegment").to_matchable(),
4865                                    Ref::new("QuotedLiteralSegment").to_matchable(),
4866                                ])
4867                                .to_matchable(),
4868                            ])
4869                            .to_matchable(),
4870                        ])
4871                        .to_matchable(),
4872                        Sequence::new(vec![
4873                            Ref::keyword("UNSET").to_matchable(),
4874                            one_of(vec![
4875                                Ref::new("RoleReferenceSegment").to_matchable(),
4876                                Sequence::new(vec![
4877                                    Ref::keyword("TAG").to_matchable(),
4878                                    Delimited::new(vec![
4879                                        Ref::new("TagReferenceSegment").to_matchable(),
4880                                    ])
4881                                    .to_matchable(),
4882                                ])
4883                                .to_matchable(),
4884                                Sequence::new(vec![Ref::keyword("COMMENT").to_matchable()])
4885                                    .to_matchable(),
4886                            ])
4887                            .to_matchable(),
4888                        ])
4889                        .to_matchable(),
4890                        Sequence::new(vec![
4891                            Ref::keyword("RENAME").to_matchable(),
4892                            Ref::keyword("TO").to_matchable(),
4893                            one_of(vec![Ref::new("RoleReferenceSegment").to_matchable()])
4894                                .to_matchable(),
4895                        ])
4896                        .to_matchable(),
4897                    ])
4898                    .to_matchable(),
4899                ])
4900                .to_matchable()
4901            })
4902            .to_matchable()
4903            .into(),
4904        ),
4905        (
4906            "AlterSchemaStatementSegment".into(),
4907            NodeMatcher::new(SyntaxKind::AlterSchemaStatement, |_| {
4908                Sequence::new(vec![
4909                    Ref::keyword("ALTER").to_matchable(),
4910                    Ref::keyword("SCHEMA").to_matchable(),
4911                    Sequence::new(vec![
4912                        Ref::keyword("IF").to_matchable(),
4913                        Ref::keyword("EXISTS").to_matchable(),
4914                    ])
4915                    .config(|this| this.optional())
4916                    .to_matchable(),
4917                    Ref::new("SchemaReferenceSegment").to_matchable(),
4918                    one_of(vec![
4919                        Sequence::new(vec![
4920                            Ref::keyword("RENAME").to_matchable(),
4921                            Ref::keyword("TO").to_matchable(),
4922                            Ref::new("SchemaReferenceSegment").to_matchable(),
4923                        ])
4924                        .to_matchable(),
4925                        Sequence::new(vec![
4926                            Ref::keyword("SWAP").to_matchable(),
4927                            Ref::keyword("WITH").to_matchable(),
4928                            Ref::new("SchemaReferenceSegment").to_matchable(),
4929                        ])
4930                        .to_matchable(),
4931                        Sequence::new(vec![
4932                            Ref::keyword("SET").to_matchable(),
4933                            one_of(vec![
4934                                Ref::new("SchemaObjectParamsSegment").to_matchable(),
4935                                Ref::new("TagEqualsSegment").to_matchable(),
4936                            ])
4937                            .to_matchable(),
4938                        ])
4939                        .to_matchable(),
4940                        Sequence::new(vec![
4941                            Ref::keyword("UNSET").to_matchable(),
4942                            one_of(vec![
4943                                Delimited::new(vec![
4944                                    Ref::keyword("DATA_RETENTION_TIME_IN_DAYS").to_matchable(),
4945                                    Ref::keyword("MAX_DATA_EXTENSION_TIME_IN_DAYS").to_matchable(),
4946                                    Ref::keyword("DEFAULT_DDL_COLLATION").to_matchable(),
4947                                    Ref::keyword("COMMENT").to_matchable(),
4948                                ])
4949                                .to_matchable(),
4950                                Sequence::new(vec![
4951                                    Ref::keyword("TAG").to_matchable(),
4952                                    Delimited::new(vec![
4953                                        Ref::new("TagReferenceSegment").to_matchable(),
4954                                    ])
4955                                    .to_matchable(),
4956                                ])
4957                                .to_matchable(),
4958                            ])
4959                            .to_matchable(),
4960                        ])
4961                        .to_matchable(),
4962                        Sequence::new(vec![
4963                            one_of(vec![
4964                                Ref::keyword("ENABLE").to_matchable(),
4965                                Ref::keyword("DISABLE").to_matchable(),
4966                            ])
4967                            .to_matchable(),
4968                            Sequence::new(vec![
4969                                Ref::keyword("MANAGED").to_matchable(),
4970                                Ref::keyword("ACCESS").to_matchable(),
4971                            ])
4972                            .to_matchable(),
4973                        ])
4974                        .to_matchable(),
4975                    ])
4976                    .to_matchable(),
4977                ])
4978                .to_matchable()
4979            })
4980            .to_matchable()
4981            .into(),
4982        ),
4983        (
4984            "SchemaObjectParamsSegment".into(),
4985            NodeMatcher::new(SyntaxKind::SchemaObjectProperties, |_| {
4986                any_set_of(vec![
4987                    Sequence::new(vec![
4988                        Ref::keyword("DATA_RETENTION_TIME_IN_DAYS").to_matchable(),
4989                        Ref::new("EqualsSegment").to_matchable(),
4990                        Ref::new("NumericLiteralSegment").to_matchable(),
4991                    ])
4992                    .to_matchable(),
4993                    Sequence::new(vec![
4994                        Ref::keyword("MAX_DATA_EXTENSION_TIME_IN_DAYS").to_matchable(),
4995                        Ref::new("EqualsSegment").to_matchable(),
4996                        Ref::new("NumericLiteralSegment").to_matchable(),
4997                    ])
4998                    .to_matchable(),
4999                    Sequence::new(vec![
5000                        Ref::keyword("DEFAULT_DDL_COLLATION").to_matchable(),
5001                        Ref::new("EqualsSegment").to_matchable(),
5002                        Ref::new("QuotedLiteralSegment").to_matchable(),
5003                    ])
5004                    .to_matchable(),
5005                    Ref::new("CommentEqualsClauseSegment").to_matchable(),
5006                ])
5007                .to_matchable()
5008            })
5009            .to_matchable()
5010            .into(),
5011        ),
5012    ]);
5013
5014    snowflake_dialect.replace_grammar(
5015        "CreateTableStatementSegment",
5016        Sequence::new(vec![
5017            Ref::keyword("CREATE").to_matchable(),
5018            Ref::new("OrReplaceGrammar").optional().to_matchable(),
5019            Ref::new("TemporaryTransientGrammar")
5020                .optional()
5021                .to_matchable(),
5022            Ref::keyword("TABLE").to_matchable(),
5023            Ref::new("IfNotExistsGrammar").optional().to_matchable(),
5024            Ref::new("TableReferenceSegment").to_matchable(),
5025            any_set_of(vec![
5026                Sequence::new(vec![
5027                    Bracketed::new(vec![
5028                        Delimited::new(vec![
5029                            Sequence::new(vec![
5030                                one_of(vec![
5031                                    Ref::new("TableConstraintSegment").to_matchable(),
5032                                    Ref::new("ColumnDefinitionSegment").to_matchable(),
5033                                    Ref::new("SingleIdentifierGrammar").to_matchable(),
5034                                ])
5035                                .to_matchable(),
5036                                Ref::new("CommentClauseSegment").optional().to_matchable(),
5037                            ])
5038                            .to_matchable(),
5039                        ])
5040                        .to_matchable(),
5041                    ])
5042                    .to_matchable(),
5043                ])
5044                .config(|this| this.optional())
5045                .to_matchable(),
5046                Sequence::new(vec![
5047                    Ref::keyword("CLUSTER").to_matchable(),
5048                    Ref::keyword("BY").to_matchable(),
5049                    one_of(vec![
5050                        Ref::new("FunctionSegment").to_matchable(),
5051                        Bracketed::new(vec![
5052                            Delimited::new(vec![Ref::new("ExpressionSegment").to_matchable()])
5053                                .to_matchable(),
5054                        ])
5055                        .to_matchable(),
5056                    ])
5057                    .to_matchable(),
5058                ])
5059                .config(|this| this.optional())
5060                .to_matchable(),
5061                Sequence::new(vec![
5062                    Ref::keyword("STAGE_FILE_FORMAT").to_matchable(),
5063                    Ref::new("EqualsSegment").to_matchable(),
5064                    Ref::new("FileFormatSegment").to_matchable(),
5065                ])
5066                .config(|this| this.optional())
5067                .to_matchable(),
5068                Sequence::new(vec![
5069                    Ref::keyword("STAGE_COPY_OPTIONS").to_matchable(),
5070                    Ref::new("EqualsSegment").to_matchable(),
5071                    Bracketed::new(vec![Ref::new("CopyOptionsSegment").to_matchable()])
5072                        .to_matchable(),
5073                ])
5074                .config(|this| this.optional())
5075                .to_matchable(),
5076                Sequence::new(vec![
5077                    Ref::keyword("DATA_RETENTION_TIME_IN_DAYS").to_matchable(),
5078                    Ref::new("EqualsSegment").to_matchable(),
5079                    Ref::new("NumericLiteralSegment").to_matchable(),
5080                ])
5081                .config(|this| this.optional())
5082                .to_matchable(),
5083                Sequence::new(vec![
5084                    Ref::keyword("MAX_DATA_EXTENSION_TIME_IN_DAYS").to_matchable(),
5085                    Ref::new("EqualsSegment").to_matchable(),
5086                    Ref::new("NumericLiteralSegment").to_matchable(),
5087                ])
5088                .config(|this| this.optional())
5089                .to_matchable(),
5090                Sequence::new(vec![
5091                    Ref::keyword("CHANGE_TRACKING").to_matchable(),
5092                    Ref::new("EqualsSegment").to_matchable(),
5093                    Ref::new("BooleanLiteralGrammar").to_matchable(),
5094                ])
5095                .config(|this| this.optional())
5096                .to_matchable(),
5097                Sequence::new(vec![
5098                    Ref::keyword("DEFAULT_DDL_COLLATION").to_matchable(),
5099                    Ref::new("EqualsSegment").to_matchable(),
5100                    Ref::new("QuotedLiteralGrammar").to_matchable(),
5101                ])
5102                .config(|this| this.optional())
5103                .to_matchable(),
5104                Sequence::new(vec![
5105                    Ref::keyword("COPY").to_matchable(),
5106                    Ref::keyword("GRANTS").to_matchable(),
5107                ])
5108                .config(|this| this.optional())
5109                .to_matchable(),
5110                Sequence::new(vec![
5111                    Ref::keyword("WITH").optional().to_matchable(),
5112                    Ref::keyword("ROW").to_matchable(),
5113                    Ref::keyword("ACCESS").to_matchable(),
5114                    Ref::keyword("POLICY").to_matchable(),
5115                    Ref::new("NakedIdentifierSegment").to_matchable(),
5116                    Ref::keyword("ON").to_matchable(),
5117                    Bracketed::new(vec![
5118                        Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
5119                            .to_matchable(),
5120                    ])
5121                    .to_matchable(),
5122                ])
5123                .config(|this| this.optional())
5124                .to_matchable(),
5125                Ref::new("TagBracketedEqualsSegment")
5126                    .optional()
5127                    .to_matchable(),
5128                Ref::new("CommentEqualsClauseSegment")
5129                    .optional()
5130                    .to_matchable(),
5131                one_of(vec![
5132                    Sequence::new(vec![
5133                        Ref::keyword("AS").to_matchable(),
5134                        optionally_bracketed(vec![Ref::new("SelectableGrammar").to_matchable()])
5135                            .to_matchable(),
5136                    ])
5137                    .to_matchable(),
5138                    Sequence::new(vec![
5139                        Ref::keyword("LIKE").to_matchable(),
5140                        Ref::new("TableReferenceSegment").to_matchable(),
5141                    ])
5142                    .to_matchable(),
5143                    Sequence::new(vec![
5144                        Ref::keyword("CLONE").to_matchable(),
5145                        Ref::new("TableReferenceSegment").to_matchable(),
5146                    ])
5147                    .to_matchable(),
5148                    Sequence::new(vec![
5149                        Ref::keyword("USING").to_matchable(),
5150                        Ref::keyword("TEMPLATE").to_matchable(),
5151                        Ref::new("SelectableGrammar").to_matchable(),
5152                    ])
5153                    .to_matchable(),
5154                ])
5155                .config(|this| this.optional())
5156                .to_matchable(),
5157            ])
5158            .to_matchable(),
5159        ])
5160        .to_matchable(),
5161    );
5162
5163    snowflake_dialect.add([
5164        (
5165            "CreateTaskSegment".into(),
5166            NodeMatcher::new(SyntaxKind::CreateTaskStatement, |_| {
5167                Sequence::new(vec![
5168                    Ref::keyword("CREATE").to_matchable(),
5169                    Sequence::new(vec![
5170                        Ref::keyword("OR").to_matchable(),
5171                        Ref::keyword("REPLACE").to_matchable(),
5172                    ])
5173                    .config(|this| this.optional())
5174                    .to_matchable(),
5175                    Ref::keyword("TASK").to_matchable(),
5176                    Sequence::new(vec![
5177                        Ref::keyword("IF").to_matchable(),
5178                        Ref::keyword("NOT").to_matchable(),
5179                        Ref::keyword("EXISTS").to_matchable(),
5180                    ])
5181                    .config(|this| this.optional())
5182                    .to_matchable(),
5183                    Ref::new("ObjectReferenceSegment").to_matchable(),
5184                    MetaSegment::indent().to_matchable(),
5185                    AnyNumberOf::new(vec![
5186                        one_of(vec![
5187                            Sequence::new(vec![
5188                                Ref::keyword("WAREHOUSE").to_matchable(),
5189                                Ref::new("EqualsSegment").to_matchable(),
5190                                Ref::new("ObjectReferenceSegment").to_matchable(),
5191                            ])
5192                            .to_matchable(),
5193                            Sequence::new(vec![
5194                                Ref::keyword("USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE")
5195                                    .to_matchable(),
5196                                Ref::new("EqualsSegment").to_matchable(),
5197                                Ref::new("WarehouseSize").to_matchable(),
5198                            ])
5199                            .to_matchable(),
5200                        ])
5201                        .to_matchable(),
5202                        Sequence::new(vec![
5203                            Ref::keyword("SCHEDULE").to_matchable(),
5204                            Ref::new("EqualsSegment").to_matchable(),
5205                            Ref::new("QuotedLiteralSegment").to_matchable(),
5206                        ])
5207                        .to_matchable(),
5208                        Sequence::new(vec![
5209                            Ref::keyword("ALLOW_OVERLAPPING_EXECUTION").to_matchable(),
5210                            Ref::new("EqualsSegment").to_matchable(),
5211                            Ref::new("BooleanLiteralGrammar").to_matchable(),
5212                        ])
5213                        .to_matchable(),
5214                        Sequence::new(vec![
5215                            Ref::keyword("USER_TASK_TIMEOUT_MS").to_matchable(),
5216                            Ref::new("EqualsSegment").to_matchable(),
5217                            Ref::new("NumericLiteralSegment").to_matchable(),
5218                        ])
5219                        .to_matchable(),
5220                        Delimited::new(vec![
5221                            Sequence::new(vec![
5222                                Ref::new("ParameterNameSegment").to_matchable(),
5223                                Ref::new("EqualsSegment").to_matchable(),
5224                                one_of(vec![
5225                                    Ref::new("BooleanLiteralGrammar").to_matchable(),
5226                                    Ref::new("QuotedLiteralSegment").to_matchable(),
5227                                    Ref::new("NumericLiteralSegment").to_matchable(),
5228                                ])
5229                                .to_matchable(),
5230                            ])
5231                            .to_matchable(),
5232                        ])
5233                        .to_matchable(),
5234                        Sequence::new(vec![
5235                            Ref::keyword("COPY").to_matchable(),
5236                            Ref::keyword("GRANTS").to_matchable(),
5237                        ])
5238                        .to_matchable(),
5239                        Ref::new("CommentEqualsClauseSegment").to_matchable(),
5240                    ])
5241                    .to_matchable(),
5242                    Sequence::new(vec![
5243                        Ref::keyword("AFTER").to_matchable(),
5244                        Ref::new("ObjectReferenceSegment").to_matchable(),
5245                    ])
5246                    .config(|this| this.optional())
5247                    .to_matchable(),
5248                    MetaSegment::dedent().to_matchable(),
5249                    Sequence::new(vec![
5250                        Ref::keyword("WHEN").to_matchable(),
5251                        MetaSegment::indent().to_matchable(),
5252                        Ref::new("TaskExpressionSegment").to_matchable(),
5253                        MetaSegment::dedent().to_matchable(),
5254                    ])
5255                    .config(|this| this.optional())
5256                    .to_matchable(),
5257                    Sequence::new(vec![
5258                        Ref::keyword("AS").to_matchable(),
5259                        MetaSegment::indent().to_matchable(),
5260                        Ref::new("StatementSegment").to_matchable(),
5261                        MetaSegment::dedent().to_matchable(),
5262                    ])
5263                    .to_matchable(),
5264                ])
5265                .to_matchable()
5266            })
5267            .to_matchable()
5268            .into(),
5269        ),
5270        (
5271            "TaskExpressionSegment".into(),
5272            NodeMatcher::new(SyntaxKind::SnowflakeTaskExpressionSegment, |_| {
5273                Sequence::new(vec![
5274                    Delimited::new(vec![
5275                        one_of(vec![
5276                            Ref::new("ExpressionSegment").to_matchable(),
5277                            Sequence::new(vec![
5278                                Ref::new("SystemFunctionName").to_matchable(),
5279                                Bracketed::new(vec![
5280                                    Ref::new("QuotedLiteralSegment").to_matchable(),
5281                                ])
5282                                .to_matchable(),
5283                            ])
5284                            .to_matchable(),
5285                        ])
5286                        .to_matchable(),
5287                    ])
5288                    .config(|this| {
5289                        this.delimiter(one_of(vec![
5290                            Ref::new("BooleanBinaryOperatorGrammar").to_matchable(),
5291                        ]))
5292                    })
5293                    .to_matchable(),
5294                ])
5295                .to_matchable()
5296            })
5297            .to_matchable()
5298            .into(),
5299        ),
5300        (
5301            "CreateStatementSegment".into(),
5302            NodeMatcher::new(SyntaxKind::CreateStatement, |_| {
5303                Sequence::new(vec![
5304                    Ref::keyword("CREATE").to_matchable(),
5305                    Ref::new("OrReplaceGrammar").optional().to_matchable(),
5306                    one_of(vec![
5307                        Sequence::new(vec![
5308                            Ref::keyword("NETWORK").to_matchable(),
5309                            Ref::keyword("POLICY").to_matchable(),
5310                        ])
5311                        .to_matchable(),
5312                        Sequence::new(vec![
5313                            Ref::keyword("RESOURCE").to_matchable(),
5314                            Ref::keyword("MONITOR").to_matchable(),
5315                        ])
5316                        .to_matchable(),
5317                        Ref::keyword("SHARE").to_matchable(),
5318                        Ref::keyword("ROLE").to_matchable(),
5319                        Ref::keyword("USER").to_matchable(),
5320                        Ref::keyword("TAG").to_matchable(),
5321                        Ref::keyword("WAREHOUSE").to_matchable(),
5322                        Sequence::new(vec![
5323                            Ref::keyword("NOTIFICATION").to_matchable(),
5324                            Ref::keyword("INTEGRATION").to_matchable(),
5325                        ])
5326                        .to_matchable(),
5327                        Sequence::new(vec![
5328                            Ref::keyword("SECURITY").to_matchable(),
5329                            Ref::keyword("INTEGRATION").to_matchable(),
5330                        ])
5331                        .to_matchable(),
5332                        Sequence::new(vec![
5333                            Ref::keyword("STORAGE").to_matchable(),
5334                            Ref::keyword("INTEGRATION").to_matchable(),
5335                        ])
5336                        .to_matchable(),
5337                        Sequence::new(vec![
5338                            Ref::keyword("MATERIALIZED").to_matchable(),
5339                            Ref::keyword("VIEW").to_matchable(),
5340                        ])
5341                        .to_matchable(),
5342                        Sequence::new(vec![
5343                            Ref::keyword("MASKING").to_matchable(),
5344                            Ref::keyword("POLICY").to_matchable(),
5345                        ])
5346                        .to_matchable(),
5347                        Ref::keyword("PIPE").to_matchable(),
5348                        Sequence::new(vec![
5349                            Ref::keyword("EXTERNAL").to_matchable(),
5350                            Ref::keyword("FUNCTION").to_matchable(),
5351                        ])
5352                        .to_matchable(),
5353                        Ref::keyword("DATABASE").to_matchable(),
5354                        Ref::keyword("SEQUENCE").to_matchable(),
5355                    ])
5356                    .to_matchable(),
5357                    Ref::new("IfNotExistsGrammar").optional().to_matchable(),
5358                    Ref::new("ObjectReferenceSegment").to_matchable(),
5359                    any_set_of(vec![
5360                        Sequence::new(vec![
5361                            Ref::keyword("TYPE").to_matchable(),
5362                            Ref::new("EqualsSegment").to_matchable(),
5363                            Ref::keyword("QUEUE").to_matchable(),
5364                        ])
5365                        .to_matchable(),
5366                        Sequence::new(vec![
5367                            Ref::keyword("ENABLED").to_matchable(),
5368                            Ref::new("EqualsSegment").to_matchable(),
5369                            Ref::new("BooleanLiteralGrammar").to_matchable(),
5370                        ])
5371                        .to_matchable(),
5372                        Sequence::new(vec![
5373                            Ref::keyword("NOTIFICATION_PROVIDER").to_matchable(),
5374                            Ref::new("EqualsSegment").to_matchable(),
5375                            one_of(vec![
5376                                Ref::keyword("AWS_SNS").to_matchable(),
5377                                Ref::keyword("AZURE_EVENT_GRID").to_matchable(),
5378                                Ref::keyword("GCP_PUBSUB").to_matchable(),
5379                                Ref::keyword("AZURE_STORAGE_QUEUE").to_matchable(),
5380                                Ref::new("QuotedLiteralSegment").to_matchable(),
5381                            ])
5382                            .to_matchable(),
5383                        ])
5384                        .to_matchable(),
5385                        Sequence::new(vec![
5386                            Ref::keyword("AWS_SNS_TOPIC_ARN").to_matchable(),
5387                            Ref::new("EqualsSegment").to_matchable(),
5388                            Ref::new("QuotedLiteralSegment").to_matchable(),
5389                        ])
5390                        .to_matchable(),
5391                        Sequence::new(vec![
5392                            Ref::keyword("AWS_SNS_ROLE_ARN").to_matchable(),
5393                            Ref::new("EqualsSegment").to_matchable(),
5394                            Ref::new("QuotedLiteralSegment").to_matchable(),
5395                        ])
5396                        .to_matchable(),
5397                        Sequence::new(vec![
5398                            Ref::keyword("AZURE_TENANT_ID").to_matchable(),
5399                            Ref::new("EqualsSegment").to_matchable(),
5400                            Ref::new("QuotedLiteralSegment").to_matchable(),
5401                        ])
5402                        .to_matchable(),
5403                        one_of(vec![
5404                            Sequence::new(vec![
5405                                Ref::keyword("AZURE_STORAGE_QUEUE_PRIMARY_URI").to_matchable(),
5406                                Ref::new("EqualsSegment").to_matchable(),
5407                                Ref::new("QuotedLiteralSegment").to_matchable(),
5408                            ])
5409                            .to_matchable(),
5410                            Sequence::new(vec![
5411                                Ref::keyword("AZURE_EVENT_GRID_TOPIC_ENDPOINT").to_matchable(),
5412                                Ref::new("EqualsSegment").to_matchable(),
5413                                Ref::new("QuotedLiteralSegment").to_matchable(),
5414                            ])
5415                            .to_matchable(),
5416                        ])
5417                        .to_matchable(),
5418                        one_of(vec![
5419                            Sequence::new(vec![
5420                                Ref::keyword("GCP_PUBSUB_SUBSCRIPTION_NAME").to_matchable(),
5421                                Ref::new("EqualsSegment").to_matchable(),
5422                                Ref::new("QuotedLiteralSegment").to_matchable(),
5423                            ])
5424                            .to_matchable(),
5425                            Sequence::new(vec![
5426                                Ref::keyword("GCP_PUBSUB_TOPIC_NAME").to_matchable(),
5427                                Ref::new("EqualsSegment").to_matchable(),
5428                                Ref::new("QuotedLiteralSegment").to_matchable(),
5429                            ])
5430                            .to_matchable(),
5431                        ])
5432                        .to_matchable(),
5433                        Sequence::new(vec![
5434                            Ref::keyword("DIRECTION").to_matchable(),
5435                            Ref::new("EqualsSegment").to_matchable(),
5436                            Ref::keyword("OUTBOUND").to_matchable(),
5437                        ])
5438                        .config(|this| this.optional())
5439                        .to_matchable(),
5440                        Sequence::new(vec![
5441                            Ref::keyword("COMMENT").to_matchable(),
5442                            Ref::new("EqualsSegment").to_matchable(),
5443                            Ref::new("QuotedLiteralSegment").to_matchable(),
5444                        ])
5445                        .to_matchable(),
5446                        Sequence::new(vec![
5447                            Ref::keyword("ALLOWED_VALUES").to_matchable(),
5448                            Delimited::new(vec![Ref::new("QuotedLiteralSegment").to_matchable()])
5449                                .to_matchable(),
5450                        ])
5451                        .to_matchable(),
5452                        Sequence::new(vec![
5453                            Ref::keyword("ALLOWED_IP_LIST").to_matchable(),
5454                            Ref::new("EqualsSegment").to_matchable(),
5455                            Bracketed::new(vec![
5456                                Delimited::new(vec![
5457                                    Ref::new("QuotedLiteralSegment").to_matchable(),
5458                                ])
5459                                .to_matchable(),
5460                            ])
5461                            .to_matchable(),
5462                        ])
5463                        .to_matchable(),
5464                        Sequence::new(vec![
5465                            Ref::keyword("BLOCKED_IP_LIST").to_matchable(),
5466                            Ref::new("EqualsSegment").to_matchable(),
5467                            Bracketed::new(vec![
5468                                Delimited::new(vec![
5469                                    Ref::new("QuotedLiteralSegment").to_matchable(),
5470                                ])
5471                                .to_matchable(),
5472                            ])
5473                            .to_matchable(),
5474                        ])
5475                        .to_matchable(),
5476                    ])
5477                    .to_matchable(),
5478                    any_set_of(vec![
5479                        Sequence::new(vec![
5480                            Ref::keyword("TYPE").to_matchable(),
5481                            Ref::new("EqualsSegment").to_matchable(),
5482                            Ref::keyword("EXTERNAL_STAGE").to_matchable(),
5483                        ])
5484                        .to_matchable(),
5485                        Sequence::new(vec![
5486                            Ref::keyword("ENABLED").to_matchable(),
5487                            Ref::new("EqualsSegment").to_matchable(),
5488                            Ref::new("BooleanLiteralGrammar").to_matchable(),
5489                        ])
5490                        .to_matchable(),
5491                        Sequence::new(vec![
5492                            Ref::keyword("STORAGE_PROVIDER").to_matchable(),
5493                            Ref::new("EqualsSegment").to_matchable(),
5494                            one_of(vec![
5495                                Ref::keyword("S3").to_matchable(),
5496                                Ref::keyword("AZURE").to_matchable(),
5497                                Ref::keyword("GCS").to_matchable(),
5498                                Ref::new("QuotedLiteralSegment").to_matchable(),
5499                            ])
5500                            .to_matchable(),
5501                        ])
5502                        .to_matchable(),
5503                        Sequence::new(vec![
5504                            Ref::keyword("AZURE_TENANT_ID").to_matchable(),
5505                            Ref::new("EqualsSegment").to_matchable(),
5506                            Ref::new("QuotedLiteralSegment").to_matchable(),
5507                        ])
5508                        .to_matchable(),
5509                        Sequence::new(vec![
5510                            Ref::keyword("STORAGE_AWS_ROLE_ARN").to_matchable(),
5511                            Ref::new("EqualsSegment").to_matchable(),
5512                            Ref::new("QuotedLiteralSegment").to_matchable(),
5513                        ])
5514                        .to_matchable(),
5515                        Sequence::new(vec![
5516                            Ref::keyword("STORAGE_AWS_OBJECT_ACL").to_matchable(),
5517                            Ref::new("EqualsSegment").to_matchable(),
5518                            StringParser::new("'bucket-owner-full-control'", SyntaxKind::Literal)
5519                                .to_matchable(),
5520                        ])
5521                        .to_matchable(),
5522                        Sequence::new(vec![
5523                            Ref::keyword("STORAGE_ALLOWED_LOCATIONS").to_matchable(),
5524                            Ref::new("EqualsSegment").to_matchable(),
5525                            one_of(vec![
5526                                Bracketed::new(vec![
5527                                    Delimited::new(vec![
5528                                        one_of(vec![
5529                                            Ref::new("S3Path").to_matchable(),
5530                                            Ref::new("GCSPath").to_matchable(),
5531                                            Ref::new("AzureBlobStoragePath").to_matchable(),
5532                                        ])
5533                                        .to_matchable(),
5534                                    ])
5535                                    .to_matchable(),
5536                                ])
5537                                .to_matchable(),
5538                                Bracketed::new(vec![Ref::new("QuotedStarSegment").to_matchable()])
5539                                    .to_matchable(),
5540                            ])
5541                            .to_matchable(),
5542                        ])
5543                        .to_matchable(),
5544                        Sequence::new(vec![
5545                            Ref::keyword("STORAGE_BLOCKED_LOCATIONS").to_matchable(),
5546                            Ref::new("EqualsSegment").to_matchable(),
5547                            Bracketed::new(vec![
5548                                Delimited::new(vec![
5549                                    one_of(vec![
5550                                        Ref::new("S3Path").to_matchable(),
5551                                        Ref::new("GCSPath").to_matchable(),
5552                                        Ref::new("AzureBlobStoragePath").to_matchable(),
5553                                    ])
5554                                    .to_matchable(),
5555                                ])
5556                                .to_matchable(),
5557                            ])
5558                            .to_matchable(),
5559                        ])
5560                        .to_matchable(),
5561                        Sequence::new(vec![
5562                            Ref::keyword("COMMENT").to_matchable(),
5563                            Ref::new("EqualsSegment").to_matchable(),
5564                            Ref::new("QuotedLiteralSegment").to_matchable(),
5565                        ])
5566                        .to_matchable(),
5567                    ])
5568                    .to_matchable(),
5569                    Sequence::new(vec![
5570                        Sequence::new(vec![
5571                            Ref::keyword("AUTO_INGEST").to_matchable(),
5572                            Ref::new("EqualsSegment").to_matchable(),
5573                            Ref::new("BooleanLiteralGrammar").to_matchable(),
5574                        ])
5575                        .config(|this| this.optional())
5576                        .to_matchable(),
5577                        Sequence::new(vec![
5578                            Ref::keyword("ERROR_INTEGRATION").to_matchable(),
5579                            Ref::new("EqualsSegment").to_matchable(),
5580                            Ref::new("ObjectReferenceSegment").to_matchable(),
5581                        ])
5582                        .config(|this| this.optional())
5583                        .to_matchable(),
5584                        Sequence::new(vec![
5585                            Ref::keyword("AWS_SNS_TOPIC").to_matchable(),
5586                            Ref::new("EqualsSegment").to_matchable(),
5587                            Ref::new("QuotedLiteralSegment").to_matchable(),
5588                        ])
5589                        .config(|this| this.optional())
5590                        .to_matchable(),
5591                        Sequence::new(vec![
5592                            Ref::keyword("INTEGRATION").to_matchable(),
5593                            Ref::new("EqualsSegment").to_matchable(),
5594                            one_of(vec![
5595                                Ref::new("QuotedLiteralSegment").to_matchable(),
5596                                Ref::new("ObjectReferenceSegment").to_matchable(),
5597                            ])
5598                            .to_matchable(),
5599                        ])
5600                        .config(|this| this.optional())
5601                        .to_matchable(),
5602                    ])
5603                    .config(|this| this.optional())
5604                    .to_matchable(),
5605                    Sequence::new(vec![
5606                        Sequence::new(vec![Ref::keyword("WITH").to_matchable()])
5607                            .config(|this| this.optional())
5608                            .to_matchable(),
5609                        AnyNumberOf::new(vec![
5610                            Ref::new("WarehouseObjectPropertiesSegment").to_matchable(),
5611                            Ref::new("CommentEqualsClauseSegment").to_matchable(),
5612                            Ref::new("WarehouseObjectParamsSegment").to_matchable(),
5613                        ])
5614                        .to_matchable(),
5615                        Ref::new("TagBracketedEqualsSegment")
5616                            .optional()
5617                            .to_matchable(),
5618                    ])
5619                    .config(|this| this.optional())
5620                    .to_matchable(),
5621                    Ref::new("CommentEqualsClauseSegment")
5622                        .optional()
5623                        .to_matchable(),
5624                    Ref::keyword("AS").optional().to_matchable(),
5625                    one_of(vec![
5626                        Ref::new("SelectStatementSegment").to_matchable(),
5627                        Sequence::new(vec![
5628                            Bracketed::new(vec![
5629                                Ref::new("FunctionContentsGrammar").to_matchable(),
5630                            ])
5631                            .config(|this| this.optional())
5632                            .to_matchable(),
5633                            Ref::keyword("RETURNS").to_matchable(),
5634                            Ref::new("DatatypeSegment").to_matchable(),
5635                            Ref::new("FunctionAssignerSegment").to_matchable(),
5636                            Ref::new("ExpressionSegment").to_matchable(),
5637                            Sequence::new(vec![
5638                                Ref::keyword("COMMENT").to_matchable(),
5639                                Ref::new("EqualsSegment").to_matchable(),
5640                                Ref::new("QuotedLiteralSegment").to_matchable(),
5641                            ])
5642                            .config(|this| this.optional())
5643                            .to_matchable(),
5644                        ])
5645                        .config(|this| this.optional())
5646                        .to_matchable(),
5647                        Ref::new("CopyIntoTableStatementSegment").to_matchable(),
5648                    ])
5649                    .config(|this| this.optional())
5650                    .to_matchable(),
5651                ])
5652                .to_matchable()
5653            })
5654            .to_matchable()
5655            .into(),
5656        ),
5657        (
5658            "CreateUserSegment".into(),
5659            NodeMatcher::new(SyntaxKind::CreateUserStatement, |_| {
5660                Sequence::new(vec![
5661                    Ref::keyword("CREATE").to_matchable(),
5662                    Sequence::new(vec![
5663                        Ref::keyword("OR").to_matchable(),
5664                        Ref::keyword("REPLACE").to_matchable(),
5665                    ])
5666                    .config(|this| this.optional())
5667                    .to_matchable(),
5668                    Ref::keyword("USER").to_matchable(),
5669                    Sequence::new(vec![
5670                        Ref::keyword("IF").to_matchable(),
5671                        Ref::keyword("NOT").to_matchable(),
5672                        Ref::keyword("EXISTS").to_matchable(),
5673                    ])
5674                    .config(|this| this.optional())
5675                    .to_matchable(),
5676                    Ref::new("ObjectReferenceSegment").to_matchable(),
5677                    MetaSegment::indent().to_matchable(),
5678                    AnyNumberOf::new(vec![
5679                        Sequence::new(vec![
5680                            Ref::keyword("PASSWORD").to_matchable(),
5681                            Ref::new("EqualsSegment").to_matchable(),
5682                            Ref::new("QuotedLiteralSegment").to_matchable(),
5683                        ])
5684                        .to_matchable(),
5685                        Sequence::new(vec![
5686                            Ref::keyword("LOGIN_NAME").to_matchable(),
5687                            Ref::new("EqualsSegment").to_matchable(),
5688                            one_of(vec![
5689                                Ref::new("ObjectReferenceSegment").to_matchable(),
5690                                Ref::new("QuotedLiteralSegment").to_matchable(),
5691                            ])
5692                            .to_matchable(),
5693                        ])
5694                        .to_matchable(),
5695                        Sequence::new(vec![
5696                            Ref::keyword("DISPLAY_NAME").to_matchable(),
5697                            Ref::new("EqualsSegment").to_matchable(),
5698                            one_of(vec![
5699                                Ref::new("ObjectReferenceSegment").to_matchable(),
5700                                Ref::new("QuotedLiteralSegment").to_matchable(),
5701                            ])
5702                            .to_matchable(),
5703                        ])
5704                        .to_matchable(),
5705                        Sequence::new(vec![
5706                            Ref::keyword("FIRST_NAME").to_matchable(),
5707                            Ref::new("EqualsSegment").to_matchable(),
5708                            one_of(vec![
5709                                Ref::new("ObjectReferenceSegment").to_matchable(),
5710                                Ref::new("QuotedLiteralSegment").to_matchable(),
5711                            ])
5712                            .to_matchable(),
5713                        ])
5714                        .to_matchable(),
5715                        Sequence::new(vec![
5716                            Ref::keyword("MIDDLE_NAME").to_matchable(),
5717                            Ref::new("EqualsSegment").to_matchable(),
5718                            one_of(vec![
5719                                Ref::new("ObjectReferenceSegment").to_matchable(),
5720                                Ref::new("QuotedLiteralSegment").to_matchable(),
5721                            ])
5722                            .to_matchable(),
5723                        ])
5724                        .to_matchable(),
5725                        Sequence::new(vec![
5726                            Ref::keyword("LAST_NAME").to_matchable(),
5727                            Ref::new("EqualsSegment").to_matchable(),
5728                            one_of(vec![
5729                                Ref::new("ObjectReferenceSegment").to_matchable(),
5730                                Ref::new("QuotedLiteralSegment").to_matchable(),
5731                            ])
5732                            .to_matchable(),
5733                        ])
5734                        .to_matchable(),
5735                        Sequence::new(vec![
5736                            Ref::keyword("EMAIL").to_matchable(),
5737                            Ref::new("EqualsSegment").to_matchable(),
5738                            Ref::new("QuotedLiteralSegment").to_matchable(),
5739                        ])
5740                        .to_matchable(),
5741                        Sequence::new(vec![
5742                            Ref::keyword("MUST_CHANGE_PASSWORD").to_matchable(),
5743                            Ref::new("EqualsSegment").to_matchable(),
5744                            Ref::new("BooleanLiteralGrammar").to_matchable(),
5745                        ])
5746                        .to_matchable(),
5747                        Sequence::new(vec![
5748                            Ref::keyword("DISABLED").to_matchable(),
5749                            Ref::new("EqualsSegment").to_matchable(),
5750                            Ref::new("BooleanLiteralGrammar").to_matchable(),
5751                        ])
5752                        .to_matchable(),
5753                        Sequence::new(vec![
5754                            Ref::keyword("DAYS_TO_EXPIRY").to_matchable(),
5755                            Ref::new("EqualsSegment").to_matchable(),
5756                            Ref::new("NumericLiteralSegment").to_matchable(),
5757                        ])
5758                        .to_matchable(),
5759                        Sequence::new(vec![
5760                            Ref::keyword("MINS_TO_UNLOCK").to_matchable(),
5761                            Ref::new("EqualsSegment").to_matchable(),
5762                            Ref::new("NumericLiteralSegment").to_matchable(),
5763                        ])
5764                        .to_matchable(),
5765                        Sequence::new(vec![
5766                            Ref::keyword("DEFAULT_WAREHOUSE").to_matchable(),
5767                            Ref::new("EqualsSegment").to_matchable(),
5768                            one_of(vec![
5769                                Ref::new("ObjectReferenceSegment").to_matchable(),
5770                                Ref::new("QuotedLiteralSegment").to_matchable(),
5771                            ])
5772                            .to_matchable(),
5773                        ])
5774                        .to_matchable(),
5775                        Sequence::new(vec![
5776                            Ref::keyword("DEFAULT_NAMESPACE").to_matchable(),
5777                            Ref::new("EqualsSegment").to_matchable(),
5778                            one_of(vec![
5779                                Ref::new("ObjectReferenceSegment").to_matchable(),
5780                                Ref::new("QuotedLiteralSegment").to_matchable(),
5781                            ])
5782                            .to_matchable(),
5783                        ])
5784                        .to_matchable(),
5785                        Sequence::new(vec![
5786                            Ref::keyword("DEFAULT_ROLE").to_matchable(),
5787                            Ref::new("EqualsSegment").to_matchable(),
5788                            one_of(vec![
5789                                Ref::new("ObjectReferenceSegment").to_matchable(),
5790                                Ref::new("QuotedLiteralSegment").to_matchable(),
5791                            ])
5792                            .to_matchable(),
5793                        ])
5794                        .to_matchable(),
5795                        Sequence::new(vec![
5796                            Ref::keyword("DEFAULT_SECONDARY_ROLES").to_matchable(),
5797                            Ref::new("EqualsSegment").to_matchable(),
5798                            Bracketed::new(vec![Ref::new("QuotedLiteralSegment").to_matchable()])
5799                                .to_matchable(),
5800                        ])
5801                        .to_matchable(),
5802                        Sequence::new(vec![
5803                            Ref::keyword("MINS_TO_BYPASS_MFA").to_matchable(),
5804                            Ref::new("EqualsSegment").to_matchable(),
5805                            Ref::new("NumericLiteralSegment").to_matchable(),
5806                        ])
5807                        .to_matchable(),
5808                        Sequence::new(vec![
5809                            Ref::keyword("RSA_PUBLIC_KEY").to_matchable(),
5810                            Ref::new("EqualsSegment").to_matchable(),
5811                            Ref::new("ObjectReferenceSegment").to_matchable(),
5812                        ])
5813                        .to_matchable(),
5814                        Sequence::new(vec![
5815                            Ref::keyword("RSA_PUBLIC_KEY_2").to_matchable(),
5816                            Ref::new("EqualsSegment").to_matchable(),
5817                            Ref::new("ObjectReferenceSegment").to_matchable(),
5818                        ])
5819                        .to_matchable(),
5820                        Ref::new("CommentEqualsClauseSegment").to_matchable(),
5821                    ])
5822                    .to_matchable(),
5823                    MetaSegment::dedent().to_matchable(),
5824                ])
5825                .to_matchable()
5826            })
5827            .to_matchable()
5828            .into(),
5829        ),
5830    ]);
5831
5832    snowflake_dialect.replace_grammar(
5833        "CreateViewStatementSegment",
5834        Sequence::new(vec![
5835            Ref::keyword("CREATE").to_matchable(),
5836            Ref::new("OrReplaceGrammar").optional().to_matchable(),
5837            any_set_of(vec![
5838                Ref::keyword("SECURE").to_matchable(),
5839                Ref::keyword("RECURSIVE").to_matchable(),
5840            ])
5841            .to_matchable(),
5842            Ref::new("TemporaryGrammar").optional().to_matchable(),
5843            Ref::keyword("VIEW").to_matchable(),
5844            Ref::new("IfNotExistsGrammar").optional().to_matchable(),
5845            Ref::new("TableReferenceSegment").to_matchable(),
5846            any_set_of(vec![
5847                Bracketed::new(vec![
5848                    Delimited::new(vec![
5849                        Sequence::new(vec![
5850                            Ref::new("ColumnReferenceSegment").to_matchable(),
5851                            Ref::new("CommentClauseSegment").optional().to_matchable(),
5852                        ])
5853                        .to_matchable(),
5854                    ])
5855                    .to_matchable(),
5856                ])
5857                .to_matchable(),
5858                Sequence::new(vec![
5859                    Ref::keyword("WITH").optional().to_matchable(),
5860                    Ref::keyword("ROW").to_matchable(),
5861                    Ref::keyword("ACCESS").to_matchable(),
5862                    Ref::keyword("POLICY").to_matchable(),
5863                    Ref::new("NakedIdentifierSegment").to_matchable(),
5864                    Ref::keyword("ON").to_matchable(),
5865                    Bracketed::new(vec![
5866                        Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
5867                            .to_matchable(),
5868                    ])
5869                    .to_matchable(),
5870                ])
5871                .to_matchable(),
5872                Ref::new("TagBracketedEqualsSegment").to_matchable(),
5873                Sequence::new(vec![
5874                    Ref::keyword("COPY").to_matchable(),
5875                    Ref::keyword("GRANTS").to_matchable(),
5876                ])
5877                .to_matchable(),
5878                Ref::new("CommentEqualsClauseSegment").to_matchable(),
5879            ])
5880            .to_matchable(),
5881            Ref::keyword("AS").to_matchable(),
5882            optionally_bracketed(vec![Ref::new("SelectableGrammar").to_matchable()]).to_matchable(),
5883        ])
5884        .to_matchable(),
5885    );
5886
5887    snowflake_dialect.add([
5888        (
5889            "AlterViewStatementSegment".into(),
5890            NodeMatcher::new(SyntaxKind::AlterViewStatement, |_| {
5891                Sequence::new(vec![
5892                    Ref::keyword("ALTER").to_matchable(),
5893                    Ref::keyword("VIEW").to_matchable(),
5894                    Ref::new("IfExistsGrammar").optional().to_matchable(),
5895                    Ref::new("TableReferenceSegment").to_matchable(),
5896                    one_of(vec![
5897                        Sequence::new(vec![
5898                            Ref::keyword("RENAME").to_matchable(),
5899                            Ref::keyword("TO").to_matchable(),
5900                            Ref::new("TableReferenceSegment").to_matchable(),
5901                        ])
5902                        .to_matchable(),
5903                        Sequence::new(vec![
5904                            Ref::keyword("COMMENT").to_matchable(),
5905                            Ref::new("EqualsSegment").to_matchable(),
5906                            Ref::new("QuotedLiteralSegment").to_matchable(),
5907                        ])
5908                        .to_matchable(),
5909                        Sequence::new(vec![
5910                            Ref::keyword("UNSET").to_matchable(),
5911                            Ref::keyword("COMMENT").to_matchable(),
5912                        ])
5913                        .to_matchable(),
5914                        Sequence::new(vec![
5915                            one_of(vec![
5916                                Ref::keyword("SET").to_matchable(),
5917                                Ref::keyword("UNSET").to_matchable(),
5918                            ])
5919                            .to_matchable(),
5920                            Ref::keyword("SECURE").to_matchable(),
5921                        ])
5922                        .to_matchable(),
5923                        Sequence::new(vec![
5924                            Ref::keyword("SET").to_matchable(),
5925                            Ref::new("TagEqualsSegment").to_matchable(),
5926                        ])
5927                        .to_matchable(),
5928                        Sequence::new(vec![
5929                            Ref::keyword("UNSET").to_matchable(),
5930                            Ref::keyword("TAG").to_matchable(),
5931                            Delimited::new(vec![Ref::new("TagReferenceSegment").to_matchable()])
5932                                .to_matchable(),
5933                        ])
5934                        .to_matchable(),
5935                        Delimited::new(vec![
5936                            Sequence::new(vec![
5937                                Ref::keyword("ADD").to_matchable(),
5938                                Ref::keyword("ROW").to_matchable(),
5939                                Ref::keyword("ACCESS").to_matchable(),
5940                                Ref::keyword("POLICY").to_matchable(),
5941                                Ref::new("FunctionNameSegment").to_matchable(),
5942                                Ref::keyword("ON").to_matchable(),
5943                                Bracketed::new(vec![
5944                                    Delimited::new(vec![
5945                                        Ref::new("ColumnReferenceSegment").to_matchable(),
5946                                    ])
5947                                    .to_matchable(),
5948                                ])
5949                                .to_matchable(),
5950                            ])
5951                            .to_matchable(),
5952                            Sequence::new(vec![
5953                                Ref::keyword("DROP").to_matchable(),
5954                                Ref::keyword("ROW").to_matchable(),
5955                                Ref::keyword("ACCESS").to_matchable(),
5956                                Ref::keyword("POLICY").to_matchable(),
5957                                Ref::new("FunctionNameSegment").to_matchable(),
5958                            ])
5959                            .to_matchable(),
5960                        ])
5961                        .to_matchable(),
5962                        Sequence::new(vec![
5963                            one_of(vec![
5964                                Ref::keyword("ALTER").to_matchable(),
5965                                Ref::keyword("MODIFY").to_matchable(),
5966                            ])
5967                            .to_matchable(),
5968                            one_of(vec![
5969                                Delimited::new(vec![
5970                                    Sequence::new(vec![
5971                                        Ref::keyword("COLUMN").optional().to_matchable(),
5972                                        Ref::new("ColumnReferenceSegment").to_matchable(),
5973                                        one_of(vec![
5974                                            Sequence::new(vec![
5975                                                Ref::keyword("SET").to_matchable(),
5976                                                Ref::keyword("MASKING").to_matchable(),
5977                                                Ref::keyword("POLICY").to_matchable(),
5978                                                Ref::new("FunctionNameSegment").to_matchable(),
5979                                                Sequence::new(vec![
5980                                                    Ref::keyword("USING").to_matchable(),
5981                                                    Bracketed::new(vec![
5982                                                        Delimited::new(vec![
5983                                                            Ref::new("ColumnReferenceSegment")
5984                                                                .to_matchable(),
5985                                                        ])
5986                                                        .to_matchable(),
5987                                                    ])
5988                                                    .config(|this| this.optional())
5989                                                    .to_matchable(),
5990                                                ])
5991                                                .config(|this| this.optional())
5992                                                .to_matchable(),
5993                                            ])
5994                                            .to_matchable(),
5995                                            Sequence::new(vec![
5996                                                Ref::keyword("UNSET").to_matchable(),
5997                                                Ref::keyword("MASKING").to_matchable(),
5998                                                Ref::keyword("POLICY").to_matchable(),
5999                                            ])
6000                                            .to_matchable(),
6001                                            Sequence::new(vec![
6002                                                Ref::keyword("SET").to_matchable(),
6003                                                Ref::new("TagEqualsSegment").to_matchable(),
6004                                            ])
6005                                            .to_matchable(),
6006                                        ])
6007                                        .to_matchable(),
6008                                    ])
6009                                    .to_matchable(),
6010                                    Sequence::new(vec![
6011                                        Ref::keyword("COLUMN").to_matchable(),
6012                                        Ref::new("ColumnReferenceSegment").to_matchable(),
6013                                        Ref::keyword("UNSET").to_matchable(),
6014                                        Ref::keyword("TAG").to_matchable(),
6015                                        Delimited::new(vec![
6016                                            Ref::new("TagReferenceSegment").to_matchable(),
6017                                        ])
6018                                        .to_matchable(),
6019                                    ])
6020                                    .to_matchable(),
6021                                ])
6022                                .to_matchable(),
6023                            ])
6024                            .to_matchable(),
6025                        ])
6026                        .to_matchable(),
6027                    ])
6028                    .to_matchable(),
6029                ])
6030                .to_matchable()
6031            })
6032            .to_matchable()
6033            .into(),
6034        ),
6035        (
6036            "AlterMaterializedViewStatementSegment".into(),
6037            NodeMatcher::new(SyntaxKind::AlterMaterializedViewStatement, |_| {
6038                Sequence::new(vec![
6039                    Ref::keyword("ALTER").to_matchable(),
6040                    Ref::keyword("MATERIALIZED").to_matchable(),
6041                    Ref::keyword("VIEW").to_matchable(),
6042                    Ref::new("TableReferenceSegment").to_matchable(),
6043                    one_of(vec![
6044                        Sequence::new(vec![
6045                            Ref::keyword("RENAME").to_matchable(),
6046                            Ref::keyword("TO").to_matchable(),
6047                            Ref::new("TableReferenceSegment").to_matchable(),
6048                        ])
6049                        .to_matchable(),
6050                        Sequence::new(vec![
6051                            Ref::keyword("CLUSTER").to_matchable(),
6052                            Ref::keyword("BY").to_matchable(),
6053                            Delimited::new(vec![Ref::new("ExpressionSegment").to_matchable()])
6054                                .to_matchable(),
6055                        ])
6056                        .to_matchable(),
6057                        Sequence::new(vec![
6058                            Ref::keyword("DROP").to_matchable(),
6059                            Ref::keyword("CLUSTERING").to_matchable(),
6060                            Ref::keyword("KEY").to_matchable(),
6061                        ])
6062                        .to_matchable(),
6063                        Sequence::new(vec![
6064                            Ref::keyword("SUSPEND").to_matchable(),
6065                            Ref::keyword("RECLUSTER").to_matchable(),
6066                        ])
6067                        .to_matchable(),
6068                        Sequence::new(vec![
6069                            Ref::keyword("RESUME").to_matchable(),
6070                            Ref::keyword("RECLUSTER").to_matchable(),
6071                        ])
6072                        .to_matchable(),
6073                        Ref::keyword("SUSPEND").to_matchable(),
6074                        Ref::keyword("RESUME").to_matchable(),
6075                        Sequence::new(vec![
6076                            one_of(vec![
6077                                Ref::keyword("SET").to_matchable(),
6078                                Ref::keyword("UNSET").to_matchable(),
6079                            ])
6080                            .to_matchable(),
6081                            one_of(vec![
6082                                Ref::keyword("SECURE").to_matchable(),
6083                                Ref::new("CommentEqualsClauseSegment").to_matchable(),
6084                                Ref::new("TagEqualsSegment").to_matchable(),
6085                            ])
6086                            .to_matchable(),
6087                        ])
6088                        .to_matchable(),
6089                    ])
6090                    .to_matchable(),
6091                ])
6092                .to_matchable()
6093            })
6094            .to_matchable()
6095            .into(),
6096        ),
6097        (
6098            "CreateFileFormatSegment".into(),
6099            NodeMatcher::new(SyntaxKind::CreateFileFormatSegment, |_| {
6100                Sequence::new(vec![
6101                    Ref::keyword("CREATE").to_matchable(),
6102                    Ref::new("OrReplaceGrammar").optional().to_matchable(),
6103                    Sequence::new(vec![
6104                        Ref::keyword("FILE").to_matchable(),
6105                        Ref::keyword("FORMAT").to_matchable(),
6106                    ])
6107                    .to_matchable(),
6108                    Ref::new("IfNotExistsGrammar").optional().to_matchable(),
6109                    Ref::new("ObjectReferenceSegment").to_matchable(),
6110                    one_of(vec![
6111                        Ref::new("CsvFileFormatTypeParameters").to_matchable(),
6112                        Ref::new("JsonFileFormatTypeParameters").to_matchable(),
6113                        Ref::new("AvroFileFormatTypeParameters").to_matchable(),
6114                        Ref::new("OrcFileFormatTypeParameters").to_matchable(),
6115                        Ref::new("ParquetFileFormatTypeParameters").to_matchable(),
6116                        Ref::new("XmlFileFormatTypeParameters").to_matchable(),
6117                    ])
6118                    .to_matchable(),
6119                    Sequence::new(vec![
6120                        Ref::new("CommaSegment").optional().to_matchable(),
6121                        Ref::new("CommentEqualsClauseSegment").to_matchable(),
6122                    ])
6123                    .config(|this| this.optional())
6124                    .to_matchable(),
6125                ])
6126                .to_matchable()
6127            })
6128            .to_matchable()
6129            .into(),
6130        ),
6131        (
6132            "AlterFileFormatSegment".into(),
6133            NodeMatcher::new(SyntaxKind::AlterFileFormatSegment, |_| {
6134                Sequence::new(vec![
6135                    Ref::keyword("ALTER").to_matchable(),
6136                    Sequence::new(vec![
6137                        Ref::keyword("FILE").to_matchable(),
6138                        Ref::keyword("FORMAT").to_matchable(),
6139                    ])
6140                    .to_matchable(),
6141                    Ref::new("IfExistsGrammar").optional().to_matchable(),
6142                    Ref::new("ObjectReferenceSegment").to_matchable(),
6143                    one_of(vec![
6144                        Sequence::new(vec![
6145                            Ref::keyword("RENAME").to_matchable(),
6146                            Ref::keyword("TO").to_matchable(),
6147                            Ref::new("ObjectReferenceSegment").to_matchable(),
6148                        ])
6149                        .to_matchable(),
6150                        Sequence::new(vec![
6151                            Ref::keyword("SET").to_matchable(),
6152                            one_of(vec![
6153                                Ref::new("CsvFileFormatTypeParameters").to_matchable(),
6154                                Ref::new("JsonFileFormatTypeParameters").to_matchable(),
6155                                Ref::new("AvroFileFormatTypeParameters").to_matchable(),
6156                                Ref::new("OrcFileFormatTypeParameters").to_matchable(),
6157                                Ref::new("ParquetFileFormatTypeParameters").to_matchable(),
6158                                Ref::new("XmlFileFormatTypeParameters").to_matchable(),
6159                            ])
6160                            .to_matchable(),
6161                        ])
6162                        .to_matchable(),
6163                    ])
6164                    .to_matchable(),
6165                    Sequence::new(vec![
6166                        Ref::new("CommaSegment").optional().to_matchable(),
6167                        Ref::new("CommentEqualsClauseSegment").to_matchable(),
6168                    ])
6169                    .config(|this| this.optional())
6170                    .to_matchable(),
6171                ])
6172                .to_matchable()
6173            })
6174            .to_matchable()
6175            .into(),
6176        ),
6177        (
6178            "CsvFileFormatTypeParameters".into(),
6179            NodeMatcher::new(SyntaxKind::CsvFileFormatTypeParameters, |_| {
6180                let file_format_type_parameter = one_of(vec![
6181                    Sequence::new(vec![
6182                        Ref::keyword("TYPE").to_matchable(),
6183                        Ref::new("EqualsSegment").to_matchable(),
6184                        one_of(vec![
6185                            StringParser::new("'CSV'", SyntaxKind::FileType).to_matchable(),
6186                            StringParser::new("CSV", SyntaxKind::FileType).to_matchable(),
6187                        ])
6188                        .to_matchable(),
6189                    ])
6190                    .to_matchable(),
6191                    Sequence::new(vec![
6192                        Ref::keyword("COMPRESSION").to_matchable(),
6193                        Ref::new("EqualsSegment").to_matchable(),
6194                        Ref::new("CompressionType").to_matchable(),
6195                    ])
6196                    .to_matchable(),
6197                    Sequence::new(vec![
6198                        Ref::keyword("FILE_EXTENSION").to_matchable(),
6199                        Ref::new("EqualsSegment").to_matchable(),
6200                        Ref::new("QuotedLiteralSegment").to_matchable(),
6201                    ])
6202                    .to_matchable(),
6203                    Sequence::new(vec![
6204                        Ref::keyword("SKIP_HEADER").to_matchable(),
6205                        Ref::new("EqualsSegment").to_matchable(),
6206                        Ref::new("IntegerSegment").to_matchable(),
6207                    ])
6208                    .to_matchable(),
6209                    Sequence::new(vec![
6210                        one_of(vec![
6211                            Ref::keyword("DATE_FORMAT").to_matchable(),
6212                            Ref::keyword("TIME_FORMAT").to_matchable(),
6213                            Ref::keyword("TIMESTAMP_FORMAT").to_matchable(),
6214                        ])
6215                        .to_matchable(),
6216                        Ref::new("EqualsSegment").to_matchable(),
6217                        one_of(vec![
6218                            Ref::keyword("AUTO").to_matchable(),
6219                            Ref::new("QuotedLiteralSegment").to_matchable(),
6220                        ])
6221                        .to_matchable(),
6222                    ])
6223                    .to_matchable(),
6224                    Sequence::new(vec![
6225                        Ref::keyword("BINARY_FORMAT").to_matchable(),
6226                        Ref::new("EqualsSegment").to_matchable(),
6227                        one_of(vec![
6228                            Ref::keyword("HEX").to_matchable(),
6229                            Ref::keyword("BASE64").to_matchable(),
6230                            Ref::keyword("UTF8").to_matchable(),
6231                        ])
6232                        .to_matchable(),
6233                    ])
6234                    .to_matchable(),
6235                    Sequence::new(vec![
6236                        one_of(vec![
6237                            Ref::keyword("RECORD_DELIMITER").to_matchable(),
6238                            Ref::keyword("FIELD_DELIMITER").to_matchable(),
6239                            Ref::keyword("ESCAPE").to_matchable(),
6240                            Ref::keyword("ESCAPE_UNENCLOSED_FIELD").to_matchable(),
6241                            Ref::keyword("FIELD_OPTIONALLY_ENCLOSED_BY").to_matchable(),
6242                        ])
6243                        .to_matchable(),
6244                        Ref::new("EqualsSegment").to_matchable(),
6245                        one_of(vec![
6246                            Ref::keyword("NONE").to_matchable(),
6247                            Ref::new("QuotedLiteralSegment").to_matchable(),
6248                        ])
6249                        .to_matchable(),
6250                    ])
6251                    .to_matchable(),
6252                    Sequence::new(vec![
6253                        Ref::keyword("NULL_IF").to_matchable(),
6254                        Ref::new("EqualsSegment").to_matchable(),
6255                        Bracketed::new(vec![
6256                            Delimited::new(vec![Ref::new("QuotedLiteralSegment").to_matchable()])
6257                                .config(|this| this.optional())
6258                                .to_matchable(),
6259                        ])
6260                        .to_matchable(),
6261                    ])
6262                    .to_matchable(),
6263                    Sequence::new(vec![
6264                        one_of(vec![
6265                            Ref::keyword("SKIP_BLANK_LINES").to_matchable(),
6266                            Ref::keyword("ERROR_ON_COLUMN_COUNT_MISMATCH").to_matchable(),
6267                            Ref::keyword("REPLACE_INVALID_CHARACTERS").to_matchable(),
6268                            Ref::keyword("VALIDATE_UTF8").to_matchable(),
6269                            Ref::keyword("EMPTY_FIELD_AS_NULL").to_matchable(),
6270                            Ref::keyword("SKIP_BYTE_ORDER_MARK").to_matchable(),
6271                            Ref::keyword("TRIM_SPACE").to_matchable(),
6272                        ])
6273                        .to_matchable(),
6274                        Ref::new("EqualsSegment").to_matchable(),
6275                        Ref::new("BooleanLiteralGrammar").to_matchable(),
6276                    ])
6277                    .to_matchable(),
6278                    Sequence::new(vec![
6279                        Ref::keyword("ENCODING").to_matchable(),
6280                        Ref::new("EqualsSegment").to_matchable(),
6281                        one_of(vec![
6282                            Ref::keyword("UTF8").to_matchable(),
6283                            Ref::new("QuotedLiteralSegment").to_matchable(),
6284                        ])
6285                        .to_matchable(),
6286                    ])
6287                    .to_matchable(),
6288                ]);
6289
6290                one_of(vec![
6291                    Delimited::new(vec![file_format_type_parameter.clone().to_matchable()])
6292                        .to_matchable(),
6293                    AnyNumberOf::new(vec![file_format_type_parameter.to_matchable()])
6294                        .to_matchable(),
6295                ])
6296                .to_matchable()
6297            })
6298            .to_matchable()
6299            .into(),
6300        ),
6301        (
6302            "JsonFileFormatTypeParameters".into(),
6303            NodeMatcher::new(SyntaxKind::JsonFileFormatTypeParameters, |_| {
6304                let file_format_type_parameter = one_of(vec![
6305                    Sequence::new(vec![
6306                        Ref::keyword("TYPE").to_matchable(),
6307                        Ref::new("EqualsSegment").to_matchable(),
6308                        one_of(vec![
6309                            StringParser::new("'JSON'", SyntaxKind::FileType).to_matchable(),
6310                            StringParser::new("JSON", SyntaxKind::FileType).to_matchable(),
6311                        ])
6312                        .to_matchable(),
6313                    ])
6314                    .to_matchable(),
6315                    Sequence::new(vec![
6316                        Ref::keyword("COMPRESSION").to_matchable(),
6317                        Ref::new("EqualsSegment").to_matchable(),
6318                        Ref::new("CompressionType").to_matchable(),
6319                    ])
6320                    .to_matchable(),
6321                    Sequence::new(vec![
6322                        one_of(vec![
6323                            Ref::keyword("DATE_FORMAT").to_matchable(),
6324                            Ref::keyword("TIME_FORMAT").to_matchable(),
6325                            Ref::keyword("TIMESTAMP_FORMAT").to_matchable(),
6326                        ])
6327                        .to_matchable(),
6328                        Ref::new("EqualsSegment").to_matchable(),
6329                        one_of(vec![
6330                            Ref::new("QuotedLiteralSegment").to_matchable(),
6331                            Ref::keyword("AUTO").to_matchable(),
6332                        ])
6333                        .to_matchable(),
6334                    ])
6335                    .to_matchable(),
6336                    Sequence::new(vec![
6337                        Ref::keyword("BINARY_FORMAT").to_matchable(),
6338                        Ref::new("EqualsSegment").to_matchable(),
6339                        one_of(vec![
6340                            Ref::keyword("HEX").to_matchable(),
6341                            Ref::keyword("BASE64").to_matchable(),
6342                            Ref::keyword("UTF8").to_matchable(),
6343                        ])
6344                        .to_matchable(),
6345                    ])
6346                    .to_matchable(),
6347                    Sequence::new(vec![
6348                        Ref::keyword("NULL_IF").to_matchable(),
6349                        Ref::new("EqualsSegment").to_matchable(),
6350                        Bracketed::new(vec![
6351                            Delimited::new(vec![Ref::new("QuotedLiteralSegment").to_matchable()])
6352                                .config(|this| this.optional())
6353                                .to_matchable(),
6354                        ])
6355                        .to_matchable(),
6356                    ])
6357                    .to_matchable(),
6358                    Sequence::new(vec![
6359                        Ref::keyword("FILE_EXTENSION").to_matchable(),
6360                        Ref::new("EqualsSegment").to_matchable(),
6361                        Ref::new("QuotedLiteralSegment").to_matchable(),
6362                    ])
6363                    .to_matchable(),
6364                    Sequence::new(vec![
6365                        one_of(vec![
6366                            Ref::keyword("TRIM_SPACE").to_matchable(),
6367                            Ref::keyword("ENABLE_OCTAL").to_matchable(),
6368                            Ref::keyword("ALLOW_DUPLICATE").to_matchable(),
6369                            Ref::keyword("STRIP_OUTER_ARRAY").to_matchable(),
6370                            Ref::keyword("STRIP_NULL_VALUES").to_matchable(),
6371                            Ref::keyword("REPLACE_INVALID_CHARACTERS").to_matchable(),
6372                            Ref::keyword("IGNORE_UTF8_ERRORS").to_matchable(),
6373                            Ref::keyword("SKIP_BYTE_ORDER_MARK").to_matchable(),
6374                        ])
6375                        .to_matchable(),
6376                        Ref::new("EqualsSegment").to_matchable(),
6377                        Ref::new("BooleanLiteralGrammar").to_matchable(),
6378                    ])
6379                    .to_matchable(),
6380                ]);
6381
6382                one_of(vec![
6383                    Delimited::new(vec![file_format_type_parameter.clone().to_matchable()])
6384                        .to_matchable(),
6385                    AnyNumberOf::new(vec![file_format_type_parameter.to_matchable()])
6386                        .to_matchable(),
6387                ])
6388                .to_matchable()
6389            })
6390            .to_matchable()
6391            .into(),
6392        ),
6393        (
6394            "AvroFileFormatTypeParameters".into(),
6395            NodeMatcher::new(SyntaxKind::AvroFileFormatTypeParameters, |_| {
6396                let file_format_type_parameter = one_of(vec![
6397                    Sequence::new(vec![
6398                        Ref::keyword("TYPE").to_matchable(),
6399                        Ref::new("EqualsSegment").to_matchable(),
6400                        one_of(vec![
6401                            StringParser::new("'AVRO'", SyntaxKind::FileType).to_matchable(),
6402                            StringParser::new("AVRO", SyntaxKind::FileType).to_matchable(),
6403                        ])
6404                        .to_matchable(),
6405                    ])
6406                    .to_matchable(),
6407                    Sequence::new(vec![
6408                        Ref::keyword("COMPRESSION").to_matchable(),
6409                        Ref::new("EqualsSegment").to_matchable(),
6410                        Ref::new("CompressionType").to_matchable(),
6411                    ])
6412                    .to_matchable(),
6413                    Sequence::new(vec![
6414                        Ref::keyword("TRIM_SPACE").to_matchable(),
6415                        Ref::new("EqualsSegment").to_matchable(),
6416                        Ref::new("BooleanLiteralGrammar").to_matchable(),
6417                    ])
6418                    .to_matchable(),
6419                    Sequence::new(vec![
6420                        Ref::keyword("NULL_IF").to_matchable(),
6421                        Ref::new("EqualsSegment").to_matchable(),
6422                        Bracketed::new(vec![
6423                            Delimited::new(vec![Ref::new("QuotedLiteralSegment").to_matchable()])
6424                                .config(|this| this.optional())
6425                                .to_matchable(),
6426                        ])
6427                        .to_matchable(),
6428                    ])
6429                    .to_matchable(),
6430                ]);
6431
6432                one_of(vec![
6433                    Delimited::new(vec![file_format_type_parameter.clone().to_matchable()])
6434                        .to_matchable(),
6435                    AnyNumberOf::new(vec![file_format_type_parameter.to_matchable()])
6436                        .to_matchable(),
6437                ])
6438                .to_matchable()
6439            })
6440            .to_matchable()
6441            .into(),
6442        ),
6443        (
6444            "OrcFileFormatTypeParameters".into(),
6445            NodeMatcher::new(SyntaxKind::OrcFileFormatTypeParameters, |_| {
6446                let file_format_type_parameter = one_of(vec![
6447                    Sequence::new(vec![
6448                        Ref::keyword("TYPE").to_matchable(),
6449                        Ref::new("EqualsSegment").to_matchable(),
6450                        one_of(vec![
6451                            StringParser::new("'ORC'", SyntaxKind::FileType).to_matchable(),
6452                            StringParser::new("ORC", SyntaxKind::FileType).to_matchable(),
6453                        ])
6454                        .to_matchable(),
6455                    ])
6456                    .to_matchable(),
6457                    Sequence::new(vec![
6458                        Ref::keyword("TRIM_SPACE").to_matchable(),
6459                        Ref::new("EqualsSegment").to_matchable(),
6460                        Ref::new("BooleanLiteralGrammar").to_matchable(),
6461                    ])
6462                    .to_matchable(),
6463                    Sequence::new(vec![
6464                        Ref::keyword("NULL_IF").to_matchable(),
6465                        Ref::new("EqualsSegment").to_matchable(),
6466                        Bracketed::new(vec![
6467                            Delimited::new(vec![Ref::new("QuotedLiteralSegment").to_matchable()])
6468                                .config(|this| this.optional())
6469                                .to_matchable(),
6470                        ])
6471                        .to_matchable(),
6472                    ])
6473                    .to_matchable(),
6474                ]);
6475
6476                one_of(vec![
6477                    Delimited::new(vec![file_format_type_parameter.clone().to_matchable()])
6478                        .to_matchable(),
6479                    AnyNumberOf::new(vec![file_format_type_parameter.to_matchable()])
6480                        .to_matchable(),
6481                ])
6482                .to_matchable()
6483            })
6484            .to_matchable()
6485            .into(),
6486        ),
6487        (
6488            "ParquetFileFormatTypeParameters".into(),
6489            NodeMatcher::new(SyntaxKind::ParquetFileFormatTypeParameters, |_| {
6490                let file_format_type_parameter = one_of(vec![
6491                    Sequence::new(vec![
6492                        Ref::keyword("TYPE").to_matchable(),
6493                        Ref::new("EqualsSegment").to_matchable(),
6494                        one_of(vec![
6495                            StringParser::new("'PARQUET'", SyntaxKind::FileType).to_matchable(),
6496                            StringParser::new("PARQUET", SyntaxKind::FileType).to_matchable(),
6497                        ])
6498                        .to_matchable(),
6499                    ])
6500                    .to_matchable(),
6501                    Sequence::new(vec![
6502                        Ref::keyword("COMPRESSION").to_matchable(),
6503                        Ref::new("EqualsSegment").to_matchable(),
6504                        Ref::new("CompressionType").to_matchable(),
6505                    ])
6506                    .to_matchable(),
6507                    Sequence::new(vec![
6508                        one_of(vec![
6509                            Ref::keyword("SNAPPY_COMPRESSION").to_matchable(),
6510                            Ref::keyword("BINARY_AS_TEXT").to_matchable(),
6511                            Ref::keyword("TRIM_SPACE").to_matchable(),
6512                        ])
6513                        .to_matchable(),
6514                        Ref::new("EqualsSegment").to_matchable(),
6515                        Ref::new("BooleanLiteralGrammar").to_matchable(),
6516                    ])
6517                    .to_matchable(),
6518                    Sequence::new(vec![
6519                        Ref::keyword("NULL_IF").to_matchable(),
6520                        Ref::new("EqualsSegment").to_matchable(),
6521                        Bracketed::new(vec![
6522                            Delimited::new(vec![Ref::new("QuotedLiteralSegment").to_matchable()])
6523                                .config(|this| this.optional())
6524                                .to_matchable(),
6525                        ])
6526                        .to_matchable(),
6527                    ])
6528                    .to_matchable(),
6529                ]);
6530
6531                one_of(vec![
6532                    Delimited::new(vec![file_format_type_parameter.clone().to_matchable()])
6533                        .to_matchable(),
6534                    AnyNumberOf::new(vec![file_format_type_parameter.to_matchable()])
6535                        .to_matchable(),
6536                ])
6537                .to_matchable()
6538            })
6539            .to_matchable()
6540            .into(),
6541        ),
6542        (
6543            "XmlFileFormatTypeParameters".into(),
6544            NodeMatcher::new(SyntaxKind::XmlFileFormatTypeParameters, |_| {
6545                let file_format_type_parameter = one_of(vec![
6546                    Sequence::new(vec![
6547                        Ref::keyword("TYPE").to_matchable(),
6548                        Ref::new("EqualsSegment").to_matchable(),
6549                        one_of(vec![
6550                            StringParser::new("'XML'", SyntaxKind::FileType).to_matchable(),
6551                            StringParser::new("XML", SyntaxKind::FileType).to_matchable(),
6552                        ])
6553                        .to_matchable(),
6554                    ])
6555                    .to_matchable(),
6556                    Sequence::new(vec![
6557                        Ref::keyword("COMPRESSION").to_matchable(),
6558                        Ref::new("EqualsSegment").to_matchable(),
6559                        Ref::new("CompressionType").to_matchable(),
6560                    ])
6561                    .to_matchable(),
6562                    Sequence::new(vec![
6563                        one_of(vec![
6564                            Ref::keyword("IGNORE_UTF8_ERRORS").to_matchable(),
6565                            Ref::keyword("PRESERVE_SPACE").to_matchable(),
6566                            Ref::keyword("STRIP_OUTER_ELEMENT").to_matchable(),
6567                            Ref::keyword("DISABLE_SNOWFLAKE_DATA").to_matchable(),
6568                            Ref::keyword("DISABLE_AUTO_CONVERT").to_matchable(),
6569                            Ref::keyword("SKIP_BYTE_ORDER_MARK").to_matchable(),
6570                        ])
6571                        .to_matchable(),
6572                        Ref::new("EqualsSegment").to_matchable(),
6573                        Ref::new("BooleanLiteralGrammar").to_matchable(),
6574                    ])
6575                    .to_matchable(),
6576                ]);
6577
6578                one_of(vec![
6579                    Delimited::new(vec![file_format_type_parameter.clone().to_matchable()])
6580                        .to_matchable(),
6581                    AnyNumberOf::new(vec![file_format_type_parameter.to_matchable()])
6582                        .to_matchable(),
6583                ])
6584                .to_matchable()
6585            })
6586            .to_matchable()
6587            .into(),
6588        ),
6589        (
6590            "AlterPipeSegment".into(),
6591            NodeMatcher::new(SyntaxKind::AlterPipeSegment, |_| {
6592                Sequence::new(vec![
6593                    Ref::keyword("ALTER").to_matchable(),
6594                    Ref::keyword("PIPE").to_matchable(),
6595                    Ref::new("IfExistsGrammar").optional().to_matchable(),
6596                    Ref::new("ObjectReferenceSegment").to_matchable(),
6597                    one_of(vec![
6598                        Sequence::new(vec![
6599                            Ref::keyword("SET").to_matchable(),
6600                            AnyNumberOf::new(vec![
6601                                Sequence::new(vec![
6602                                    Ref::keyword("PIPE_EXECUTION_PAUSED").to_matchable(),
6603                                    Ref::new("EqualsSegment").to_matchable(),
6604                                    Ref::new("BooleanLiteralGrammar").to_matchable(),
6605                                ])
6606                                .to_matchable(),
6607                                Ref::new("CommentEqualsClauseSegment").to_matchable(),
6608                            ])
6609                            .to_matchable(),
6610                        ])
6611                        .to_matchable(),
6612                        Sequence::new(vec![
6613                            Ref::keyword("UNSET").to_matchable(),
6614                            one_of(vec![
6615                                Ref::keyword("PIPE_EXECUTION_PAUSED").to_matchable(),
6616                                Ref::keyword("COMMENT").to_matchable(),
6617                            ])
6618                            .to_matchable(),
6619                        ])
6620                        .to_matchable(),
6621                        Sequence::new(vec![
6622                            Ref::keyword("SET").to_matchable(),
6623                            Ref::new("TagEqualsSegment").to_matchable(),
6624                        ])
6625                        .to_matchable(),
6626                        Sequence::new(vec![
6627                            Ref::keyword("UNSET").to_matchable(),
6628                            Sequence::new(vec![
6629                                Ref::keyword("TAG").to_matchable(),
6630                                Delimited::new(vec![
6631                                    Ref::new("TagReferenceSegment").to_matchable(),
6632                                ])
6633                                .to_matchable(),
6634                            ])
6635                            .to_matchable(),
6636                        ])
6637                        .to_matchable(),
6638                        Sequence::new(vec![
6639                            Ref::keyword("REFRESH").to_matchable(),
6640                            Sequence::new(vec![
6641                                Ref::keyword("PREFIX").to_matchable(),
6642                                Ref::new("EqualsSegment").to_matchable(),
6643                                Ref::new("QuotedLiteralSegment").to_matchable(),
6644                            ])
6645                            .config(|this| this.optional())
6646                            .to_matchable(),
6647                            Sequence::new(vec![
6648                                Ref::keyword("MODIFIED_AFTER").to_matchable(),
6649                                Ref::new("EqualsSegment").to_matchable(),
6650                                Ref::new("QuotedLiteralSegment").to_matchable(),
6651                            ])
6652                            .config(|this| this.optional())
6653                            .to_matchable(),
6654                        ])
6655                        .to_matchable(),
6656                    ])
6657                    .to_matchable(),
6658                    Ref::new("CommaSegment").optional().to_matchable(),
6659                ])
6660                .to_matchable()
6661            })
6662            .to_matchable()
6663            .into(),
6664        ),
6665        (
6666            "FileFormatSegment".into(),
6667            NodeMatcher::new(SyntaxKind::FileFormatSegment, |_| {
6668                one_of(vec![
6669                    one_of(vec![
6670                        Ref::new("QuotedLiteralSegment").to_matchable(),
6671                        Ref::new("ObjectReferenceSegment").to_matchable(),
6672                    ])
6673                    .to_matchable(),
6674                    Bracketed::new(vec![
6675                        Sequence::new(vec![
6676                            one_of(vec![
6677                                Sequence::new(vec![
6678                                    Ref::keyword("FORMAT_NAME").to_matchable(),
6679                                    Ref::new("EqualsSegment").to_matchable(),
6680                                    one_of(vec![
6681                                        Ref::new("QuotedLiteralSegment").to_matchable(),
6682                                        Ref::new("ObjectReferenceSegment").to_matchable(),
6683                                    ])
6684                                    .to_matchable(),
6685                                ])
6686                                .to_matchable(),
6687                                one_of(vec![
6688                                    Ref::new("CsvFileFormatTypeParameters").to_matchable(),
6689                                    Ref::new("JsonFileFormatTypeParameters").to_matchable(),
6690                                    Ref::new("AvroFileFormatTypeParameters").to_matchable(),
6691                                    Ref::new("OrcFileFormatTypeParameters").to_matchable(),
6692                                    Ref::new("ParquetFileFormatTypeParameters").to_matchable(),
6693                                    Ref::new("XmlFileFormatTypeParameters").to_matchable(),
6694                                ])
6695                                .to_matchable(),
6696                            ])
6697                            .to_matchable(),
6698                            Ref::new("FormatTypeOptions").optional().to_matchable(),
6699                        ])
6700                        .to_matchable(),
6701                    ])
6702                    .to_matchable(),
6703                ])
6704                .to_matchable()
6705            })
6706            .to_matchable()
6707            .into(),
6708        ),
6709        (
6710            "FormatTypeOptions".into(),
6711            NodeMatcher::new(SyntaxKind::FormatTypeOptions, |_| {
6712                one_of(vec![
6713                    // COPY INTO <location>, open for extension
6714                    any_set_of(vec![
6715                        Sequence::new(vec![
6716                            Ref::keyword("COMPRESSION").to_matchable(),
6717                            Ref::new("EqualsSegment").to_matchable(),
6718                            Ref::new("CompressionType").to_matchable(),
6719                        ])
6720                        .to_matchable(),
6721                        Sequence::new(vec![
6722                            Ref::keyword("RECORD_DELIMITER").to_matchable(),
6723                            Ref::new("EqualsSegment").to_matchable(),
6724                            one_of(vec![
6725                                Ref::keyword("NONE").to_matchable(),
6726                                Ref::new("QuotedLiteralSegment").to_matchable(),
6727                            ])
6728                            .to_matchable(),
6729                        ])
6730                        .to_matchable(),
6731                        Sequence::new(vec![
6732                            Ref::keyword("FIELD_DELIMITER").to_matchable(),
6733                            Ref::new("EqualsSegment").to_matchable(),
6734                            one_of(vec![
6735                                Ref::keyword("NONE").to_matchable(),
6736                                Ref::new("QuotedLiteralSegment").to_matchable(),
6737                            ])
6738                            .to_matchable(),
6739                        ])
6740                        .to_matchable(),
6741                        Sequence::new(vec![
6742                            Ref::keyword("ESCAPE").to_matchable(),
6743                            Ref::new("EqualsSegment").to_matchable(),
6744                            one_of(vec![
6745                                Ref::keyword("NONE").to_matchable(),
6746                                Ref::new("QuotedLiteralSegment").to_matchable(),
6747                            ])
6748                            .to_matchable(),
6749                        ])
6750                        .to_matchable(),
6751                        Sequence::new(vec![
6752                            Ref::keyword("ESCAPE_UNENCLOSED_FIELD").to_matchable(),
6753                            Ref::new("EqualsSegment").to_matchable(),
6754                            one_of(vec![
6755                                Ref::keyword("NONE").to_matchable(),
6756                                Ref::new("QuotedLiteralSegment").to_matchable(),
6757                            ])
6758                            .to_matchable(),
6759                        ])
6760                        .to_matchable(),
6761                        Sequence::new(vec![
6762                            Ref::keyword("DATA_FORMAT").to_matchable(),
6763                            Ref::new("EqualsSegment").to_matchable(),
6764                            one_of(vec![
6765                                Ref::keyword("AUTO").to_matchable(),
6766                                Ref::new("QuotedLiteralSegment").to_matchable(),
6767                            ])
6768                            .to_matchable(),
6769                        ])
6770                        .to_matchable(),
6771                        Sequence::new(vec![
6772                            Ref::keyword("TIME_FORMAT").to_matchable(),
6773                            Ref::new("EqualsSegment").to_matchable(),
6774                            one_of(vec![
6775                                Ref::keyword("NONE").to_matchable(),
6776                                Ref::new("QuotedLiteralSegment").to_matchable(),
6777                            ])
6778                            .to_matchable(),
6779                        ])
6780                        .to_matchable(),
6781                        Sequence::new(vec![
6782                            Ref::keyword("TIMESTAMP_FORMAT").to_matchable(),
6783                            Ref::new("EqualsSegment").to_matchable(),
6784                            one_of(vec![
6785                                Ref::keyword("NONE").to_matchable(),
6786                                Ref::new("QuotedLiteralSegment").to_matchable(),
6787                            ])
6788                            .to_matchable(),
6789                        ])
6790                        .to_matchable(),
6791                        Sequence::new(vec![
6792                            Ref::keyword("BINARY_FORMAT").to_matchable(),
6793                            Ref::new("EqualsSegment").to_matchable(),
6794                            one_of(vec![
6795                                Ref::keyword("HEX").to_matchable(),
6796                                Ref::keyword("BASE64").to_matchable(),
6797                                Ref::keyword("UTF8").to_matchable(),
6798                            ])
6799                            .to_matchable(),
6800                        ])
6801                        .to_matchable(),
6802                        Sequence::new(vec![
6803                            Ref::keyword("FIELD_OPTIONALITY_ENCLOSED_BY").to_matchable(),
6804                            Ref::new("EqualsSegment").to_matchable(),
6805                            one_of(vec![
6806                                Ref::keyword("NONE").to_matchable(),
6807                                Ref::new("QuotedLiteralSegment").to_matchable(),
6808                            ])
6809                            .to_matchable(),
6810                        ])
6811                        .to_matchable(),
6812                        Sequence::new(vec![
6813                            Ref::keyword("NULL_IF").to_matchable(),
6814                            Ref::new("EqualsSegment").to_matchable(),
6815                            Bracketed::new(vec![
6816                                Delimited::new(vec![
6817                                    Ref::new("QuotedLiteralSegment").to_matchable(),
6818                                ])
6819                                .config(|this| this.optional())
6820                                .to_matchable(),
6821                            ])
6822                            .to_matchable(),
6823                        ])
6824                        .to_matchable(),
6825                        Sequence::new(vec![
6826                            Ref::keyword("EMPTY_FIELD_AS_NULL").to_matchable(),
6827                            Ref::new("EqualsSegment").to_matchable(),
6828                            Ref::new("BooleanLiteralGrammar").to_matchable(),
6829                        ])
6830                        .to_matchable(),
6831                        Sequence::new(vec![
6832                            Ref::keyword("SNAPPY_COMPRESSION").to_matchable(),
6833                            Ref::new("EqualsSegment").to_matchable(),
6834                            Ref::new("BooleanLiteralGrammar").to_matchable(),
6835                        ])
6836                        .to_matchable(),
6837                    ])
6838                    .to_matchable(),
6839                    // COPY INTO <table>, open for extension
6840                    any_set_of(vec![]).to_matchable(),
6841                ])
6842                .to_matchable()
6843            })
6844            .to_matchable()
6845            .into(),
6846        ),
6847        (
6848            "CreateExternalTableSegment".into(),
6849            NodeMatcher::new(SyntaxKind::CreateExternalTableStatement, |_| {
6850                Sequence::new(vec![
6851                    Ref::keyword("CREATE").to_matchable(),
6852                    Sequence::new(vec![
6853                        Ref::keyword("OR").to_matchable(),
6854                        Ref::keyword("REPLACE").to_matchable(),
6855                    ])
6856                    .config(|this| this.optional())
6857                    .to_matchable(),
6858                    Ref::keyword("EXTERNAL").to_matchable(),
6859                    Ref::keyword("TABLE").to_matchable(),
6860                    Sequence::new(vec![
6861                        Ref::keyword("IF").to_matchable(),
6862                        Ref::keyword("NOT").to_matchable(),
6863                        Ref::keyword("EXISTS").to_matchable(),
6864                    ])
6865                    .config(|this| this.optional())
6866                    .to_matchable(),
6867                    Ref::new("TableReferenceSegment").to_matchable(),
6868                    Bracketed::new(vec![
6869                        Delimited::new(vec![
6870                            Sequence::new(vec![
6871                                Ref::new("SingleIdentifierGrammar").to_matchable(),
6872                                Ref::new("DatatypeSegment").to_matchable(),
6873                                Ref::keyword("AS").to_matchable(),
6874                                optionally_bracketed(vec![
6875                                    Sequence::new(vec![
6876                                        Ref::new("ExpressionSegment").to_matchable(),
6877                                        Ref::new("TableConstraintSegment")
6878                                            .optional()
6879                                            .to_matchable(),
6880                                        Sequence::new(vec![
6881                                            Ref::keyword("NOT").optional().to_matchable(),
6882                                            Ref::keyword("NULL").optional().to_matchable(),
6883                                        ])
6884                                        .config(|this| this.optional())
6885                                        .to_matchable(),
6886                                    ])
6887                                    .to_matchable(),
6888                                ])
6889                                .to_matchable(),
6890                            ])
6891                            .to_matchable(),
6892                        ])
6893                        .to_matchable(),
6894                    ])
6895                    .config(|this| this.optional())
6896                    .to_matchable(),
6897                    any_set_of(vec![
6898                        Sequence::new(vec![
6899                            Ref::keyword("INTEGRATION").to_matchable(),
6900                            Ref::new("EqualsSegment").to_matchable(),
6901                            Ref::new("QuotedLiteralSegment").to_matchable(),
6902                        ])
6903                        .to_matchable(),
6904                        Sequence::new(vec![
6905                            Ref::keyword("PARTITION").to_matchable(),
6906                            Ref::keyword("BY").to_matchable(),
6907                            Bracketed::new(vec![
6908                                Delimited::new(vec![
6909                                    Ref::new("SingleIdentifierGrammar").to_matchable(),
6910                                ])
6911                                .to_matchable(),
6912                            ])
6913                            .to_matchable(),
6914                        ])
6915                        .to_matchable(),
6916                        Sequence::new(vec![
6917                            Sequence::new(vec![Ref::keyword("WITH").to_matchable()])
6918                                .config(|this| this.optional())
6919                                .to_matchable(),
6920                            Ref::keyword("LOCATION").to_matchable(),
6921                            Ref::new("EqualsSegment").to_matchable(),
6922                            Ref::new("StagePath").to_matchable(),
6923                        ])
6924                        .to_matchable(),
6925                        Sequence::new(vec![
6926                            Ref::keyword("REFRESH_ON_CREATE").to_matchable(),
6927                            Ref::new("EqualsSegment").to_matchable(),
6928                            Ref::new("BooleanLiteralGrammar").to_matchable(),
6929                        ])
6930                        .to_matchable(),
6931                        Sequence::new(vec![
6932                            Ref::keyword("AUTO_REFRESH").to_matchable(),
6933                            Ref::new("EqualsSegment").to_matchable(),
6934                            Ref::new("BooleanLiteralGrammar").to_matchable(),
6935                        ])
6936                        .to_matchable(),
6937                        Sequence::new(vec![
6938                            Ref::keyword("PATTERN").to_matchable(),
6939                            Ref::new("EqualsSegment").to_matchable(),
6940                            Ref::new("QuotedLiteralSegment").to_matchable(),
6941                        ])
6942                        .to_matchable(),
6943                        Sequence::new(vec![
6944                            Ref::keyword("FILE_FORMAT").to_matchable(),
6945                            Ref::new("EqualsSegment").to_matchable(),
6946                            Ref::new("FileFormatSegment").to_matchable(),
6947                        ])
6948                        .to_matchable(),
6949                        Sequence::new(vec![
6950                            Ref::keyword("AWS_SNS_TOPIC").to_matchable(),
6951                            Ref::new("EqualsSegment").to_matchable(),
6952                            Ref::new("QuotedLiteralSegment").to_matchable(),
6953                        ])
6954                        .to_matchable(),
6955                        Sequence::new(vec![
6956                            Ref::keyword("COPY").to_matchable(),
6957                            Ref::keyword("GRANTS").to_matchable(),
6958                        ])
6959                        .to_matchable(),
6960                        Sequence::new(vec![
6961                            Sequence::new(vec![Ref::keyword("WITH").to_matchable()])
6962                                .config(|this| this.optional())
6963                                .to_matchable(),
6964                            Ref::keyword("ROW").to_matchable(),
6965                            Ref::keyword("ACCESS").to_matchable(),
6966                            Ref::keyword("POLICY").to_matchable(),
6967                            Ref::new("NakedIdentifierSegment").to_matchable(),
6968                        ])
6969                        .to_matchable(),
6970                        Ref::new("TagBracketedEqualsSegment").to_matchable(),
6971                        Ref::new("CommentEqualsClauseSegment").to_matchable(),
6972                    ])
6973                    .to_matchable(),
6974                ])
6975                .to_matchable()
6976            })
6977            .to_matchable()
6978            .into(),
6979        ),
6980    ]);
6981
6982    snowflake_dialect.replace_grammar(
6983        "TableExpressionSegment",
6984        one_of(vec![
6985            Ref::new("BareFunctionSegment").to_matchable(),
6986            Ref::new("FunctionSegment").to_matchable(),
6987            Ref::new("TableReferenceSegment").to_matchable(),
6988            Bracketed::new(vec![Ref::new("SelectableGrammar").to_matchable()]).to_matchable(),
6989            Ref::new("ValuesClauseSegment").to_matchable(),
6990            Sequence::new(vec![
6991                Ref::new("StagePath").to_matchable(),
6992                Bracketed::new(vec![
6993                    Delimited::new(vec![
6994                        Sequence::new(vec![
6995                            Ref::keyword("FILE_FORMAT").to_matchable(),
6996                            Ref::new("ParameterAssignerSegment").to_matchable(),
6997                            Ref::new("FileFormatSegment").to_matchable(),
6998                        ])
6999                        .to_matchable(),
7000                        Sequence::new(vec![
7001                            Ref::keyword("PATTERN").to_matchable(),
7002                            Ref::new("ParameterAssignerSegment").to_matchable(),
7003                            Ref::new("QuotedLiteralSegment").to_matchable(),
7004                        ])
7005                        .to_matchable(),
7006                    ])
7007                    .to_matchable(),
7008                ])
7009                .config(|this| this.optional())
7010                .to_matchable(),
7011            ])
7012            .to_matchable(),
7013        ])
7014        .to_matchable(),
7015    );
7016
7017    snowflake_dialect.add([
7018        (
7019            "PartitionBySegment".into(),
7020            NodeMatcher::new(SyntaxKind::PartitionBySegment, |_| {
7021                Sequence::new(vec![
7022                    Ref::keyword("PARTITION").to_matchable(),
7023                    Ref::keyword("BY").to_matchable(),
7024                    MetaSegment::indent().to_matchable(),
7025                    optionally_bracketed(vec![
7026                        Delimited::new(vec![Ref::new("ExpressionSegment").to_matchable()])
7027                            .to_matchable(),
7028                    ])
7029                    .to_matchable(),
7030                    MetaSegment::dedent().to_matchable(),
7031                ])
7032                .to_matchable()
7033            })
7034            .to_matchable()
7035            .into(),
7036        ),
7037        (
7038            "CopyIntoLocationStatementSegment".into(),
7039            NodeMatcher::new(SyntaxKind::CopyIntoLocationStatement, |_| {
7040                Sequence::new(vec![
7041                    Ref::keyword("COPY").to_matchable(),
7042                    Ref::keyword("INTO").to_matchable(),
7043                    Ref::new("StorageLocation").to_matchable(),
7044                    Bracketed::new(vec![
7045                        Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
7046                            .to_matchable(),
7047                    ])
7048                    .config(|this| this.optional())
7049                    .to_matchable(),
7050                    Sequence::new(vec![
7051                        Ref::keyword("FROM").to_matchable(),
7052                        one_of(vec![
7053                            Ref::new("TableReferenceSegment").to_matchable(),
7054                            Bracketed::new(vec![Ref::new("SelectStatementSegment").to_matchable()])
7055                                .to_matchable(),
7056                        ])
7057                        .to_matchable(),
7058                    ])
7059                    .config(|this| this.optional())
7060                    .to_matchable(),
7061                    one_of(vec![
7062                        Ref::new("S3ExternalStageParameters").to_matchable(),
7063                        Ref::new("AzureBlobStorageExternalStageParameters").to_matchable(),
7064                    ])
7065                    .config(|this| this.optional())
7066                    .to_matchable(),
7067                    Ref::new("InternalStageParameters")
7068                        .optional()
7069                        .to_matchable(),
7070                    any_set_of(vec![
7071                        Ref::new("PartitionBySegment").to_matchable(),
7072                        Sequence::new(vec![
7073                            Ref::keyword("FILE_FORMAT").to_matchable(),
7074                            Ref::new("EqualsSegment").to_matchable(),
7075                            Ref::new("FileFormatSegment").to_matchable(),
7076                        ])
7077                        .to_matchable(),
7078                        Ref::new("CopyOptionsSegment").to_matchable(),
7079                        Sequence::new(vec![
7080                            Ref::keyword("VALIDATION_MODE").to_matchable(),
7081                            Ref::new("EqualsSegment").to_matchable(),
7082                            Ref::new("ValidationModeOptionSegment").to_matchable(),
7083                        ])
7084                        .to_matchable(),
7085                        Sequence::new(vec![
7086                            Ref::keyword("HEADER").to_matchable(),
7087                            Ref::new("EqualsSegment").to_matchable(),
7088                            Ref::new("BooleanLiteralGrammar").to_matchable(),
7089                        ])
7090                        .to_matchable(),
7091                    ])
7092                    .to_matchable(),
7093                ])
7094                .to_matchable()
7095            })
7096            .to_matchable()
7097            .into(),
7098        ),
7099        (
7100            "CopyIntoTableStatementSegment".into(),
7101            NodeMatcher::new(SyntaxKind::CopyIntoTableStatement, |_| {
7102                Sequence::new(vec![
7103                    Ref::keyword("COPY").to_matchable(),
7104                    Ref::keyword("INTO").to_matchable(),
7105                    Ref::new("TableReferenceSegment").to_matchable(),
7106                    Bracketed::new(vec![
7107                        Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
7108                            .to_matchable(),
7109                    ])
7110                    .config(|this| this.optional())
7111                    .to_matchable(),
7112                    Sequence::new(vec![
7113                        Ref::keyword("FROM").to_matchable(),
7114                        one_of(vec![
7115                            Ref::new("StorageLocation").to_matchable(),
7116                            Bracketed::new(vec![Ref::new("SelectStatementSegment").to_matchable()])
7117                                .to_matchable(),
7118                        ])
7119                        .to_matchable(),
7120                    ])
7121                    .config(|this| this.optional())
7122                    .to_matchable(),
7123                    one_of(vec![
7124                        Ref::new("S3ExternalStageParameters").to_matchable(),
7125                        Ref::new("AzureBlobStorageExternalStageParameters").to_matchable(),
7126                    ])
7127                    .config(|this| this.optional())
7128                    .to_matchable(),
7129                    Ref::new("InternalStageParameters")
7130                        .optional()
7131                        .to_matchable(),
7132                    any_set_of(vec![
7133                        Sequence::new(vec![
7134                            Ref::keyword("FILES").to_matchable(),
7135                            Ref::new("EqualsSegment").to_matchable(),
7136                            Bracketed::new(vec![
7137                                Delimited::new(vec![
7138                                    Ref::new("QuotedLiteralSegment").to_matchable(),
7139                                ])
7140                                .to_matchable(),
7141                            ])
7142                            .to_matchable(),
7143                        ])
7144                        .to_matchable(),
7145                        Sequence::new(vec![
7146                            Ref::keyword("PATTERN").to_matchable(),
7147                            Ref::new("EqualsSegment").to_matchable(),
7148                            one_of(vec![
7149                                Ref::new("QuotedLiteralSegment").to_matchable(),
7150                                Ref::new("ReferencedVariableNameSegment").to_matchable(),
7151                            ])
7152                            .to_matchable(),
7153                        ])
7154                        .to_matchable(),
7155                        Sequence::new(vec![
7156                            Ref::keyword("FILE_FORMAT").to_matchable(),
7157                            Ref::new("EqualsSegment").to_matchable(),
7158                            Ref::new("FileFormatSegment").to_matchable(),
7159                        ])
7160                        .to_matchable(),
7161                        Ref::new("CopyOptionsSegment").to_matchable(),
7162                    ])
7163                    .to_matchable(),
7164                    Sequence::new(vec![
7165                        Ref::keyword("VALIDATION_MODE").to_matchable(),
7166                        Ref::new("EqualsSegment").to_matchable(),
7167                        Ref::new("ValidationModeOptionSegment").to_matchable(),
7168                    ])
7169                    .config(|this| this.optional())
7170                    .to_matchable(),
7171                ])
7172                .to_matchable()
7173            })
7174            .to_matchable()
7175            .into(),
7176        ),
7177        (
7178            "StorageLocation".into(),
7179            NodeMatcher::new(SyntaxKind::StorageLocation, |_| {
7180                one_of(vec![
7181                    Ref::new("StagePath").to_matchable(),
7182                    Ref::new("S3Path").to_matchable(),
7183                    Ref::new("GCSPath").to_matchable(),
7184                    Ref::new("AzureBlobStoragePath").to_matchable(),
7185                ])
7186                .to_matchable()
7187            })
7188            .to_matchable()
7189            .into(),
7190        ),
7191        (
7192            "InternalStageParameters".into(),
7193            NodeMatcher::new(SyntaxKind::StageParameters, |_| {
7194                Sequence::new(vec![
7195                    Sequence::new(vec![
7196                        Ref::keyword("ENCRYPTION").to_matchable(),
7197                        Ref::new("EqualsSegment").to_matchable(),
7198                        Bracketed::new(vec![
7199                            Ref::keyword("TYPE").to_matchable(),
7200                            Ref::new("EqualsSegment").to_matchable(),
7201                            Ref::new("SnowflakeEncryptionOption").to_matchable(),
7202                        ])
7203                        .to_matchable(),
7204                    ])
7205                    .config(|this| this.optional())
7206                    .to_matchable(),
7207                ])
7208                .to_matchable()
7209            })
7210            .to_matchable()
7211            .into(),
7212        ),
7213        (
7214            "S3ExternalStageParameters".into(),
7215            NodeMatcher::new(SyntaxKind::S3ExternalStageParameters, |_| {
7216                Sequence::new(vec![
7217                    one_of(vec![
7218                        Sequence::new(vec![
7219                            Ref::keyword("STORAGE_INTEGRATION").to_matchable(),
7220                            Ref::new("EqualsSegment").to_matchable(),
7221                            Ref::new("ObjectReferenceSegment").to_matchable(),
7222                        ])
7223                        .to_matchable(),
7224                        Sequence::new(vec![
7225                            Ref::keyword("CREDENTIALS").to_matchable(),
7226                            Ref::new("EqualsSegment").to_matchable(),
7227                            Bracketed::new(vec![
7228                                one_of(vec![
7229                                    Sequence::new(vec![
7230                                        Ref::keyword("AWS_KEY_ID").to_matchable(),
7231                                        Ref::new("EqualsSegment").to_matchable(),
7232                                        Ref::new("QuotedLiteralSegment").to_matchable(),
7233                                        Ref::keyword("AWS_SECRET_KEY").to_matchable(),
7234                                        Ref::new("EqualsSegment").to_matchable(),
7235                                        Ref::new("QuotedLiteralSegment").to_matchable(),
7236                                        Sequence::new(vec![
7237                                            Ref::keyword("AWS_TOKEN").to_matchable(),
7238                                            Ref::new("EqualsSegment").to_matchable(),
7239                                            Ref::new("QuotedLiteralSegment").to_matchable(),
7240                                        ])
7241                                        .config(|this| this.optional())
7242                                        .to_matchable(),
7243                                    ])
7244                                    .to_matchable(),
7245                                    Sequence::new(vec![
7246                                        Ref::keyword("AWS_ROLE").to_matchable(),
7247                                        Ref::new("EqualsSegment").to_matchable(),
7248                                        Ref::new("QuotedLiteralSegment").to_matchable(),
7249                                    ])
7250                                    .to_matchable(),
7251                                ])
7252                                .to_matchable(),
7253                            ])
7254                            .to_matchable(),
7255                        ])
7256                        .to_matchable(),
7257                    ])
7258                    .config(|this| this.optional())
7259                    .to_matchable(),
7260                    Sequence::new(vec![
7261                        Ref::keyword("ENCRYPTION").to_matchable(),
7262                        Ref::new("EqualsSegment").to_matchable(),
7263                        Bracketed::new(vec![
7264                            one_of(vec![
7265                                Sequence::new(vec![
7266                                    Sequence::new(vec![
7267                                        Ref::keyword("TYPE").to_matchable(),
7268                                        Ref::new("EqualsSegment").to_matchable(),
7269                                        Ref::new("S3EncryptionOption").to_matchable(),
7270                                    ])
7271                                    .config(|this| this.optional())
7272                                    .to_matchable(),
7273                                    Ref::keyword("MASTER_KEY").to_matchable(),
7274                                    Ref::new("EqualsSegment").to_matchable(),
7275                                    Ref::new("QuotedLiteralSegment").to_matchable(),
7276                                ])
7277                                .to_matchable(),
7278                                Sequence::new(vec![
7279                                    Ref::keyword("TYPE").to_matchable(),
7280                                    Ref::new("EqualsSegment").to_matchable(),
7281                                    Ref::new("S3EncryptionOption").to_matchable(),
7282                                ])
7283                                .to_matchable(),
7284                                Sequence::new(vec![
7285                                    Ref::keyword("TYPE").to_matchable(),
7286                                    Ref::new("EqualsSegment").to_matchable(),
7287                                    Ref::new("S3EncryptionOption").to_matchable(),
7288                                    Sequence::new(vec![
7289                                        Ref::keyword("KMS_KEY_ID").to_matchable(),
7290                                        Ref::new("EqualsSegment").to_matchable(),
7291                                        Ref::new("QuotedLiteralSegment").to_matchable(),
7292                                    ])
7293                                    .config(|this| this.optional())
7294                                    .to_matchable(),
7295                                ])
7296                                .to_matchable(),
7297                                Sequence::new(vec![
7298                                    Ref::keyword("TYPE").to_matchable(),
7299                                    Ref::new("EqualsSegment").to_matchable(),
7300                                    Ref::keyword("NONE").to_matchable(),
7301                                ])
7302                                .to_matchable(),
7303                            ])
7304                            .to_matchable(),
7305                        ])
7306                        .to_matchable(),
7307                    ])
7308                    .config(|this| this.optional())
7309                    .to_matchable(),
7310                ])
7311                .to_matchable()
7312            })
7313            .to_matchable()
7314            .into(),
7315        ),
7316        (
7317            "GCSExternalStageParameters".into(),
7318            NodeMatcher::new(SyntaxKind::GcsExternalStageParameters, |_| {
7319                Sequence::new(vec![
7320                    Sequence::new(vec![
7321                        Ref::keyword("STORAGE_INTEGRATION").to_matchable(),
7322                        Ref::new("EqualsSegment").to_matchable(),
7323                        Ref::new("ObjectReferenceSegment").to_matchable(),
7324                    ])
7325                    .config(|this| this.optional())
7326                    .to_matchable(),
7327                    Sequence::new(vec![
7328                        Ref::keyword("ENCRYPTION").to_matchable(),
7329                        Ref::new("EqualsSegment").to_matchable(),
7330                        Bracketed::new(vec![
7331                            Sequence::new(vec![
7332                                Ref::keyword("TYPE").to_matchable(),
7333                                Ref::new("EqualsSegment").to_matchable(),
7334                                one_of(vec![
7335                                    Sequence::new(vec![
7336                                        Ref::new("GCSEncryptionOption").to_matchable(),
7337                                        Sequence::new(vec![
7338                                            Ref::keyword("KMS_KEY_ID").to_matchable(),
7339                                            Ref::new("EqualsSegment").to_matchable(),
7340                                            Ref::new("QuotedLiteralSegment").to_matchable(),
7341                                        ])
7342                                        .config(|this| this.optional())
7343                                        .to_matchable(),
7344                                    ])
7345                                    .to_matchable(),
7346                                    Ref::keyword("NONE").to_matchable(),
7347                                ])
7348                                .to_matchable(),
7349                            ])
7350                            .to_matchable(),
7351                        ])
7352                        .to_matchable(),
7353                    ])
7354                    .config(|this| this.optional())
7355                    .to_matchable(),
7356                ])
7357                .to_matchable()
7358            })
7359            .to_matchable()
7360            .into(),
7361        ),
7362        (
7363            "AzureBlobStorageExternalStageParameters".into(),
7364            NodeMatcher::new(SyntaxKind::AzureBlobStorageExternalStageParameters, |_| {
7365                Sequence::new(vec![
7366                    one_of(vec![
7367                        Sequence::new(vec![
7368                            Ref::keyword("STORAGE_INTEGRATION").to_matchable(),
7369                            Ref::new("EqualsSegment").to_matchable(),
7370                            Ref::new("ObjectReferenceSegment").to_matchable(),
7371                        ])
7372                        .to_matchable(),
7373                        Sequence::new(vec![
7374                            Ref::keyword("CREDENTIALS").to_matchable(),
7375                            Ref::new("EqualsSegment").to_matchable(),
7376                            Bracketed::new(vec![
7377                                Sequence::new(vec![
7378                                    Ref::keyword("AZURE_SAS_TOKEN").to_matchable(),
7379                                    Ref::new("EqualsSegment").to_matchable(),
7380                                    Ref::new("QuotedLiteralSegment").to_matchable(),
7381                                ])
7382                                .to_matchable(),
7383                            ])
7384                            .to_matchable(),
7385                        ])
7386                        .to_matchable(),
7387                    ])
7388                    .config(|this| this.optional())
7389                    .to_matchable(),
7390                    Sequence::new(vec![
7391                        Ref::keyword("ENCRYPTION").to_matchable(),
7392                        Ref::new("EqualsSegment").to_matchable(),
7393                        Bracketed::new(vec![
7394                            Sequence::new(vec![
7395                                Ref::keyword("TYPE").to_matchable(),
7396                                Ref::new("EqualsSegment").to_matchable(),
7397                                one_of(vec![
7398                                    Sequence::new(vec![
7399                                        Ref::new("AzureBlobStorageEncryptionOption").to_matchable(),
7400                                        Sequence::new(vec![
7401                                            Ref::keyword("MASTER_KEY").to_matchable(),
7402                                            Ref::new("EqualsSegment").to_matchable(),
7403                                            Ref::new("QuotedLiteralSegment").to_matchable(),
7404                                        ])
7405                                        .config(|this| this.optional())
7406                                        .to_matchable(),
7407                                    ])
7408                                    .to_matchable(),
7409                                    Ref::keyword("NONE").to_matchable(),
7410                                ])
7411                                .to_matchable(),
7412                            ])
7413                            .to_matchable(),
7414                        ])
7415                        .to_matchable(),
7416                    ])
7417                    .config(|this| this.optional())
7418                    .to_matchable(),
7419                ])
7420                .to_matchable()
7421            })
7422            .to_matchable()
7423            .into(),
7424        ),
7425        (
7426            "CreateStageSegment".into(),
7427            NodeMatcher::new(SyntaxKind::CreateStageStatement, |_| {
7428                Sequence::new(vec![
7429                    Ref::keyword("CREATE").to_matchable(),
7430                    Sequence::new(vec![
7431                        Ref::keyword("OR").to_matchable(),
7432                        Ref::keyword("REPLACE").to_matchable(),
7433                    ])
7434                    .config(|this| this.optional())
7435                    .to_matchable(),
7436                    Ref::keyword("TEMPORARY").optional().to_matchable(),
7437                    Ref::keyword("STAGE").to_matchable(),
7438                    Sequence::new(vec![
7439                        Ref::keyword("IF").to_matchable(),
7440                        Ref::keyword("NOT").to_matchable(),
7441                        Ref::keyword("EXISTS").to_matchable(),
7442                    ])
7443                    .config(|this| this.optional())
7444                    .to_matchable(),
7445                    Ref::new("ObjectReferenceSegment").to_matchable(),
7446                    MetaSegment::indent().to_matchable(),
7447                    one_of(vec![
7448                        // Internal stages
7449                        Sequence::new(vec![
7450                            Ref::new("InternalStageParameters")
7451                                .optional()
7452                                .to_matchable(),
7453                            Sequence::new(vec![
7454                                Ref::keyword("DIRECTORY").to_matchable(),
7455                                Ref::new("EqualsSegment").to_matchable(),
7456                                Bracketed::new(vec![
7457                                    Sequence::new(vec![
7458                                        Ref::keyword("ENABLE").to_matchable(),
7459                                        Ref::new("EqualsSegment").to_matchable(),
7460                                        Ref::new("BooleanLiteralGrammar").to_matchable(),
7461                                    ])
7462                                    .to_matchable(),
7463                                ])
7464                                .to_matchable(),
7465                            ])
7466                            .config(|this| this.optional())
7467                            .to_matchable(),
7468                        ])
7469                        .to_matchable(),
7470                        // External S3 stage
7471                        Sequence::new(vec![
7472                            Ref::keyword("URL").to_matchable(),
7473                            Ref::new("EqualsSegment").to_matchable(),
7474                            Ref::new("S3Path").to_matchable(),
7475                            Ref::new("S3ExternalStageParameters")
7476                                .optional()
7477                                .to_matchable(),
7478                            Sequence::new(vec![
7479                                Ref::keyword("DIRECTORY").to_matchable(),
7480                                Ref::new("EqualsSegment").to_matchable(),
7481                                Bracketed::new(vec![
7482                                    Sequence::new(vec![
7483                                        Ref::keyword("ENABLE").to_matchable(),
7484                                        Ref::new("EqualsSegment").to_matchable(),
7485                                        Ref::new("BooleanLiteralGrammar").to_matchable(),
7486                                    ])
7487                                    .to_matchable(),
7488                                    Sequence::new(vec![
7489                                        Ref::keyword("AUTO_REFRESH").to_matchable(),
7490                                        Ref::new("EqualsSegment").to_matchable(),
7491                                        Ref::new("BooleanLiteralGrammar").to_matchable(),
7492                                    ])
7493                                    .config(|this| this.optional())
7494                                    .to_matchable(),
7495                                ])
7496                                .to_matchable(),
7497                            ])
7498                            .config(|this| this.optional())
7499                            .to_matchable(),
7500                        ])
7501                        .to_matchable(),
7502                        // External GCS stage
7503                        Sequence::new(vec![
7504                            Ref::keyword("URL").to_matchable(),
7505                            Ref::new("EqualsSegment").to_matchable(),
7506                            Ref::new("GCSPath").to_matchable(),
7507                            Ref::new("GCSExternalStageParameters")
7508                                .optional()
7509                                .to_matchable(),
7510                            Sequence::new(vec![
7511                                Ref::keyword("DIRECTORY").to_matchable(),
7512                                Ref::new("EqualsSegment").to_matchable(),
7513                                Bracketed::new(vec![
7514                                    Sequence::new(vec![
7515                                        Ref::keyword("ENABLE").to_matchable(),
7516                                        Ref::new("EqualsSegment").to_matchable(),
7517                                        Ref::new("BooleanLiteralGrammar").to_matchable(),
7518                                    ])
7519                                    .to_matchable(),
7520                                    Sequence::new(vec![
7521                                        Ref::keyword("AUTO_REFRESH").to_matchable(),
7522                                        Ref::new("EqualsSegment").to_matchable(),
7523                                        Ref::new("BooleanLiteralGrammar").to_matchable(),
7524                                    ])
7525                                    .config(|this| this.optional())
7526                                    .to_matchable(),
7527                                    Sequence::new(vec![
7528                                        Ref::keyword("NOTIFICATION_INTEGRATION").to_matchable(),
7529                                        Ref::new("EqualsSegment").to_matchable(),
7530                                        one_of(vec![
7531                                            Ref::new("NakedIdentifierSegment").to_matchable(),
7532                                            Ref::new("QuotedLiteralSegment").to_matchable(),
7533                                        ])
7534                                        .to_matchable(),
7535                                    ])
7536                                    .config(|this| this.optional())
7537                                    .to_matchable(),
7538                                ])
7539                                .to_matchable(),
7540                            ])
7541                            .config(|this| this.optional())
7542                            .to_matchable(),
7543                        ])
7544                        .to_matchable(),
7545                        // External Azure Blob Storage stage
7546                        Sequence::new(vec![
7547                            Ref::keyword("URL").to_matchable(),
7548                            Ref::new("EqualsSegment").to_matchable(),
7549                            Ref::new("AzureBlobStoragePath").to_matchable(),
7550                            Ref::new("AzureBlobStorageExternalStageParameters")
7551                                .optional()
7552                                .to_matchable(),
7553                            Sequence::new(vec![
7554                                Ref::keyword("DIRECTORY").to_matchable(),
7555                                Ref::new("EqualsSegment").to_matchable(),
7556                                Bracketed::new(vec![
7557                                    Sequence::new(vec![
7558                                        Ref::keyword("ENABLE").to_matchable(),
7559                                        Ref::new("EqualsSegment").to_matchable(),
7560                                        Ref::new("BooleanLiteralGrammar").to_matchable(),
7561                                    ])
7562                                    .to_matchable(),
7563                                    Sequence::new(vec![
7564                                        Ref::keyword("AUTO_REFRESH").to_matchable(),
7565                                        Ref::new("EqualsSegment").to_matchable(),
7566                                        Ref::new("BooleanLiteralGrammar").to_matchable(),
7567                                    ])
7568                                    .config(|this| this.optional())
7569                                    .to_matchable(),
7570                                    Sequence::new(vec![
7571                                        Ref::keyword("NOTIFICATION_INTEGRATION").to_matchable(),
7572                                        Ref::new("EqualsSegment").to_matchable(),
7573                                        one_of(vec![
7574                                            Ref::new("NakedIdentifierSegment").to_matchable(),
7575                                            Ref::new("QuotedLiteralSegment").to_matchable(),
7576                                        ])
7577                                        .to_matchable(),
7578                                    ])
7579                                    .config(|this| this.optional())
7580                                    .to_matchable(),
7581                                ])
7582                                .to_matchable(),
7583                            ])
7584                            .config(|this| this.optional())
7585                            .to_matchable(),
7586                        ])
7587                        .to_matchable(),
7588                    ])
7589                    .config(|this| this.optional())
7590                    .to_matchable(),
7591                    Sequence::new(vec![
7592                        Ref::keyword("FILE_FORMAT").to_matchable(),
7593                        Ref::new("EqualsSegment").to_matchable(),
7594                        Ref::new("FileFormatSegment").to_matchable(),
7595                    ])
7596                    .config(|this| this.optional())
7597                    .to_matchable(),
7598                    Sequence::new(vec![
7599                        Ref::keyword("COPY_OPTIONS").to_matchable(),
7600                        Ref::new("EqualsSegment").to_matchable(),
7601                        Bracketed::new(vec![Ref::new("CopyOptionsSegment").to_matchable()])
7602                            .to_matchable(),
7603                    ])
7604                    .config(|this| this.optional())
7605                    .to_matchable(),
7606                    Ref::new("TagBracketedEqualsSegment")
7607                        .optional()
7608                        .to_matchable(),
7609                    Ref::new("CommentEqualsClauseSegment")
7610                        .optional()
7611                        .to_matchable(),
7612                    MetaSegment::dedent().to_matchable(),
7613                ])
7614                .to_matchable()
7615            })
7616            .to_matchable()
7617            .into(),
7618        ),
7619        (
7620            "AlterStageSegment".into(),
7621            NodeMatcher::new(SyntaxKind::AlterStageStatement, |_| {
7622                Sequence::new(vec![
7623                    Ref::keyword("ALTER").to_matchable(),
7624                    Ref::keyword("STAGE").to_matchable(),
7625                    Sequence::new(vec![
7626                        Ref::keyword("IF").to_matchable(),
7627                        Ref::keyword("EXISTS").to_matchable(),
7628                    ])
7629                    .config(|this| this.optional())
7630                    .to_matchable(),
7631                    Ref::new("ObjectReferenceSegment").to_matchable(),
7632                    one_of(vec![
7633                        Sequence::new(vec![
7634                            Ref::keyword("RENAME").to_matchable(),
7635                            Ref::keyword("TO").to_matchable(),
7636                            Ref::new("ObjectReferenceSegment").to_matchable(),
7637                        ])
7638                        .to_matchable(),
7639                        Sequence::new(vec![
7640                            Ref::keyword("SET").to_matchable(),
7641                            MetaSegment::indent().to_matchable(),
7642                            one_of(vec![
7643                                Sequence::new(vec![
7644                                    one_of(vec![
7645                                        Ref::new("InternalStageParameters").to_matchable(),
7646                                        Sequence::new(vec![
7647                                            Sequence::new(vec![
7648                                                Ref::keyword("URL").to_matchable(),
7649                                                Ref::new("EqualsSegment").to_matchable(),
7650                                                Ref::new("S3Path").to_matchable(),
7651                                            ])
7652                                            .config(|this| this.optional())
7653                                            .to_matchable(),
7654                                            Ref::new("S3ExternalStageParameters")
7655                                                .optional()
7656                                                .to_matchable(),
7657                                        ])
7658                                        .to_matchable(),
7659                                        Sequence::new(vec![
7660                                            Sequence::new(vec![
7661                                                Ref::keyword("URL").to_matchable(),
7662                                                Ref::new("EqualsSegment").to_matchable(),
7663                                                Ref::new("GCSPath").to_matchable(),
7664                                            ])
7665                                            .config(|this| this.optional())
7666                                            .to_matchable(),
7667                                            Ref::new("GCSExternalStageParameters")
7668                                                .optional()
7669                                                .to_matchable(),
7670                                        ])
7671                                        .to_matchable(),
7672                                        Sequence::new(vec![
7673                                            Sequence::new(vec![
7674                                                Ref::keyword("URL").to_matchable(),
7675                                                Ref::new("EqualsSegment").to_matchable(),
7676                                                Ref::new("AzureBlobStoragePath").to_matchable(),
7677                                            ])
7678                                            .config(|this| this.optional())
7679                                            .to_matchable(),
7680                                            Ref::new("AzureBlobStorageExternalStageParameters")
7681                                                .optional()
7682                                                .to_matchable(),
7683                                        ])
7684                                        .to_matchable(),
7685                                    ])
7686                                    .config(|this| this.optional())
7687                                    .to_matchable(),
7688                                    Sequence::new(vec![
7689                                        Ref::keyword("FILE_FORMAT").to_matchable(),
7690                                        Ref::new("EqualsSegment").to_matchable(),
7691                                        Ref::new("FileFormatSegment").to_matchable(),
7692                                    ])
7693                                    .config(|this| this.optional())
7694                                    .to_matchable(),
7695                                    Sequence::new(vec![
7696                                        Ref::keyword("COPY_OPTIONS").to_matchable(),
7697                                        Ref::new("EqualsSegment").to_matchable(),
7698                                        Bracketed::new(vec![
7699                                            Ref::new("CopyOptionsSegment").to_matchable(),
7700                                        ])
7701                                        .to_matchable(),
7702                                    ])
7703                                    .config(|this| this.optional())
7704                                    .to_matchable(),
7705                                    Ref::new("CommentEqualsClauseSegment")
7706                                        .optional()
7707                                        .to_matchable(),
7708                                ])
7709                                .to_matchable(),
7710                                Ref::new("TagEqualsSegment").to_matchable(),
7711                            ])
7712                            .to_matchable(),
7713                            MetaSegment::dedent().to_matchable(),
7714                        ])
7715                        .to_matchable(),
7716                        Sequence::new(vec![
7717                            Ref::keyword("REFRESH").to_matchable(),
7718                            Sequence::new(vec![
7719                                Ref::keyword("SUBPATH").to_matchable(),
7720                                Ref::new("EqualsSegment").to_matchable(),
7721                                Ref::new("QuotedLiteralSegment").to_matchable(),
7722                            ])
7723                            .config(|this| this.optional())
7724                            .to_matchable(),
7725                        ])
7726                        .to_matchable(),
7727                    ])
7728                    .to_matchable(),
7729                ])
7730                .to_matchable()
7731            })
7732            .to_matchable()
7733            .into(),
7734        ),
7735        (
7736            "CreateStreamStatementSegment".into(),
7737            NodeMatcher::new(SyntaxKind::CreateStreamStatement, |_| {
7738                Sequence::new(vec![
7739                    Ref::keyword("CREATE").to_matchable(),
7740                    Ref::new("OrReplaceGrammar").optional().to_matchable(),
7741                    Ref::keyword("STREAM").to_matchable(),
7742                    Ref::new("IfNotExistsGrammar").optional().to_matchable(),
7743                    Ref::new("ObjectReferenceSegment").to_matchable(),
7744                    Sequence::new(vec![
7745                        Ref::keyword("COPY").to_matchable(),
7746                        Ref::keyword("GRANTS").to_matchable(),
7747                    ])
7748                    .config(|this| this.optional())
7749                    .to_matchable(),
7750                    Ref::keyword("ON").to_matchable(),
7751                    one_of(vec![
7752                        Sequence::new(vec![
7753                            one_of(vec![
7754                                Ref::keyword("TABLE").to_matchable(),
7755                                Ref::keyword("VIEW").to_matchable(),
7756                            ])
7757                            .to_matchable(),
7758                            Ref::new("ObjectReferenceSegment").to_matchable(),
7759                            one_of(vec![
7760                                Ref::new("FromAtExpressionSegment").to_matchable(),
7761                                Ref::new("FromBeforeExpressionSegment").to_matchable(),
7762                            ])
7763                            .config(|this| this.optional())
7764                            .to_matchable(),
7765                            Sequence::new(vec![
7766                                Ref::keyword("APPEND_ONLY").to_matchable(),
7767                                Ref::new("EqualsSegment").to_matchable(),
7768                                Ref::new("BooleanLiteralGrammar").to_matchable(),
7769                            ])
7770                            .config(|this| this.optional())
7771                            .to_matchable(),
7772                            Sequence::new(vec![
7773                                Ref::keyword("SHOW_INITIAL_ROWS").to_matchable(),
7774                                Ref::new("EqualsSegment").to_matchable(),
7775                                Ref::new("BooleanLiteralGrammar").to_matchable(),
7776                            ])
7777                            .config(|this| this.optional())
7778                            .to_matchable(),
7779                        ])
7780                        .to_matchable(),
7781                        Sequence::new(vec![
7782                            Ref::keyword("EXTERNAL").to_matchable(),
7783                            Ref::keyword("TABLE").to_matchable(),
7784                            Ref::new("ObjectReferenceSegment").to_matchable(),
7785                            one_of(vec![
7786                                Ref::new("FromAtExpressionSegment").to_matchable(),
7787                                Ref::new("FromBeforeExpressionSegment").to_matchable(),
7788                            ])
7789                            .config(|this| this.optional())
7790                            .to_matchable(),
7791                            Sequence::new(vec![
7792                                Ref::keyword("INSERT_ONLY").to_matchable(),
7793                                Ref::new("EqualsSegment").to_matchable(),
7794                                Ref::new("TrueSegment").to_matchable(),
7795                            ])
7796                            .config(|this| this.optional())
7797                            .to_matchable(),
7798                        ])
7799                        .to_matchable(),
7800                        Sequence::new(vec![
7801                            Ref::keyword("STAGE").to_matchable(),
7802                            Ref::new("ObjectReferenceSegment").to_matchable(),
7803                        ])
7804                        .to_matchable(),
7805                    ])
7806                    .to_matchable(),
7807                    Ref::new("CommentEqualsClauseSegment")
7808                        .optional()
7809                        .to_matchable(),
7810                ])
7811                .to_matchable()
7812            })
7813            .to_matchable()
7814            .into(),
7815        ),
7816        (
7817            "AlterStreamStatementSegment".into(),
7818            NodeMatcher::new(SyntaxKind::AlterStreamStatement, |_| {
7819                Sequence::new(vec![
7820                    Ref::keyword("ALTER").to_matchable(),
7821                    Ref::keyword("STREAM").to_matchable(),
7822                    Ref::new("IfExistsGrammar").optional().to_matchable(),
7823                    Ref::new("ObjectReferenceSegment").to_matchable(),
7824                    one_of(vec![
7825                        Sequence::new(vec![
7826                            Ref::keyword("SET").to_matchable(),
7827                            Sequence::new(vec![
7828                                Ref::keyword("APPEND_ONLY").to_matchable(),
7829                                Ref::new("EqualsSegment").to_matchable(),
7830                                Ref::new("BooleanLiteralGrammar").to_matchable(),
7831                            ])
7832                            .config(|this| this.optional())
7833                            .to_matchable(),
7834                            Sequence::new(vec![
7835                                Ref::keyword("INSERT_ONLY").to_matchable(),
7836                                Ref::new("EqualsSegment").to_matchable(),
7837                                Ref::new("TrueSegment").to_matchable(),
7838                            ])
7839                            .config(|this| this.optional())
7840                            .to_matchable(),
7841                            Ref::new("TagEqualsSegment").optional().to_matchable(),
7842                            Ref::new("CommentEqualsClauseSegment")
7843                                .optional()
7844                                .to_matchable(),
7845                        ])
7846                        .to_matchable(),
7847                        Sequence::new(vec![
7848                            Ref::keyword("UNSET").to_matchable(),
7849                            one_of(vec![
7850                                Sequence::new(vec![
7851                                    Ref::keyword("TAG").to_matchable(),
7852                                    Delimited::new(vec![
7853                                        Ref::new("TagReferenceSegment").to_matchable(),
7854                                    ])
7855                                    .to_matchable(),
7856                                ])
7857                                .to_matchable(),
7858                                Ref::keyword("COMMENT").to_matchable(),
7859                            ])
7860                            .to_matchable(),
7861                        ])
7862                        .to_matchable(),
7863                    ])
7864                    .to_matchable(),
7865                ])
7866                .to_matchable()
7867            })
7868            .to_matchable()
7869            .into(),
7870        ),
7871        (
7872            // `ALTER ACCOUNT` statement.
7873            // https://docs.snowflake.com/en/sql-reference/sql/alter-account
7874            "AlterAccountStatementSegment".into(),
7875            Sequence::new(vec![
7876                Ref::keyword("ALTER").to_matchable(),
7877                Ref::keyword("ACCOUNT").to_matchable(),
7878                one_of(vec![
7879                    Sequence::new(vec![
7880                        Ref::keyword("SET").to_matchable(),
7881                        Ref::keyword("RESOURCE_MONITOR").to_matchable(),
7882                        Ref::new("EqualsSegment").to_matchable(),
7883                        Ref::new("NakedIdentifierSegment").to_matchable(),
7884                    ])
7885                    .to_matchable(),
7886                    Sequence::new(vec![
7887                        Ref::keyword("SET").to_matchable(),
7888                        one_of(vec![
7889                            Ref::keyword("PASSWORD").to_matchable(),
7890                            Ref::keyword("SESSION").to_matchable(),
7891                        ])
7892                        .to_matchable(),
7893                        Ref::keyword("POLICY").to_matchable(),
7894                        Ref::new("TableReferenceSegment").to_matchable(),
7895                    ])
7896                    .to_matchable(),
7897                    Sequence::new(vec![
7898                        Ref::keyword("SET").to_matchable(),
7899                        Ref::new("TagEqualsSegment").to_matchable(),
7900                    ])
7901                    .to_matchable(),
7902                    Sequence::new(vec![
7903                        Ref::keyword("SET").to_matchable(),
7904                        Delimited::new(vec![
7905                            Sequence::new(vec![
7906                                Ref::new("ParameterNameSegment").to_matchable(),
7907                                Ref::new("EqualsSegment").to_matchable(),
7908                                one_of(vec![
7909                                    Ref::new("BooleanLiteralGrammar").to_matchable(),
7910                                    Ref::new("QuotedLiteralSegment").to_matchable(),
7911                                    Ref::new("NumericLiteralSegment").to_matchable(),
7912                                    Ref::new("NakedIdentifierSegment").to_matchable(),
7913                                ])
7914                                .to_matchable(),
7915                            ])
7916                            .to_matchable(),
7917                        ])
7918                        .to_matchable(),
7919                    ])
7920                    .to_matchable(),
7921                    Sequence::new(vec![
7922                        Ref::keyword("UNSET").to_matchable(),
7923                        one_of(vec![
7924                            Ref::keyword("PASSWORD").to_matchable(),
7925                            Ref::keyword("SESSION").to_matchable(),
7926                        ])
7927                        .to_matchable(),
7928                        Ref::keyword("POLICY").to_matchable(),
7929                    ])
7930                    .to_matchable(),
7931                    Sequence::new(vec![
7932                        Ref::keyword("UNSET").to_matchable(),
7933                        one_of(vec![
7934                            Sequence::new(vec![
7935                                Ref::keyword("TAG").to_matchable(),
7936                                Delimited::new(vec![
7937                                    Ref::new("TagReferenceSegment").to_matchable(),
7938                                ])
7939                                .to_matchable(),
7940                            ])
7941                            .to_matchable(),
7942                            Delimited::new(vec![Ref::new("NakedIdentifierSegment").to_matchable()])
7943                                .to_matchable(),
7944                        ])
7945                        .to_matchable(),
7946                    ])
7947                    .to_matchable(),
7948                ])
7949                .to_matchable(),
7950            ])
7951            .to_matchable()
7952            .into(),
7953        ),
7954        (
7955            "ShowStatementSegment".into(),
7956            NodeMatcher::new(SyntaxKind::ShowStatement, |_| {
7957                let object_types_plural = one_of(vec![
7958                    Ref::keyword("PARAMETERS").to_matchable(),
7959                    Sequence::new(vec![
7960                        Ref::keyword("GLOBAL").to_matchable(),
7961                        Ref::keyword("ACCOUNTS").to_matchable(),
7962                    ])
7963                    .to_matchable(),
7964                    Ref::keyword("REGIONS").to_matchable(),
7965                    Sequence::new(vec![
7966                        Ref::keyword("REPLICATION").to_matchable(),
7967                        Ref::keyword("ACCOUNTS").to_matchable(),
7968                    ])
7969                    .to_matchable(),
7970                    Sequence::new(vec![
7971                        Ref::keyword("REPLICATION").to_matchable(),
7972                        Ref::keyword("DATABASES").to_matchable(),
7973                    ])
7974                    .to_matchable(),
7975                    Ref::keyword("PARAMETERS").to_matchable(),
7976                    Ref::keyword("VARIABLES").to_matchable(),
7977                    Ref::keyword("TRANSACTIONS").to_matchable(),
7978                    Ref::keyword("LOCKS").to_matchable(),
7979                    Ref::keyword("PARAMETERS").to_matchable(),
7980                    Ref::keyword("FUNCTIONS").to_matchable(),
7981                    Sequence::new(vec![
7982                        Ref::keyword("NETWORK").to_matchable(),
7983                        Ref::keyword("POLICIES").to_matchable(),
7984                    ])
7985                    .to_matchable(),
7986                    Ref::keyword("SHARES").to_matchable(),
7987                    Ref::keyword("ROLES").to_matchable(),
7988                    Ref::keyword("GRANTS").to_matchable(),
7989                    Ref::keyword("USERS").to_matchable(),
7990                    Ref::keyword("WAREHOUSES").to_matchable(),
7991                    Ref::keyword("DATABASES").to_matchable(),
7992                    Sequence::new(vec![
7993                        one_of(vec![
7994                            Ref::keyword("API").to_matchable(),
7995                            Ref::keyword("NOTIFICATION").to_matchable(),
7996                            Ref::keyword("SECURITY").to_matchable(),
7997                            Ref::keyword("STORAGE").to_matchable(),
7998                        ])
7999                        .config(|this| this.optional())
8000                        .to_matchable(),
8001                        Ref::keyword("INTEGRATIONS").to_matchable(),
8002                    ])
8003                    .to_matchable(),
8004                    Ref::keyword("SCHEMAS").to_matchable(),
8005                    Ref::keyword("OBJECTS").to_matchable(),
8006                    Ref::keyword("TABLES").to_matchable(),
8007                    Sequence::new(vec![
8008                        Ref::keyword("EXTERNAL").to_matchable(),
8009                        Ref::keyword("TABLES").to_matchable(),
8010                    ])
8011                    .to_matchable(),
8012                    Ref::keyword("VIEWS").to_matchable(),
8013                    Sequence::new(vec![
8014                        Ref::keyword("MATERIALIZED").to_matchable(),
8015                        Ref::keyword("VIEWS").to_matchable(),
8016                    ])
8017                    .to_matchable(),
8018                    Sequence::new(vec![
8019                        Ref::keyword("MASKING").to_matchable(),
8020                        Ref::keyword("POLICIES").to_matchable(),
8021                    ])
8022                    .to_matchable(),
8023                    Ref::keyword("COLUMNS").to_matchable(),
8024                    Sequence::new(vec![
8025                        Ref::keyword("FILE").to_matchable(),
8026                        Ref::keyword("FORMATS").to_matchable(),
8027                    ])
8028                    .to_matchable(),
8029                    Ref::keyword("SEQUENCES").to_matchable(),
8030                    Ref::keyword("STAGES").to_matchable(),
8031                    Ref::keyword("PIPES").to_matchable(),
8032                    Ref::keyword("STREAMS").to_matchable(),
8033                    Ref::keyword("TASKS").to_matchable(),
8034                    Sequence::new(vec![
8035                        Ref::keyword("USER").to_matchable(),
8036                        Ref::keyword("FUNCTIONS").to_matchable(),
8037                    ])
8038                    .to_matchable(),
8039                    Sequence::new(vec![
8040                        Ref::keyword("EXTERNAL").to_matchable(),
8041                        Ref::keyword("FUNCTIONS").to_matchable(),
8042                    ])
8043                    .to_matchable(),
8044                    Ref::keyword("PROCEDURES").to_matchable(),
8045                    Sequence::new(vec![
8046                        Ref::keyword("FUTURE").to_matchable(),
8047                        Ref::keyword("GRANTS").to_matchable(),
8048                    ])
8049                    .to_matchable(),
8050                ]);
8051
8052                let object_scope_types = one_of(vec![
8053                    Ref::keyword("ACCOUNT").to_matchable(),
8054                    Ref::keyword("SESSION").to_matchable(),
8055                    Sequence::new(vec![
8056                        one_of(vec![
8057                            Ref::keyword("DATABASE").to_matchable(),
8058                            Ref::keyword("SCHEMA").to_matchable(),
8059                            Ref::keyword("SHARE").to_matchable(),
8060                            Ref::keyword("ROLE").to_matchable(),
8061                            Ref::keyword("TABLE").to_matchable(),
8062                            Ref::keyword("TASK").to_matchable(),
8063                            Ref::keyword("USER").to_matchable(),
8064                            Ref::keyword("WAREHOUSE").to_matchable(),
8065                            Ref::keyword("VIEW").to_matchable(),
8066                        ])
8067                        .to_matchable(),
8068                        Ref::new("ObjectReferenceSegment").optional().to_matchable(),
8069                    ])
8070                    .to_matchable(),
8071                ]);
8072
8073                Sequence::new(vec![
8074                    Ref::keyword("SHOW").to_matchable(),
8075                    Ref::keyword("TERSE").optional().to_matchable(),
8076                    object_types_plural.to_matchable(),
8077                    Ref::keyword("HISTORY").optional().to_matchable(),
8078                    Sequence::new(vec![
8079                        Ref::keyword("LIKE").to_matchable(),
8080                        Ref::new("QuotedLiteralSegment").to_matchable(),
8081                    ])
8082                    .config(|this| this.optional())
8083                    .to_matchable(),
8084                    Sequence::new(vec![
8085                        one_of(vec![
8086                            Ref::keyword("ON").to_matchable(),
8087                            Ref::keyword("TO").to_matchable(),
8088                            Ref::keyword("OF").to_matchable(),
8089                            Ref::keyword("IN").to_matchable(),
8090                        ])
8091                        .to_matchable(),
8092                        one_of(vec![
8093                            Sequence::new(vec![object_scope_types.to_matchable()]).to_matchable(),
8094                            Ref::new("ObjectReferenceSegment").to_matchable(),
8095                        ])
8096                        .to_matchable(),
8097                    ])
8098                    .config(|this| this.optional())
8099                    .to_matchable(),
8100                    Sequence::new(vec![
8101                        Ref::keyword("STARTS").to_matchable(),
8102                        Ref::keyword("WITH").to_matchable(),
8103                        Ref::new("QuotedLiteralSegment").to_matchable(),
8104                    ])
8105                    .config(|this| this.optional())
8106                    .to_matchable(),
8107                    Sequence::new(vec![
8108                        Ref::keyword("WITH").to_matchable(),
8109                        Ref::keyword("PRIMARY").to_matchable(),
8110                        Ref::new("ObjectReferenceSegment").to_matchable(),
8111                    ])
8112                    .config(|this| this.optional())
8113                    .to_matchable(),
8114                    Sequence::new(vec![
8115                        Ref::new("LimitClauseSegment").to_matchable(),
8116                        Sequence::new(vec![
8117                            Ref::keyword("FROM").to_matchable(),
8118                            Ref::new("QuotedLiteralSegment").to_matchable(),
8119                        ])
8120                        .config(|this| this.optional())
8121                        .to_matchable(),
8122                    ])
8123                    .config(|this| this.optional())
8124                    .to_matchable(),
8125                ])
8126                .to_matchable()
8127            })
8128            .to_matchable()
8129            .into(),
8130        ),
8131        (
8132            "AlterUserStatementSegment".into(),
8133            NodeMatcher::new(SyntaxKind::AlterUserStatement, |_| {
8134                Sequence::new(vec![
8135                    Ref::keyword("ALTER").to_matchable(),
8136                    Ref::keyword("USER").to_matchable(),
8137                    Sequence::new(vec![
8138                        Ref::keyword("IF").to_matchable(),
8139                        Ref::keyword("EXISTS").to_matchable(),
8140                    ])
8141                    .config(|this| this.optional())
8142                    .to_matchable(),
8143                    Ref::new("RoleReferenceSegment").to_matchable(),
8144                    one_of(vec![
8145                        Sequence::new(vec![
8146                            Ref::keyword("RENAME").to_matchable(),
8147                            Ref::keyword("TO").to_matchable(),
8148                            Ref::new("ObjectReferenceSegment").to_matchable(),
8149                        ])
8150                        .to_matchable(),
8151                        Sequence::new(vec![
8152                            Ref::keyword("RESET").to_matchable(),
8153                            Ref::keyword("PASSWORD").to_matchable(),
8154                        ])
8155                        .to_matchable(),
8156                        Sequence::new(vec![
8157                            Ref::keyword("ABORT").to_matchable(),
8158                            Ref::keyword("ALL").to_matchable(),
8159                            Ref::keyword("QUERIES").to_matchable(),
8160                        ])
8161                        .to_matchable(),
8162                        Sequence::new(vec![
8163                            Ref::keyword("ADD").to_matchable(),
8164                            Ref::keyword("DELEGATED").to_matchable(),
8165                            Ref::keyword("AUTHORIZATION").to_matchable(),
8166                            Ref::keyword("OF").to_matchable(),
8167                            Ref::keyword("ROLE").to_matchable(),
8168                            Ref::new("ObjectReferenceSegment").to_matchable(),
8169                            Ref::keyword("TO").to_matchable(),
8170                            Ref::keyword("SECURITY").to_matchable(),
8171                            Ref::keyword("INTEGRATION").to_matchable(),
8172                            Ref::new("ObjectReferenceSegment").to_matchable(),
8173                        ])
8174                        .to_matchable(),
8175                        Sequence::new(vec![
8176                            Ref::keyword("REMOVE").to_matchable(),
8177                            Ref::keyword("DELEGATED").to_matchable(),
8178                            one_of(vec![
8179                                Sequence::new(vec![
8180                                    Ref::keyword("AUTHORIZATION").to_matchable(),
8181                                    Ref::keyword("OF").to_matchable(),
8182                                    Ref::keyword("ROLE").to_matchable(),
8183                                    Ref::new("ObjectReferenceSegment").to_matchable(),
8184                                ])
8185                                .to_matchable(),
8186                                Ref::keyword("AUTHORIZATIONS").to_matchable(),
8187                            ])
8188                            .to_matchable(),
8189                            Ref::keyword("FROM").to_matchable(),
8190                            Ref::keyword("SECURITY").to_matchable(),
8191                            Ref::keyword("INTEGRATION").to_matchable(),
8192                            Ref::new("ObjectReferenceSegment").to_matchable(),
8193                        ])
8194                        .to_matchable(),
8195                        Sequence::new(vec![
8196                            Ref::keyword("SET").to_matchable(),
8197                            Delimited::new(vec![
8198                                Sequence::new(vec![
8199                                    Ref::new("ParameterNameSegment").to_matchable(),
8200                                    Ref::new("EqualsSegment").to_matchable(),
8201                                    one_of(vec![
8202                                        Ref::new("LiteralGrammar").to_matchable(),
8203                                        Ref::new("ObjectReferenceSegment").to_matchable(),
8204                                    ])
8205                                    .to_matchable(),
8206                                ])
8207                                .to_matchable(),
8208                            ])
8209                            .to_matchable(),
8210                        ])
8211                        .to_matchable(),
8212                        Sequence::new(vec![
8213                            Ref::keyword("UNSET").to_matchable(),
8214                            Delimited::new(vec![Ref::new("ParameterNameSegment").to_matchable()])
8215                                .to_matchable(),
8216                        ])
8217                        .to_matchable(),
8218                    ])
8219                    .to_matchable(),
8220                ])
8221                .to_matchable()
8222            })
8223            .to_matchable()
8224            .into(),
8225        ),
8226    ]);
8227
8228    snowflake_dialect.replace_grammar(
8229        "CreateRoleStatementSegment",
8230        Sequence::new(vec![
8231            Ref::keyword("CREATE").to_matchable(),
8232            Sequence::new(vec![
8233                Ref::keyword("OR").to_matchable(),
8234                Ref::keyword("REPLACE").to_matchable(),
8235            ])
8236            .config(|this| this.optional())
8237            .to_matchable(),
8238            Ref::keyword("ROLE").to_matchable(),
8239            Sequence::new(vec![
8240                Ref::keyword("IF").to_matchable(),
8241                Ref::keyword("NOT").to_matchable(),
8242                Ref::keyword("EXISTS").to_matchable(),
8243            ])
8244            .config(|this| this.optional())
8245            .to_matchable(),
8246            Ref::new("RoleReferenceSegment").to_matchable(),
8247            Sequence::new(vec![
8248                Ref::keyword("COMMENT").to_matchable(),
8249                Ref::new("EqualsSegment").to_matchable(),
8250                Ref::new("QuotedLiteralSegment").to_matchable(),
8251            ])
8252            .config(|this| this.optional())
8253            .to_matchable(),
8254        ])
8255        .to_matchable(),
8256    );
8257
8258    snowflake_dialect.replace_grammar(
8259        "ExplainStatementSegment",
8260        Sequence::new(vec![
8261            Ref::keyword("EXPLAIN").to_matchable(),
8262            Sequence::new(vec![
8263                Ref::keyword("USING").to_matchable(),
8264                one_of(vec![
8265                    Ref::keyword("TABULAR").to_matchable(),
8266                    Ref::keyword("JSON").to_matchable(),
8267                    Ref::keyword("TEXT").to_matchable(),
8268                ])
8269                .to_matchable(),
8270            ])
8271            .config(|this| this.optional())
8272            .to_matchable(),
8273            ansi::explainable_stmt().to_matchable(),
8274        ])
8275        .to_matchable(),
8276    );
8277
8278    snowflake_dialect.add([
8279        (
8280            "AlterSessionStatementSegment".into(),
8281            NodeMatcher::new(SyntaxKind::AlterSessionStatement, |_| {
8282                Sequence::new(vec![
8283                    Ref::keyword("ALTER").to_matchable(),
8284                    Ref::keyword("SESSION").to_matchable(),
8285                    one_of(vec![
8286                        Ref::new("AlterSessionSetClauseSegment").to_matchable(),
8287                        Ref::new("AlterSessionUnsetClauseSegment").to_matchable(),
8288                    ])
8289                    .to_matchable(),
8290                ])
8291                .to_matchable()
8292            })
8293            .to_matchable()
8294            .into(),
8295        ),
8296        (
8297            "AlterSessionSetClauseSegment".into(),
8298            NodeMatcher::new(SyntaxKind::AlterSessionSetStatement, |_| {
8299                Sequence::new(vec![
8300                    Ref::keyword("SET").to_matchable(),
8301                    Ref::new("ParameterNameSegment").to_matchable(),
8302                    Ref::new("EqualsSegment").to_matchable(),
8303                    one_of(vec![
8304                        Ref::new("BooleanLiteralGrammar").to_matchable(),
8305                        Ref::new("QuotedLiteralSegment").to_matchable(),
8306                        Ref::new("NumericLiteralSegment").to_matchable(),
8307                    ])
8308                    .to_matchable(),
8309                ])
8310                .to_matchable()
8311            })
8312            .to_matchable()
8313            .into(),
8314        ),
8315        (
8316            "AlterSessionUnsetClauseSegment".into(),
8317            NodeMatcher::new(SyntaxKind::AlterSessionUnsetClause, |_| {
8318                Sequence::new(vec![
8319                    Ref::keyword("UNSET").to_matchable(),
8320                    Delimited::new(vec![Ref::new("ParameterNameSegment").to_matchable()])
8321                        .to_matchable(),
8322                ])
8323                .to_matchable()
8324            })
8325            .to_matchable()
8326            .into(),
8327        ),
8328        (
8329            "AlterTaskStatementSegment".into(),
8330            NodeMatcher::new(SyntaxKind::AlterTaskStatement, |_| {
8331                Sequence::new(vec![
8332                    Ref::keyword("ALTER").to_matchable(),
8333                    Ref::keyword("TASK").to_matchable(),
8334                    Sequence::new(vec![
8335                        Ref::keyword("IF").to_matchable(),
8336                        Ref::keyword("EXISTS").to_matchable(),
8337                    ])
8338                    .config(|this| this.optional())
8339                    .to_matchable(),
8340                    Ref::new("ObjectReferenceSegment").to_matchable(),
8341                    one_of(vec![
8342                        Ref::keyword("RESUME").to_matchable(),
8343                        Ref::keyword("SUSPEND").to_matchable(),
8344                        Sequence::new(vec![
8345                            Ref::keyword("REMOVE").to_matchable(),
8346                            Ref::keyword("AFTER").to_matchable(),
8347                            Ref::new("ObjectReferenceSegment").to_matchable(),
8348                        ])
8349                        .to_matchable(),
8350                        Sequence::new(vec![
8351                            Ref::keyword("ADD").to_matchable(),
8352                            Ref::keyword("AFTER").to_matchable(),
8353                            Ref::new("ObjectReferenceSegment").to_matchable(),
8354                        ])
8355                        .to_matchable(),
8356                        Ref::new("AlterTaskSpecialSetClauseSegment").to_matchable(),
8357                        Ref::new("AlterTaskSetClauseSegment").to_matchable(),
8358                        Ref::new("AlterTaskUnsetClauseSegment").to_matchable(),
8359                        Sequence::new(vec![
8360                            Ref::keyword("MODIFY").to_matchable(),
8361                            Ref::keyword("AS").to_matchable(),
8362                            ansi::explainable_stmt().to_matchable(),
8363                        ])
8364                        .to_matchable(),
8365                        Sequence::new(vec![
8366                            Ref::keyword("MODIFY").to_matchable(),
8367                            Ref::keyword("WHEN").to_matchable(),
8368                            Ref::new("BooleanLiteralGrammar").to_matchable(),
8369                        ])
8370                        .to_matchable(),
8371                    ])
8372                    .to_matchable(),
8373                ])
8374                .to_matchable()
8375            })
8376            .to_matchable()
8377            .into(),
8378        ),
8379        (
8380            "AlterTaskSpecialSetClauseSegment".into(),
8381            NodeMatcher::new(SyntaxKind::AlterTaskSpecialSetClause, |_| {
8382                Sequence::new(vec![
8383                    Ref::keyword("SET").to_matchable(),
8384                    any_set_of(vec![
8385                        Sequence::new(vec![
8386                            Ref::keyword("WAREHOUSE").to_matchable(),
8387                            Ref::new("EqualsSegment").to_matchable(),
8388                            Ref::new("ObjectReferenceSegment").to_matchable(),
8389                        ])
8390                        .config(|this| this.optional())
8391                        .to_matchable(),
8392                        Sequence::new(vec![
8393                            Ref::keyword("SCHEDULE").to_matchable(),
8394                            Ref::new("EqualsSegment").to_matchable(),
8395                            Ref::new("QuotedLiteralSegment").to_matchable(),
8396                        ])
8397                        .config(|this| this.optional())
8398                        .to_matchable(),
8399                        Sequence::new(vec![
8400                            Ref::keyword("ALLOW_OVERLAPPING_EXECUTION").to_matchable(),
8401                            Ref::new("EqualsSegment").to_matchable(),
8402                            Ref::new("BooleanLiteralGrammar").to_matchable(),
8403                        ])
8404                        .config(|this| this.optional())
8405                        .to_matchable(),
8406                    ])
8407                    .config(|this| this.min_times(1))
8408                    .to_matchable(),
8409                ])
8410                .to_matchable()
8411            })
8412            .to_matchable()
8413            .into(),
8414        ),
8415        (
8416            "AlterTaskSetClauseSegment".into(),
8417            NodeMatcher::new(SyntaxKind::AlterTaskSetClause, |_| {
8418                Sequence::new(vec![
8419                    Ref::keyword("SET").to_matchable(),
8420                    Delimited::new(vec![
8421                        Sequence::new(vec![
8422                            Ref::new("ParameterNameSegment").to_matchable(),
8423                            Ref::new("EqualsSegment").to_matchable(),
8424                            one_of(vec![
8425                                Ref::new("BooleanLiteralGrammar").to_matchable(),
8426                                Ref::new("QuotedLiteralSegment").to_matchable(),
8427                                Ref::new("NumericLiteralSegment").to_matchable(),
8428                            ])
8429                            .to_matchable(),
8430                        ])
8431                        .to_matchable(),
8432                    ])
8433                    .to_matchable(),
8434                ])
8435                .to_matchable()
8436            })
8437            .to_matchable()
8438            .into(),
8439        ),
8440        (
8441            "AlterTaskUnsetClauseSegment".into(),
8442            NodeMatcher::new(SyntaxKind::AlterTaskUnsetClause, |_| {
8443                Sequence::new(vec![
8444                    Ref::keyword("UNSET").to_matchable(),
8445                    Delimited::new(vec![Ref::new("ParameterNameSegment").to_matchable()])
8446                        .to_matchable(),
8447                ])
8448                .to_matchable()
8449            })
8450            .to_matchable()
8451            .into(),
8452        ),
8453        (
8454            //Snowflake's EXECUTE IMMEDIATE clause.
8455            // https://docs.snowflake.com/en/sql-reference/sql/execute-immediate
8456            "ExecuteImmediateClauseSegment".into(),
8457            NodeMatcher::new(SyntaxKind::ExecuteImmediateClause, |_| {
8458                Sequence::new(vec![
8459                    Ref::keyword("EXECUTE").to_matchable(),
8460                    Ref::keyword("IMMEDIATE").to_matchable(),
8461                    one_of(vec![
8462                        Ref::new("QuotedLiteralSegment").to_matchable(),
8463                        Ref::new("ReferencedVariableNameSegment").to_matchable(),
8464                        Sequence::new(vec![
8465                            Ref::new("ColonSegment").to_matchable(),
8466                            Ref::new("LocalVariableNameSegment").to_matchable(),
8467                        ])
8468                        .to_matchable(),
8469                    ])
8470                    .to_matchable(),
8471                    Sequence::new(vec![
8472                        Ref::keyword("USING").to_matchable(),
8473                        Bracketed::new(vec![
8474                            Delimited::new(vec![
8475                                Ref::new("LocalVariableNameSegment").to_matchable(),
8476                            ])
8477                            .to_matchable(),
8478                        ])
8479                        .to_matchable(),
8480                    ])
8481                    .config(|this| this.optional())
8482                    .to_matchable(),
8483                ])
8484                .to_matchable()
8485            })
8486            .to_matchable()
8487            .into(),
8488        ),
8489        (
8490            "ExecuteTaskClauseSegment".into(),
8491            NodeMatcher::new(SyntaxKind::ExecuteTaskClause, |_| {
8492                Sequence::new(vec![
8493                    Ref::keyword("EXECUTE").to_matchable(),
8494                    Ref::keyword("TASK").to_matchable(),
8495                    Ref::new("ObjectReferenceSegment").to_matchable(),
8496                ])
8497                .to_matchable()
8498            })
8499            .to_matchable()
8500            .into(),
8501        ),
8502        (
8503            "CreateSequenceStatementSegment".into(),
8504            NodeMatcher::new(SyntaxKind::CreateSequenceStatement, |_| {
8505                Sequence::new(vec![
8506                    Ref::keyword("CREATE").to_matchable(),
8507                    Sequence::new(vec![
8508                        Ref::keyword("OR").to_matchable(),
8509                        Ref::keyword("REPLACE").to_matchable(),
8510                    ])
8511                    .config(|this| this.optional())
8512                    .to_matchable(),
8513                    Ref::keyword("SEQUENCE").to_matchable(),
8514                    Ref::new("IfNotExistsGrammar").optional().to_matchable(),
8515                    Ref::new("SequenceReferenceSegment").to_matchable(),
8516                    Ref::keyword("WITH").optional().to_matchable(),
8517                    Sequence::new(vec![
8518                        Ref::keyword("START").to_matchable(),
8519                        Ref::keyword("WITH").optional().to_matchable(),
8520                        Ref::new("EqualsSegment").optional().to_matchable(),
8521                        Ref::new("IntegerSegment").to_matchable(),
8522                    ])
8523                    .config(|this| this.optional())
8524                    .to_matchable(),
8525                    Sequence::new(vec![
8526                        Ref::keyword("INCREMENT").to_matchable(),
8527                        Ref::keyword("BY").optional().to_matchable(),
8528                        Ref::new("EqualsSegment").optional().to_matchable(),
8529                        Ref::new("IntegerSegment").to_matchable(),
8530                    ])
8531                    .config(|this| this.optional())
8532                    .to_matchable(),
8533                    one_of(vec![
8534                        Ref::keyword("ORDER").to_matchable(),
8535                        Ref::keyword("NOORDER").to_matchable(),
8536                    ])
8537                    .config(|this| this.optional())
8538                    .to_matchable(),
8539                    Ref::new("CommentEqualsClauseSegment")
8540                        .optional()
8541                        .to_matchable(),
8542                ])
8543                .to_matchable()
8544            })
8545            .to_matchable()
8546            .into(),
8547        ),
8548        (
8549            "AlterSequenceStatementSegment".into(),
8550            NodeMatcher::new(SyntaxKind::AlterSequenceStatement, |_| {
8551                Sequence::new(vec![
8552                    Ref::keyword("ALTER").to_matchable(),
8553                    Ref::keyword("SEQUENCE").to_matchable(),
8554                    Ref::new("IfExistsGrammar").optional().to_matchable(),
8555                    Ref::new("SequenceReferenceSegment").to_matchable(),
8556                    Sequence::new(vec![
8557                        Ref::keyword("SET").optional().to_matchable(),
8558                        any_set_of(vec![
8559                            Sequence::new(vec![
8560                                Ref::keyword("INCREMENT").to_matchable(),
8561                                Ref::keyword("BY").optional().to_matchable(),
8562                                Ref::new("EqualsSegment").optional().to_matchable(),
8563                                Ref::new("IntegerSegment").to_matchable(),
8564                            ])
8565                            .config(|this| this.optional())
8566                            .to_matchable(),
8567                            one_of(vec![
8568                                Ref::keyword("ORDER").to_matchable(),
8569                                Ref::keyword("NOORDER").to_matchable(),
8570                            ])
8571                            .to_matchable(),
8572                            Ref::new("CommentEqualsClauseSegment").to_matchable(),
8573                        ])
8574                        .to_matchable(),
8575                    ])
8576                    .config(|this| this.optional())
8577                    .to_matchable(),
8578                    Sequence::new(vec![
8579                        Ref::keyword("UNSET").to_matchable(),
8580                        Ref::keyword("COMMENT").to_matchable(),
8581                    ])
8582                    .config(|this| this.optional())
8583                    .to_matchable(),
8584                    Sequence::new(vec![
8585                        Ref::keyword("RENAME").to_matchable(),
8586                        Ref::keyword("TO").to_matchable(),
8587                        Ref::new("SequenceReferenceSegment").to_matchable(),
8588                    ])
8589                    .config(|this| this.optional())
8590                    .to_matchable(),
8591                ])
8592                .to_matchable()
8593            })
8594            .to_matchable()
8595            .into(),
8596        ),
8597    ]);
8598
8599    snowflake_dialect.replace_grammar(
8600        "MergeUpdateClauseSegment",
8601        Sequence::new(vec![
8602            Ref::keyword("UPDATE").to_matchable(),
8603            Ref::new("SetClauseListSegment").to_matchable(),
8604            Ref::new("WhereClauseSegment").optional().to_matchable(),
8605        ])
8606        .to_matchable(),
8607    );
8608
8609    snowflake_dialect.replace_grammar(
8610        "MergeDeleteClauseSegment",
8611        Sequence::new(vec![
8612            Ref::keyword("DELETE").to_matchable(),
8613            Ref::new("WhereClauseSegment").optional().to_matchable(),
8614        ])
8615        .to_matchable(),
8616    );
8617
8618    snowflake_dialect.replace_grammar(
8619        "MergeInsertClauseSegment",
8620        Sequence::new(vec![
8621            Ref::keyword("INSERT").to_matchable(),
8622            MetaSegment::indent().to_matchable(),
8623            Ref::new("BracketedColumnReferenceListGrammar")
8624                .optional()
8625                .to_matchable(),
8626            MetaSegment::dedent().to_matchable(),
8627            Ref::new("ValuesClauseSegment").optional().to_matchable(),
8628            Ref::new("WhereClauseSegment").optional().to_matchable(),
8629        ])
8630        .to_matchable(),
8631    );
8632
8633    snowflake_dialect.add([
8634        (
8635            "DeleteStatementSegment".into(),
8636            NodeMatcher::new(SyntaxKind::DeleteStatement, |_| {
8637                Sequence::new(vec![
8638                    Ref::keyword("DELETE").to_matchable(),
8639                    Ref::keyword("FROM").to_matchable(),
8640                    Ref::new("TableReferenceSegment").to_matchable(),
8641                    Ref::new("AliasExpressionSegment").optional().to_matchable(),
8642                    Sequence::new(vec![
8643                        Ref::keyword("USING").to_matchable(),
8644                        MetaSegment::indent().to_matchable(),
8645                        Delimited::new(vec![
8646                            Sequence::new(vec![
8647                                Ref::new("TableExpressionSegment").to_matchable(),
8648                                Ref::new("AliasExpressionSegment").optional().to_matchable(),
8649                            ])
8650                            .to_matchable(),
8651                        ])
8652                        .to_matchable(),
8653                        MetaSegment::dedent().to_matchable(),
8654                    ])
8655                    .config(|this| this.optional())
8656                    .to_matchable(),
8657                    Ref::new("WhereClauseSegment").optional().to_matchable(),
8658                ])
8659                .to_matchable()
8660            })
8661            .to_matchable()
8662            .into(),
8663        ),
8664        (
8665            "DescribeStatementSegment".into(),
8666            NodeMatcher::new(SyntaxKind::DescribeStatement, |_| {
8667                Sequence::new(vec![
8668                    one_of(vec![
8669                        Ref::keyword("DESCRIBE").to_matchable(),
8670                        Ref::keyword("DESC").to_matchable(),
8671                    ])
8672                    .to_matchable(),
8673                    one_of(vec![
8674                        Sequence::new(vec![
8675                            Ref::keyword("RESULT").to_matchable(),
8676                            one_of(vec![
8677                                Ref::new("QuotedLiteralSegment").to_matchable(),
8678                                Sequence::new(vec![
8679                                    Ref::keyword("LAST_QUERY_ID").to_matchable(),
8680                                    Bracketed::new(vec![]).to_matchable(),
8681                                ])
8682                                .to_matchable(),
8683                            ])
8684                            .to_matchable(),
8685                        ])
8686                        .to_matchable(),
8687                        Sequence::new(vec![
8688                            Ref::keyword("NETWORK").to_matchable(),
8689                            Ref::keyword("POLICY").to_matchable(),
8690                            Ref::new("ObjectReferenceSegment").to_matchable(),
8691                        ])
8692                        .to_matchable(),
8693                        Sequence::new(vec![
8694                            Ref::keyword("SHARE").to_matchable(),
8695                            Ref::new("ObjectReferenceSegment").to_matchable(),
8696                            Sequence::new(vec![
8697                                Ref::new("DotSegment").to_matchable(),
8698                                Ref::new("ObjectReferenceSegment").to_matchable(),
8699                            ])
8700                            .config(|this| this.optional())
8701                            .to_matchable(),
8702                        ])
8703                        .to_matchable(),
8704                        Sequence::new(vec![
8705                            Ref::keyword("USER").to_matchable(),
8706                            Ref::new("ObjectReferenceSegment").to_matchable(),
8707                        ])
8708                        .to_matchable(),
8709                        Sequence::new(vec![
8710                            Ref::keyword("WAREHOUSE").to_matchable(),
8711                            Ref::new("ObjectReferenceSegment").to_matchable(),
8712                        ])
8713                        .to_matchable(),
8714                        Sequence::new(vec![
8715                            Ref::keyword("DATABASE").to_matchable(),
8716                            Ref::new("DatabaseReferenceSegment").to_matchable(),
8717                        ])
8718                        .to_matchable(),
8719                        Sequence::new(vec![
8720                            one_of(vec![
8721                                Ref::keyword("API").to_matchable(),
8722                                Ref::keyword("NOTIFICATION").to_matchable(),
8723                                Ref::keyword("SECURITY").to_matchable(),
8724                                Ref::keyword("STORAGE").to_matchable(),
8725                            ])
8726                            .config(|this| this.optional())
8727                            .to_matchable(),
8728                            Ref::keyword("INTEGRATION").to_matchable(),
8729                            Ref::new("ObjectReferenceSegment").to_matchable(),
8730                        ])
8731                        .to_matchable(),
8732                        Sequence::new(vec![
8733                            Ref::keyword("SESSION").to_matchable(),
8734                            Ref::keyword("POLICY").to_matchable(),
8735                            Ref::new("ObjectReferenceSegment").to_matchable(),
8736                        ])
8737                        .to_matchable(),
8738                        Sequence::new(vec![
8739                            Ref::keyword("SCHEMA").to_matchable(),
8740                            Ref::new("SchemaReferenceSegment").to_matchable(),
8741                        ])
8742                        .to_matchable(),
8743                        Sequence::new(vec![
8744                            Ref::keyword("TABLE").to_matchable(),
8745                            Ref::new("TableReferenceSegment").to_matchable(),
8746                            Sequence::new(vec![
8747                                Ref::keyword("TYPE").to_matchable(),
8748                                Ref::new("EqualsSegment").to_matchable(),
8749                                one_of(vec![
8750                                    Ref::keyword("COLUMNS").to_matchable(),
8751                                    Ref::keyword("STAGE").to_matchable(),
8752                                ])
8753                                .to_matchable(),
8754                            ])
8755                            .config(|this| this.optional())
8756                            .to_matchable(),
8757                        ])
8758                        .to_matchable(),
8759                        Sequence::new(vec![
8760                            Ref::keyword("EXTERNAL").to_matchable(),
8761                            Ref::keyword("TABLE").to_matchable(),
8762                            Ref::new("TableReferenceSegment").to_matchable(),
8763                            Sequence::new(vec![
8764                                Ref::keyword("TYPE").to_matchable(),
8765                                Ref::new("EqualsSegment").to_matchable(),
8766                                one_of(vec![
8767                                    Ref::keyword("COLUMNS").to_matchable(),
8768                                    Ref::keyword("STAGE").to_matchable(),
8769                                ])
8770                                .to_matchable(),
8771                            ])
8772                            .config(|this| this.optional())
8773                            .to_matchable(),
8774                        ])
8775                        .to_matchable(),
8776                        Sequence::new(vec![
8777                            Ref::keyword("VIEW").to_matchable(),
8778                            Ref::new("TableReferenceSegment").to_matchable(),
8779                        ])
8780                        .to_matchable(),
8781                        Sequence::new(vec![
8782                            Ref::keyword("MATERIALIZED").to_matchable(),
8783                            Ref::keyword("VIEW").to_matchable(),
8784                            Ref::new("TableReferenceSegment").to_matchable(),
8785                        ])
8786                        .to_matchable(),
8787                        Sequence::new(vec![
8788                            Ref::keyword("SEQUENCE").to_matchable(),
8789                            Ref::new("SequenceReferenceSegment").to_matchable(),
8790                        ])
8791                        .to_matchable(),
8792                        Sequence::new(vec![
8793                            Ref::keyword("MASKING").to_matchable(),
8794                            Ref::keyword("POLICY").to_matchable(),
8795                            Ref::new("ObjectReferenceSegment").to_matchable(),
8796                        ])
8797                        .to_matchable(),
8798                        Sequence::new(vec![
8799                            Ref::keyword("ROW").to_matchable(),
8800                            Ref::keyword("ACCESS").to_matchable(),
8801                            Ref::keyword("POLICY").to_matchable(),
8802                            Ref::new("ObjectReferenceSegment").to_matchable(),
8803                        ])
8804                        .to_matchable(),
8805                        Sequence::new(vec![
8806                            Ref::keyword("FILE").to_matchable(),
8807                            Ref::keyword("FORMAT").to_matchable(),
8808                            Ref::new("ObjectReferenceSegment").to_matchable(),
8809                        ])
8810                        .to_matchable(),
8811                        Sequence::new(vec![
8812                            Ref::keyword("STAGE").to_matchable(),
8813                            Ref::new("ObjectReferenceSegment").to_matchable(),
8814                        ])
8815                        .to_matchable(),
8816                        Sequence::new(vec![
8817                            Ref::keyword("PIPE").to_matchable(),
8818                            Ref::new("ObjectReferenceSegment").to_matchable(),
8819                        ])
8820                        .to_matchable(),
8821                        Sequence::new(vec![
8822                            Ref::keyword("STREAM").to_matchable(),
8823                            Ref::new("ObjectReferenceSegment").to_matchable(),
8824                        ])
8825                        .to_matchable(),
8826                        Sequence::new(vec![
8827                            Ref::keyword("TASK").to_matchable(),
8828                            Ref::new("ObjectReferenceSegment").to_matchable(),
8829                        ])
8830                        .to_matchable(),
8831                        Sequence::new(vec![
8832                            Ref::keyword("FUNCTION").to_matchable(),
8833                            Ref::new("FunctionNameSegment").to_matchable(),
8834                            Bracketed::new(vec![
8835                                Delimited::new(vec![Ref::new("DatatypeSegment").to_matchable()])
8836                                    .config(|this| this.optional())
8837                                    .to_matchable(),
8838                            ])
8839                            .to_matchable(),
8840                        ])
8841                        .to_matchable(),
8842                        Sequence::new(vec![
8843                            Ref::keyword("PROCEDURE").to_matchable(),
8844                            Ref::new("FunctionNameSegment").to_matchable(),
8845                            Bracketed::new(vec![
8846                                Delimited::new(vec![Ref::new("DatatypeSegment").to_matchable()])
8847                                    .config(|this| this.optional())
8848                                    .to_matchable(),
8849                            ])
8850                            .to_matchable(),
8851                        ])
8852                        .to_matchable(),
8853                    ])
8854                    .to_matchable(),
8855                ])
8856                .to_matchable()
8857            })
8858            .to_matchable()
8859            .into(),
8860        ),
8861    ]);
8862
8863    snowflake_dialect.replace_grammar(
8864        "TransactionStatementSegment",
8865        one_of(vec![
8866            Sequence::new(vec![
8867                Ref::keyword("BEGIN").to_matchable(),
8868                one_of(vec![
8869                    Ref::keyword("WORK").to_matchable(),
8870                    Ref::keyword("TRANSACTION").to_matchable(),
8871                ])
8872                .config(|this| this.optional())
8873                .to_matchable(),
8874                Sequence::new(vec![
8875                    Ref::keyword("NAME").to_matchable(),
8876                    Ref::new("ObjectReferenceSegment").to_matchable(),
8877                ])
8878                .config(|this| this.optional())
8879                .to_matchable(),
8880            ])
8881            .to_matchable(),
8882            Sequence::new(vec![
8883                Ref::keyword("START").to_matchable(),
8884                Ref::keyword("TRANSACTION").to_matchable(),
8885                Sequence::new(vec![
8886                    Ref::keyword("NAME").to_matchable(),
8887                    Ref::new("ObjectReferenceSegment").to_matchable(),
8888                ])
8889                .config(|this| this.optional())
8890                .to_matchable(),
8891            ])
8892            .to_matchable(),
8893            Sequence::new(vec![
8894                Ref::keyword("COMMIT").to_matchable(),
8895                Ref::keyword("WORK").optional().to_matchable(),
8896            ])
8897            .to_matchable(),
8898            Ref::keyword("ROLLBACK").to_matchable(),
8899        ])
8900        .to_matchable(),
8901    );
8902
8903    snowflake_dialect.replace_grammar(
8904        "TruncateStatementSegment",
8905        Sequence::new(vec![
8906            Ref::keyword("TRUNCATE").to_matchable(),
8907            Ref::keyword("TABLE").optional().to_matchable(),
8908            Sequence::new(vec![
8909                Ref::keyword("IF").to_matchable(),
8910                Ref::keyword("EXISTS").to_matchable(),
8911            ])
8912            .config(|this| this.optional())
8913            .to_matchable(),
8914            Ref::new("TableReferenceSegment").to_matchable(),
8915        ])
8916        .to_matchable(),
8917    );
8918
8919    snowflake_dialect.add([
8920        (
8921            "UnsetStatementSegment".into(),
8922            NodeMatcher::new(SyntaxKind::UnsetStatement, |_| {
8923                Sequence::new(vec![
8924                    Ref::keyword("UNSET").to_matchable(),
8925                    one_of(vec![
8926                        Ref::new("LocalVariableNameSegment").to_matchable(),
8927                        Bracketed::new(vec![
8928                            Delimited::new(vec![
8929                                Ref::new("LocalVariableNameSegment").to_matchable(),
8930                            ])
8931                            .to_matchable(),
8932                        ])
8933                        .to_matchable(),
8934                    ])
8935                    .to_matchable(),
8936                ])
8937                .to_matchable()
8938            })
8939            .to_matchable()
8940            .into(),
8941        ),
8942        (
8943            "UndropStatementSegment".into(),
8944            NodeMatcher::new(SyntaxKind::UndropStatement, |_| {
8945                Sequence::new(vec![
8946                    Ref::keyword("UNDROP").to_matchable(),
8947                    one_of(vec![
8948                        Sequence::new(vec![
8949                            Ref::keyword("DATABASE").to_matchable(),
8950                            Ref::new("DatabaseReferenceSegment").to_matchable(),
8951                        ])
8952                        .to_matchable(),
8953                        Sequence::new(vec![
8954                            Ref::keyword("SCHEMA").to_matchable(),
8955                            Ref::new("SchemaReferenceSegment").to_matchable(),
8956                        ])
8957                        .to_matchable(),
8958                        Sequence::new(vec![
8959                            Ref::keyword("TABLE").to_matchable(),
8960                            Ref::new("TableReferenceSegment").to_matchable(),
8961                        ])
8962                        .to_matchable(),
8963                    ])
8964                    .to_matchable(),
8965                ])
8966                .to_matchable()
8967            })
8968            .to_matchable()
8969            .into(),
8970        ),
8971        (
8972            "CommentStatementSegment".into(),
8973            NodeMatcher::new(SyntaxKind::CommentStatement, |_| {
8974                Sequence::new(vec![
8975                    Ref::keyword("COMMENT").to_matchable(),
8976                    Sequence::new(vec![
8977                        Ref::keyword("IF").to_matchable(),
8978                        Ref::keyword("EXISTS").to_matchable(),
8979                    ])
8980                    .config(|this| this.optional())
8981                    .to_matchable(),
8982                    Ref::keyword("ON").to_matchable(),
8983                    one_of(vec![
8984                        Ref::keyword("COLUMN").to_matchable(),
8985                        Ref::keyword("TABLE").to_matchable(),
8986                        Ref::keyword("VIEW").to_matchable(),
8987                        Ref::keyword("SCHEMA").to_matchable(),
8988                        Ref::keyword("DATABASE").to_matchable(),
8989                        Ref::keyword("WAREHOUSE").to_matchable(),
8990                        Ref::keyword("USER").to_matchable(),
8991                        Ref::keyword("STAGE").to_matchable(),
8992                        Ref::keyword("FUNCTION").to_matchable(),
8993                        Ref::keyword("PROCEDURE").to_matchable(),
8994                        Ref::keyword("SEQUENCE").to_matchable(),
8995                        Ref::keyword("SHARE").to_matchable(),
8996                        Ref::keyword("PIPE").to_matchable(),
8997                        Ref::keyword("STREAM").to_matchable(),
8998                        Ref::keyword("TASK").to_matchable(),
8999                        Sequence::new(vec![
9000                            Ref::keyword("NETWORK").to_matchable(),
9001                            Ref::keyword("POLICY").to_matchable(),
9002                        ])
9003                        .to_matchable(),
9004                        Sequence::new(vec![
9005                            one_of(vec![
9006                                Ref::keyword("API").to_matchable(),
9007                                Ref::keyword("NOTIFICATION").to_matchable(),
9008                                Ref::keyword("SECURITY").to_matchable(),
9009                                Ref::keyword("STORAGE").to_matchable(),
9010                            ])
9011                            .to_matchable(),
9012                            Ref::keyword("INTEGRATION").to_matchable(),
9013                        ])
9014                        .to_matchable(),
9015                        Sequence::new(vec![
9016                            Ref::keyword("SESSION").to_matchable(),
9017                            Ref::keyword("POLICY").to_matchable(),
9018                        ])
9019                        .to_matchable(),
9020                        Sequence::new(vec![
9021                            Ref::keyword("EXTERNAL").to_matchable(),
9022                            Ref::keyword("TABLE").to_matchable(),
9023                        ])
9024                        .to_matchable(),
9025                        Sequence::new(vec![
9026                            Ref::keyword("MATERIALIZED").to_matchable(),
9027                            Ref::keyword("VIEW").to_matchable(),
9028                        ])
9029                        .to_matchable(),
9030                        Sequence::new(vec![
9031                            Ref::keyword("MASKING").to_matchable(),
9032                            Ref::keyword("POLICY").to_matchable(),
9033                        ])
9034                        .to_matchable(),
9035                        Sequence::new(vec![
9036                            Ref::keyword("ROW").to_matchable(),
9037                            Ref::keyword("ACCESS").to_matchable(),
9038                            Ref::keyword("POLICY").to_matchable(),
9039                        ])
9040                        .to_matchable(),
9041                        Sequence::new(vec![
9042                            Ref::keyword("FILE").to_matchable(),
9043                            Ref::keyword("FORMAT").to_matchable(),
9044                        ])
9045                        .to_matchable(),
9046                    ])
9047                    .to_matchable(),
9048                    Ref::new("ObjectReferenceSegment").to_matchable(),
9049                    Ref::keyword("IS").to_matchable(),
9050                    Ref::new("QuotedLiteralSegment").to_matchable(),
9051                ])
9052                .to_matchable()
9053            })
9054            .to_matchable()
9055            .into(),
9056        ),
9057    ]);
9058
9059    snowflake_dialect.replace_grammar(
9060        "UseStatementSegment",
9061        Sequence::new(vec![
9062            Ref::keyword("USE").to_matchable(),
9063            one_of(vec![
9064                Sequence::new(vec![
9065                    Ref::keyword("ROLE").to_matchable(),
9066                    Ref::new("ObjectReferenceSegment").to_matchable(),
9067                ])
9068                .to_matchable(),
9069                Sequence::new(vec![
9070                    Ref::keyword("WAREHOUSE").to_matchable(),
9071                    Ref::new("ObjectReferenceSegment").to_matchable(),
9072                ])
9073                .to_matchable(),
9074                Sequence::new(vec![
9075                    Ref::keyword("DATABASE").optional().to_matchable(),
9076                    Ref::new("DatabaseReferenceSegment").to_matchable(),
9077                ])
9078                .to_matchable(),
9079                Sequence::new(vec![
9080                    Ref::keyword("SCHEMA").optional().to_matchable(),
9081                    Ref::new("SchemaReferenceSegment").to_matchable(),
9082                ])
9083                .to_matchable(),
9084                Sequence::new(vec![
9085                    Ref::keyword("SECONDARY").to_matchable(),
9086                    Ref::keyword("ROLES").to_matchable(),
9087                    one_of(vec![
9088                        Ref::keyword("ALL").to_matchable(),
9089                        Ref::keyword("NONE").to_matchable(),
9090                    ])
9091                    .to_matchable(),
9092                ])
9093                .to_matchable(),
9094            ])
9095            .to_matchable(),
9096        ])
9097        .to_matchable(),
9098    );
9099
9100    snowflake_dialect.add([(
9101        "CallStatementSegment".into(),
9102        NodeMatcher::new(SyntaxKind::CallStatement, |_| {
9103            Sequence::new(vec![
9104                Ref::keyword("CALL").to_matchable(),
9105                Sequence::new(vec![
9106                    Ref::new("FunctionNameSegment").to_matchable(),
9107                    Bracketed::new(vec![
9108                        Ref::new("FunctionContentsGrammar")
9109                            .optional()
9110                            .to_matchable(),
9111                    ])
9112                    .config(|this| this.parse_mode(ParseMode::Greedy))
9113                    .to_matchable(),
9114                ])
9115                .to_matchable(),
9116            ])
9117            .to_matchable()
9118        })
9119        .to_matchable()
9120        .into(),
9121    )]);
9122
9123    snowflake_dialect.replace_grammar(
9124        "LimitClauseSegment",
9125        one_of(vec![
9126            Sequence::new(vec![
9127                Ref::keyword("LIMIT").to_matchable(),
9128                MetaSegment::indent().to_matchable(),
9129                Ref::new("LimitLiteralGrammar").to_matchable(),
9130                MetaSegment::dedent().to_matchable(),
9131                Sequence::new(vec![
9132                    Ref::keyword("OFFSET").to_matchable(),
9133                    MetaSegment::indent().to_matchable(),
9134                    Ref::new("LimitLiteralGrammar").to_matchable(),
9135                    MetaSegment::dedent().to_matchable(),
9136                ])
9137                .config(|this| this.optional())
9138                .to_matchable(),
9139            ])
9140            .to_matchable(),
9141            Sequence::new(vec![
9142                Sequence::new(vec![
9143                    Ref::keyword("OFFSET").to_matchable(),
9144                    MetaSegment::indent().to_matchable(),
9145                    Ref::new("LimitLiteralGrammar").to_matchable(),
9146                    one_of(vec![
9147                        Ref::keyword("ROW").to_matchable(),
9148                        Ref::keyword("ROWS").to_matchable(),
9149                    ])
9150                    .config(|this| this.optional())
9151                    .to_matchable(),
9152                    MetaSegment::dedent().to_matchable(),
9153                ])
9154                .config(|this| this.optional())
9155                .to_matchable(),
9156                Ref::keyword("FETCH").to_matchable(),
9157                MetaSegment::indent().to_matchable(),
9158                one_of(vec![
9159                    Ref::keyword("FIRST").to_matchable(),
9160                    Ref::keyword("NEXT").to_matchable(),
9161                ])
9162                .config(|this| this.optional())
9163                .to_matchable(),
9164                Ref::new("LimitLiteralGrammar").to_matchable(),
9165                one_of(vec![
9166                    Ref::keyword("ROW").to_matchable(),
9167                    Ref::keyword("ROWS").to_matchable(),
9168                ])
9169                .config(|this| this.optional())
9170                .to_matchable(),
9171                Ref::keyword("ONLY").optional().to_matchable(),
9172                MetaSegment::dedent().to_matchable(),
9173            ])
9174            .to_matchable(),
9175        ])
9176        .to_matchable(),
9177    );
9178
9179    snowflake_dialect.replace_grammar(
9180        "SelectClauseSegment",
9181        ansi::select_clause_segment().copy(
9182            None,
9183            None,
9184            None,
9185            None,
9186            vec![
9187                Ref::keyword("FETCH").to_matchable(),
9188                Ref::keyword("OFFSET").to_matchable(),
9189            ],
9190            false,
9191        ),
9192    );
9193
9194    snowflake_dialect.replace_grammar(
9195        "OrderByClauseSegment",
9196        Sequence::new(vec![
9197            Ref::keyword("ORDER").to_matchable(),
9198            Ref::keyword("BY").to_matchable(),
9199            MetaSegment::indent().to_matchable(),
9200            Delimited::new(vec![
9201                Sequence::new(vec![
9202                    one_of(vec![
9203                        Ref::new("ColumnReferenceSegment").to_matchable(),
9204                        Ref::new("NumericLiteralSegment").to_matchable(),
9205                        Ref::new("ExpressionSegment").to_matchable(),
9206                    ])
9207                    .to_matchable(),
9208                    one_of(vec![
9209                        Ref::keyword("ASC").to_matchable(),
9210                        Ref::keyword("DESC").to_matchable(),
9211                    ])
9212                    .config(|this| this.optional())
9213                    .to_matchable(),
9214                    Sequence::new(vec![
9215                        Ref::keyword("NULLS").to_matchable(),
9216                        one_of(vec![
9217                            Ref::keyword("FIRST").to_matchable(),
9218                            Ref::keyword("LAST").to_matchable(),
9219                        ])
9220                        .to_matchable(),
9221                    ])
9222                    .config(|this| this.optional())
9223                    .to_matchable(),
9224                ])
9225                .to_matchable(),
9226            ])
9227            .config(|this| {
9228                this.terminators = vec![
9229                    Ref::keyword("LIMIT").to_matchable(),
9230                    Ref::keyword("FETCH").to_matchable(),
9231                    Ref::keyword("OFFSET").to_matchable(),
9232                    Ref::new("FrameClauseUnitGrammar").to_matchable(),
9233                ]
9234            })
9235            .to_matchable(),
9236            MetaSegment::dedent().to_matchable(),
9237        ])
9238        .to_matchable(),
9239    );
9240
9241    snowflake_dialect.replace_grammar("FrameClauseSegment", {
9242        let frame_extent = one_of(vec![
9243            Sequence::new(vec![
9244                Ref::keyword("CURRENT").to_matchable(),
9245                Ref::keyword("ROW").to_matchable(),
9246            ])
9247            .to_matchable(),
9248            Sequence::new(vec![
9249                one_of(vec![
9250                    Ref::new("NumericLiteralSegment").to_matchable(),
9251                    Ref::new("ReferencedVariableNameSegment").to_matchable(),
9252                    Ref::keyword("UNBOUNDED").to_matchable(),
9253                ])
9254                .to_matchable(),
9255                one_of(vec![
9256                    Ref::keyword("PRECEDING").to_matchable(),
9257                    Ref::keyword("FOLLOWING").to_matchable(),
9258                ])
9259                .to_matchable(),
9260            ])
9261            .to_matchable(),
9262        ]);
9263
9264        Sequence::new(vec![
9265            Ref::new("FrameClauseUnitGrammar").to_matchable(),
9266            one_of(vec![
9267                frame_extent.clone().to_matchable(),
9268                Sequence::new(vec![
9269                    Ref::keyword("BETWEEN").to_matchable(),
9270                    frame_extent.clone().to_matchable(),
9271                    Ref::keyword("AND").to_matchable(),
9272                    frame_extent.to_matchable(),
9273                ])
9274                .to_matchable(),
9275            ])
9276            .to_matchable(),
9277        ])
9278        .to_matchable()
9279    });
9280
9281    snowflake_dialect.add([
9282        (
9283            "DropProcedureStatementSegment".into(),
9284            NodeMatcher::new(SyntaxKind::DropProcedureStatement, |_| {
9285                Sequence::new(vec![
9286                    Ref::keyword("DROP").to_matchable(),
9287                    Ref::keyword("PROCEDURE").to_matchable(),
9288                    Ref::new("IfExistsGrammar").optional().to_matchable(),
9289                    Ref::new("FunctionNameSegment").to_matchable(),
9290                    Ref::new("FunctionParameterListGrammar").to_matchable(),
9291                ])
9292                .to_matchable()
9293            })
9294            .to_matchable()
9295            .into(),
9296        ),
9297        (
9298            "DropExternalTableStatementSegment".into(),
9299            NodeMatcher::new(SyntaxKind::DropExternalTableStatement, |_| {
9300                Sequence::new(vec![
9301                    Ref::keyword("DROP").to_matchable(),
9302                    Ref::keyword("EXTERNAL").to_matchable(),
9303                    Ref::keyword("TABLE").to_matchable(),
9304                    Ref::new("IfExistsGrammar").optional().to_matchable(),
9305                    Ref::new("TableReferenceSegment").to_matchable(),
9306                    Ref::new("DropBehaviorGrammar").optional().to_matchable(),
9307                ])
9308                .to_matchable()
9309            })
9310            .to_matchable()
9311            .into(),
9312        ),
9313        (
9314            "DropFunctionStatementSegment".into(),
9315            NodeMatcher::new(SyntaxKind::DropFunctionStatement, |_| {
9316                Sequence::new(vec![
9317                    Ref::keyword("DROP").to_matchable(),
9318                    Ref::keyword("EXTERNAL").optional().to_matchable(),
9319                    Ref::keyword("FUNCTION").to_matchable(),
9320                    Ref::new("IfExistsGrammar").optional().to_matchable(),
9321                    Ref::new("FunctionNameSegment").to_matchable(),
9322                    Ref::new("FunctionParameterListGrammar").to_matchable(),
9323                ])
9324                .to_matchable()
9325            })
9326            .to_matchable()
9327            .into(),
9328        ),
9329        (
9330            "DropMaterializedViewStatementSegment".into(),
9331            NodeMatcher::new(SyntaxKind::DropMaterializedViewStatement, |_| {
9332                Sequence::new(vec![
9333                    Ref::keyword("DROP").to_matchable(),
9334                    Ref::keyword("MATERIALIZED").to_matchable(),
9335                    Ref::keyword("VIEW").to_matchable(),
9336                    Ref::new("IfExistsGrammar").optional().to_matchable(),
9337                    Ref::new("TableReferenceSegment").to_matchable(),
9338                ])
9339                .to_matchable()
9340            })
9341            .to_matchable()
9342            .into(),
9343        ),
9344        (
9345            "DropObjectStatementSegment".into(),
9346            NodeMatcher::new(SyntaxKind::DropObjectStatement, |_| {
9347                Sequence::new(vec![
9348                    Ref::keyword("DROP").to_matchable(),
9349                    one_of(vec![
9350                        Sequence::new(vec![
9351                            one_of(vec![
9352                                Ref::keyword("CONNECTION").to_matchable(),
9353                                Sequence::new(vec![
9354                                    Ref::keyword("FILE").to_matchable(),
9355                                    Ref::keyword("FORMAT").to_matchable(),
9356                                ])
9357                                .to_matchable(),
9358                                Sequence::new(vec![
9359                                    one_of(vec![
9360                                        Ref::keyword("API").to_matchable(),
9361                                        Ref::keyword("NOTIFICATION").to_matchable(),
9362                                        Ref::keyword("SECURITY").to_matchable(),
9363                                        Ref::keyword("STORAGE").to_matchable(),
9364                                    ])
9365                                    .config(|this| this.optional())
9366                                    .to_matchable(),
9367                                    Ref::keyword("INTEGRATION").to_matchable(),
9368                                ])
9369                                .to_matchable(),
9370                                Ref::keyword("PIPE").to_matchable(),
9371                                Sequence::new(vec![
9372                                    Ref::keyword("ROW").to_matchable(),
9373                                    Ref::keyword("ACCESS").to_matchable(),
9374                                    Ref::keyword("POLICY").to_matchable(),
9375                                ])
9376                                .to_matchable(),
9377                                Ref::keyword("STAGE").to_matchable(),
9378                                Ref::keyword("STREAM").to_matchable(),
9379                                Ref::keyword("TAG").to_matchable(),
9380                                Ref::keyword("TASK").to_matchable(),
9381                            ])
9382                            .to_matchable(),
9383                            Ref::new("IfExistsGrammar").optional().to_matchable(),
9384                            Ref::new("ObjectReferenceSegment").to_matchable(),
9385                        ])
9386                        .to_matchable(),
9387                        Sequence::new(vec![
9388                            one_of(vec![
9389                                Sequence::new(vec![
9390                                    Ref::keyword("RESOURCE").to_matchable(),
9391                                    Ref::keyword("MONITOR").to_matchable(),
9392                                ])
9393                                .to_matchable(),
9394                                Ref::keyword("SHARE").to_matchable(),
9395                            ])
9396                            .to_matchable(),
9397                            Ref::new("ObjectReferenceSegment").to_matchable(),
9398                        ])
9399                        .to_matchable(),
9400                        Sequence::new(vec![
9401                            one_of(vec![
9402                                Sequence::new(vec![
9403                                    Ref::keyword("MANAGED").to_matchable(),
9404                                    Ref::keyword("ACCOUNT").to_matchable(),
9405                                ])
9406                                .to_matchable(),
9407                                Sequence::new(vec![
9408                                    Ref::keyword("MASKING").to_matchable(),
9409                                    Ref::keyword("POLICY").to_matchable(),
9410                                ])
9411                                .to_matchable(),
9412                            ])
9413                            .to_matchable(),
9414                            Ref::new("SingleIdentifierGrammar").to_matchable(),
9415                        ])
9416                        .to_matchable(),
9417                        Sequence::new(vec![
9418                            one_of(vec![
9419                                Sequence::new(vec![
9420                                    Ref::keyword("NETWORK").to_matchable(),
9421                                    Ref::keyword("POLICY").to_matchable(),
9422                                ])
9423                                .to_matchable(),
9424                            ])
9425                            .to_matchable(),
9426                            Ref::new("IfExistsGrammar").optional().to_matchable(),
9427                            Ref::new("SingleIdentifierGrammar").to_matchable(),
9428                        ])
9429                        .to_matchable(),
9430                        Sequence::new(vec![
9431                            one_of(vec![
9432                                Ref::keyword("WAREHOUSE").to_matchable(),
9433                                Sequence::new(vec![
9434                                    Ref::keyword("SESSION").to_matchable(),
9435                                    Ref::keyword("POLICY").to_matchable(),
9436                                ])
9437                                .to_matchable(),
9438                            ])
9439                            .to_matchable(),
9440                            Ref::new("IfExistsGrammar").optional().to_matchable(),
9441                            Ref::new("SingleIdentifierGrammar").to_matchable(),
9442                        ])
9443                        .to_matchable(),
9444                        Sequence::new(vec![
9445                            Ref::keyword("SEQUENCE").to_matchable(),
9446                            Ref::new("IfExistsGrammar").optional().to_matchable(),
9447                            Ref::new("ObjectReferenceSegment").to_matchable(),
9448                            Ref::new("DropBehaviorGrammar").optional().to_matchable(),
9449                        ])
9450                        .to_matchable(),
9451                    ])
9452                    .to_matchable(),
9453                ])
9454                .to_matchable()
9455            })
9456            .to_matchable()
9457            .into(),
9458        ),
9459        (
9460            "ListStatementSegment".into(),
9461            NodeMatcher::new(SyntaxKind::ListStatement, |_| {
9462                Sequence::new(vec![
9463                    one_of(vec![
9464                        Ref::keyword("LIST").to_matchable(),
9465                        Ref::keyword("LS").to_matchable(),
9466                    ])
9467                    .to_matchable(),
9468                    Ref::new("StagePath").to_matchable(),
9469                    Sequence::new(vec![
9470                        Ref::keyword("PATTERN").to_matchable(),
9471                        Ref::new("EqualsSegment").to_matchable(),
9472                        Ref::new("QuotedLiteralSegment").to_matchable(),
9473                    ])
9474                    .config(|this| this.optional())
9475                    .to_matchable(),
9476                ])
9477                .to_matchable()
9478            })
9479            .to_matchable()
9480            .into(),
9481        ),
9482        (
9483            "GetStatementSegment".into(),
9484            NodeMatcher::new(SyntaxKind::GetStatement, |_| {
9485                Sequence::new(vec![
9486                    Ref::keyword("GET").to_matchable(),
9487                    Ref::new("StagePath").to_matchable(),
9488                    one_of(vec![
9489                        Ref::new("UnquotedFilePath").to_matchable(),
9490                        Ref::new("QuotedLiteralSegment").to_matchable(),
9491                    ])
9492                    .to_matchable(),
9493                    any_set_of(vec![
9494                        Sequence::new(vec![
9495                            Ref::keyword("PARALLEL").to_matchable(),
9496                            Ref::new("EqualsSegment").to_matchable(),
9497                            Ref::new("IntegerSegment").to_matchable(),
9498                        ])
9499                        .to_matchable(),
9500                        Sequence::new(vec![
9501                            Ref::keyword("PATTERN").to_matchable(),
9502                            Ref::new("EqualsSegment").to_matchable(),
9503                            one_of(vec![
9504                                Ref::new("QuotedLiteralSegment").to_matchable(),
9505                                Ref::new("ReferencedVariableNameSegment").to_matchable(),
9506                            ])
9507                            .to_matchable(),
9508                        ])
9509                        .to_matchable(),
9510                    ])
9511                    .to_matchable(),
9512                ])
9513                .to_matchable()
9514            })
9515            .to_matchable()
9516            .into(),
9517        ),
9518        (
9519            "PutStatementSegment".into(),
9520            NodeMatcher::new(SyntaxKind::PutStatement, |_| {
9521                Sequence::new(vec![
9522                    Ref::keyword("PUT").to_matchable(),
9523                    one_of(vec![
9524                        Ref::new("UnquotedFilePath").to_matchable(),
9525                        Ref::new("QuotedLiteralSegment").to_matchable(),
9526                    ])
9527                    .to_matchable(),
9528                    Ref::new("StagePath").to_matchable(),
9529                    any_set_of(vec![
9530                        Sequence::new(vec![
9531                            Ref::keyword("PARALLEL").to_matchable(),
9532                            Ref::new("EqualsSegment").to_matchable(),
9533                            Ref::new("IntegerSegment").to_matchable(),
9534                        ])
9535                        .to_matchable(),
9536                        Sequence::new(vec![
9537                            Ref::keyword("AUTO_COMPRESS").to_matchable(),
9538                            Ref::new("EqualsSegment").to_matchable(),
9539                            Ref::new("BooleanLiteralGrammar").to_matchable(),
9540                        ])
9541                        .to_matchable(),
9542                        Sequence::new(vec![
9543                            Ref::keyword("SOURCE_COMPRESSION").to_matchable(),
9544                            Ref::new("EqualsSegment").to_matchable(),
9545                            Ref::new("CompressionType").to_matchable(),
9546                        ])
9547                        .to_matchable(),
9548                        Sequence::new(vec![
9549                            Ref::keyword("OVERWRITE").to_matchable(),
9550                            Ref::new("EqualsSegment").to_matchable(),
9551                            Ref::new("BooleanLiteralGrammar").to_matchable(),
9552                        ])
9553                        .to_matchable(),
9554                    ])
9555                    .to_matchable(),
9556                ])
9557                .to_matchable()
9558            })
9559            .to_matchable()
9560            .into(),
9561        ),
9562        (
9563            "RemoveStatementSegment".into(),
9564            NodeMatcher::new(SyntaxKind::RemoveStatement, |_| {
9565                Sequence::new(vec![
9566                    one_of(vec![
9567                        Ref::keyword("REMOVE").to_matchable(),
9568                        Ref::keyword("RM").to_matchable(),
9569                    ])
9570                    .to_matchable(),
9571                    Ref::new("StagePath").to_matchable(),
9572                    Sequence::new(vec![
9573                        Ref::keyword("PATTERN").to_matchable(),
9574                        Ref::new("EqualsSegment").to_matchable(),
9575                        one_of(vec![
9576                            Ref::new("QuotedLiteralSegment").to_matchable(),
9577                            Ref::new("ReferencedVariableNameSegment").to_matchable(),
9578                        ])
9579                        .to_matchable(),
9580                    ])
9581                    .config(|this| this.optional())
9582                    .to_matchable(),
9583                ])
9584                .to_matchable()
9585            })
9586            .to_matchable()
9587            .into(),
9588        ),
9589    ]);
9590
9591    snowflake_dialect.replace_grammar(
9592        "SetOperatorSegment",
9593        one_of(vec![
9594            Sequence::new(vec![
9595                Ref::keyword("UNION").to_matchable(),
9596                one_of(vec![
9597                    Ref::keyword("DISTINCT").to_matchable(),
9598                    Ref::keyword("ALL").to_matchable(),
9599                ])
9600                .config(|this| this.optional())
9601                .to_matchable(),
9602            ])
9603            .to_matchable(),
9604            Sequence::new(vec![
9605                one_of(vec![
9606                    Ref::keyword("INTERSECT").to_matchable(),
9607                    Ref::keyword("EXCEPT").to_matchable(),
9608                ])
9609                .to_matchable(),
9610                Ref::keyword("ALL").optional().to_matchable(),
9611            ])
9612            .to_matchable(),
9613            Ref::keyword("MINUS").to_matchable(),
9614        ])
9615        .to_matchable(),
9616    );
9617
9618    snowflake_dialect.add([(
9619        "ShorthandCastSegment".into(),
9620        NodeMatcher::new(SyntaxKind::CastExpression, |_| {
9621            Sequence::new(vec![
9622                one_of(vec![
9623                    Ref::new("Expression_D_Grammar").to_matchable(),
9624                    Ref::new("CaseExpressionSegment").to_matchable(),
9625                ])
9626                .to_matchable(),
9627                AnyNumberOf::new(vec![
9628                    Sequence::new(vec![
9629                        Ref::new("CastOperatorSegment").to_matchable(),
9630                        Ref::new("DatatypeSegment").to_matchable(),
9631                        one_of(vec![
9632                            Ref::new("TimeZoneGrammar").to_matchable(),
9633                            AnyNumberOf::new(vec![Ref::new("ArrayAccessorSegment").to_matchable()])
9634                                .to_matchable(),
9635                        ])
9636                        .config(|this| this.optional())
9637                        .to_matchable(),
9638                    ])
9639                    .to_matchable(),
9640                ])
9641                .config(|this| this.min_times(1))
9642                .to_matchable(),
9643            ])
9644            .to_matchable()
9645        })
9646        .to_matchable()
9647        .into(),
9648    )]);
9649
9650    // Resource Monitor statements
9651    snowflake_dialect.add([
9652        (
9653            // A `RESOURCE MONITOR` options statement.
9654            // https://docs.snowflake.com/en/sql-reference/sql/create-resource-monitor
9655            // https://docs.snowflake.com/en/sql-reference/sql/alter-resource-monitor
9656            "ResourceMonitorOptionsSegment".into(),
9657            AnyNumberOf::new(vec![
9658                Sequence::new(vec![
9659                    Ref::keyword("CREDIT_QUOTA").to_matchable(),
9660                    Ref::new("EqualsSegment").to_matchable(),
9661                    Ref::new("NumericLiteralSegment").to_matchable(),
9662                ])
9663                .to_matchable(),
9664                Sequence::new(vec![
9665                    Ref::keyword("FREQUENCY").to_matchable(),
9666                    Ref::new("EqualsSegment").to_matchable(),
9667                    one_of(vec![
9668                        Ref::keyword("DAILY").to_matchable(),
9669                        Ref::keyword("WEEKLY").to_matchable(),
9670                        Ref::keyword("MONTHLY").to_matchable(),
9671                        Ref::keyword("YEARLY").to_matchable(),
9672                        Ref::keyword("NEVER").to_matchable(),
9673                    ])
9674                    .to_matchable(),
9675                ])
9676                .to_matchable(),
9677                Sequence::new(vec![
9678                    Ref::keyword("START_TIMESTAMP").to_matchable(),
9679                    Ref::new("EqualsSegment").to_matchable(),
9680                    one_of(vec![
9681                        Ref::new("QuotedLiteralSegment").to_matchable(),
9682                        Ref::keyword("IMMEDIATELY").to_matchable(),
9683                    ])
9684                    .to_matchable(),
9685                ])
9686                .to_matchable(),
9687                Sequence::new(vec![
9688                    Ref::keyword("END_TIMESTAMP").to_matchable(),
9689                    Ref::new("EqualsSegment").to_matchable(),
9690                    Ref::new("QuotedLiteralSegment").to_matchable(),
9691                ])
9692                .to_matchable(),
9693                Sequence::new(vec![
9694                    Ref::keyword("NOTIFY_USERS").to_matchable(),
9695                    Ref::new("EqualsSegment").to_matchable(),
9696                    Bracketed::new(vec![
9697                        Delimited::new(vec![Ref::new("SingleIdentifierGrammar").to_matchable()])
9698                            .to_matchable(),
9699                    ])
9700                    .to_matchable(),
9701                ])
9702                .to_matchable(),
9703                Sequence::new(vec![
9704                    Ref::keyword("TRIGGERS").to_matchable(),
9705                    AnyNumberOf::new(vec![
9706                        Sequence::new(vec![
9707                            Ref::keyword("ON").to_matchable(),
9708                            Ref::new("NumericLiteralSegment").to_matchable(),
9709                            Ref::keyword("PERCENT").to_matchable(),
9710                            Ref::keyword("DO").to_matchable(),
9711                            one_of(vec![
9712                                Ref::keyword("NOTIFY").to_matchable(),
9713                                Ref::keyword("SUSPEND").to_matchable(),
9714                                Ref::keyword("SUSPEND_IMMEDIATE").to_matchable(),
9715                            ])
9716                            .to_matchable(),
9717                        ])
9718                        .to_matchable(),
9719                    ])
9720                    .to_matchable(),
9721                ])
9722                .to_matchable(),
9723            ])
9724            .to_matchable()
9725            .into(),
9726        ),
9727        (
9728            // A `CREATE RESOURCE MONITOR` statement.
9729            // https://docs.snowflake.com/en/sql-reference/sql/create-resource-monitor
9730            "CreateResourceMonitorStatementSegment".into(),
9731            Sequence::new(vec![
9732                Ref::keyword("CREATE").to_matchable(),
9733                Ref::new("OrReplaceGrammar").optional().to_matchable(),
9734                Ref::new("IfNotExistsGrammar").optional().to_matchable(),
9735                Sequence::new(vec![
9736                    Ref::keyword("RESOURCE").to_matchable(),
9737                    Ref::keyword("MONITOR").to_matchable(),
9738                ])
9739                .to_matchable(),
9740                Ref::new("ObjectReferenceSegment").to_matchable(),
9741                Ref::keyword("WITH").to_matchable(),
9742                Ref::new("ResourceMonitorOptionsSegment").to_matchable(),
9743            ])
9744            .to_matchable()
9745            .into(),
9746        ),
9747        (
9748            // An `ALTER RESOURCE MONITOR` statement.
9749            // https://docs.snowflake.com/en/sql-reference/sql/alter-resource-monitor
9750            "AlterResourceMonitorStatementSegment".into(),
9751            Sequence::new(vec![
9752                Ref::keyword("ALTER").to_matchable(),
9753                Sequence::new(vec![
9754                    Ref::keyword("RESOURCE").to_matchable(),
9755                    Ref::keyword("MONITOR").to_matchable(),
9756                ])
9757                .to_matchable(),
9758                Ref::new("IfExistsGrammar").optional().to_matchable(),
9759                Ref::new("ObjectReferenceSegment").to_matchable(),
9760                Ref::keyword("SET").to_matchable(),
9761                Ref::new("ResourceMonitorOptionsSegment").to_matchable(),
9762            ])
9763            .to_matchable()
9764            .into(),
9765        ),
9766        (
9767            // A `DROP RESOURCE MONITOR` statement.
9768            // https://docs.snowflake.com/en/sql-reference/sql/drop-resource-monitor
9769            "DropResourceMonitorStatementSegment".into(),
9770            Sequence::new(vec![
9771                Ref::keyword("DROP").to_matchable(),
9772                Sequence::new(vec![
9773                    Ref::keyword("RESOURCE").to_matchable(),
9774                    Ref::keyword("MONITOR").to_matchable(),
9775                ])
9776                .to_matchable(),
9777                Ref::new("IfExistsGrammar").optional().to_matchable(),
9778                Ref::new("ObjectReferenceSegment").to_matchable(),
9779            ])
9780            .to_matchable()
9781            .into(),
9782        ),
9783        (
9784            // An `ALTER DATABASE` statement.
9785            // https://docs.snowflake.com/en/sql-reference/sql/alter-database
9786            "AlterDatabaseSegment".into(),
9787            NodeMatcher::new(SyntaxKind::AlterDatabaseStatement, |_| {
9788                Sequence::new(vec![
9789                    Ref::keyword("ALTER").to_matchable(),
9790                    Ref::keyword("DATABASE").to_matchable(),
9791                    Ref::new("IfExistsGrammar").optional().to_matchable(),
9792                    Ref::new("ObjectReferenceSegment").to_matchable(),
9793                    one_of(vec![
9794                        Sequence::new(vec![
9795                            Ref::keyword("RENAME").to_matchable(),
9796                            Ref::keyword("TO").to_matchable(),
9797                            Ref::new("ObjectReferenceSegment").to_matchable(),
9798                        ])
9799                        .to_matchable(),
9800                        Sequence::new(vec![
9801                            Ref::keyword("SWAP").to_matchable(),
9802                            Ref::keyword("WITH").to_matchable(),
9803                            Ref::new("ObjectReferenceSegment").to_matchable(),
9804                        ])
9805                        .to_matchable(),
9806                        Sequence::new(vec![
9807                            Ref::keyword("SET").to_matchable(),
9808                            one_of(vec![
9809                                Ref::new("TagEqualsSegment").to_matchable(),
9810                                Delimited::new(vec![
9811                                    Sequence::new(vec![
9812                                        Ref::new("ParameterNameSegment").to_matchable(),
9813                                        Ref::new("EqualsSegment").to_matchable(),
9814                                        one_of(vec![
9815                                            Ref::new("BooleanLiteralGrammar").to_matchable(),
9816                                            Ref::new("QuotedLiteralSegment").to_matchable(),
9817                                            Ref::new("NumericLiteralSegment").to_matchable(),
9818                                        ])
9819                                        .to_matchable(),
9820                                    ])
9821                                    .to_matchable(),
9822                                ])
9823                                .to_matchable(),
9824                            ])
9825                            .to_matchable(),
9826                        ])
9827                        .to_matchable(),
9828                        Sequence::new(vec![
9829                            Ref::keyword("UNSET").to_matchable(),
9830                            Ref::keyword("TAG").to_matchable(),
9831                            Delimited::new(vec![Ref::new("TagReferenceSegment").to_matchable()])
9832                                .to_matchable(),
9833                        ])
9834                        .to_matchable(),
9835                        Sequence::new(vec![
9836                            Ref::keyword("UNSET").to_matchable(),
9837                            Delimited::new(vec![
9838                                one_of(vec![
9839                                    Ref::keyword("DATA_RETENTION_TIME_IN_DAYS").to_matchable(),
9840                                    Ref::keyword("MAX_DATA_EXTENSION_TIME_IN_DAYS").to_matchable(),
9841                                    Ref::keyword("DEFAULT_DDL_COLLATION").to_matchable(),
9842                                    Ref::keyword("COMMENT").to_matchable(),
9843                                ])
9844                                .to_matchable(),
9845                            ])
9846                            .to_matchable(),
9847                        ])
9848                        .to_matchable(),
9849                    ])
9850                    .to_matchable(),
9851                ])
9852                .to_matchable()
9853            })
9854            .to_matchable()
9855            .into(),
9856        ),
9857        (
9858            // An `ALTER MASKING POLICY` statement.
9859            // https://docs.snowflake.com/en/sql-reference/sql/alter-masking-policy
9860            "AlterMaskingPolicySegment".into(),
9861            Sequence::new(vec![
9862                Ref::keyword("ALTER").to_matchable(),
9863                Ref::keyword("MASKING").to_matchable(),
9864                Ref::keyword("POLICY").to_matchable(),
9865                Ref::new("IfExistsGrammar").optional().to_matchable(),
9866                Ref::new("ObjectReferenceSegment").to_matchable(),
9867                one_of(vec![
9868                    Sequence::new(vec![
9869                        Ref::keyword("RENAME").to_matchable(),
9870                        Ref::keyword("TO").to_matchable(),
9871                        Ref::new("ObjectReferenceSegment").to_matchable(),
9872                    ])
9873                    .to_matchable(),
9874                    Sequence::new(vec![
9875                        Ref::keyword("SET").to_matchable(),
9876                        Ref::keyword("BODY").to_matchable(),
9877                        Ref::new("FunctionAssignerSegment").to_matchable(),
9878                        Ref::new("ExpressionSegment").to_matchable(),
9879                    ])
9880                    .to_matchable(),
9881                    Sequence::new(vec![
9882                        Ref::keyword("SET").to_matchable(),
9883                        Ref::new("TagEqualsSegment").to_matchable(),
9884                    ])
9885                    .to_matchable(),
9886                    Sequence::new(vec![
9887                        Ref::keyword("UNSET").to_matchable(),
9888                        Ref::keyword("TAG").to_matchable(),
9889                        Delimited::new(vec![Ref::new("TagReferenceSegment").to_matchable()])
9890                            .to_matchable(),
9891                    ])
9892                    .to_matchable(),
9893                    Sequence::new(vec![
9894                        Ref::keyword("SET").to_matchable(),
9895                        Ref::keyword("COMMENT").to_matchable(),
9896                        Ref::new("EqualsSegment").to_matchable(),
9897                        Ref::new("QuotedLiteralSegment").to_matchable(),
9898                    ])
9899                    .to_matchable(),
9900                    Sequence::new(vec![
9901                        Ref::keyword("UNSET").to_matchable(),
9902                        Ref::keyword("COMMENT").to_matchable(),
9903                    ])
9904                    .to_matchable(),
9905                ])
9906                .to_matchable(),
9907            ])
9908            .to_matchable()
9909            .into(),
9910        ),
9911        (
9912            // An `ALTER NETWORK POLICY` statement.
9913            // https://docs.snowflake.com/en/sql-reference/sql/alter-network-policy
9914            "AlterNetworkPolicyStatementSegment".into(),
9915            Sequence::new(vec![
9916                Ref::keyword("ALTER").to_matchable(),
9917                Ref::keyword("NETWORK").to_matchable(),
9918                Ref::keyword("POLICY").to_matchable(),
9919                Ref::new("IfExistsGrammar").optional().to_matchable(),
9920                Ref::new("SingleIdentifierGrammar").to_matchable(),
9921                one_of(vec![
9922                    Sequence::new(vec![
9923                        Ref::keyword("SET").to_matchable(),
9924                        any_set_of(vec![
9925                            Sequence::new(vec![
9926                                Ref::keyword("ALLOWED_NETWORK_RULE_LIST").to_matchable(),
9927                                Ref::new("EqualsSegment").to_matchable(),
9928                                Bracketed::new(vec![
9929                                    Delimited::new(vec![
9930                                        Ref::new("QuotedLiteralSegment").to_matchable(),
9931                                    ])
9932                                    .to_matchable(),
9933                                ])
9934                                .to_matchable(),
9935                            ])
9936                            .to_matchable(),
9937                            Sequence::new(vec![
9938                                Ref::keyword("BLOCKED_NETWORK_RULE_LIST").to_matchable(),
9939                                Ref::new("EqualsSegment").to_matchable(),
9940                                Bracketed::new(vec![
9941                                    Delimited::new(vec![
9942                                        Ref::new("QuotedLiteralSegment").to_matchable(),
9943                                    ])
9944                                    .to_matchable(),
9945                                ])
9946                                .to_matchable(),
9947                            ])
9948                            .to_matchable(),
9949                            Sequence::new(vec![
9950                                Ref::keyword("ALLOWED_IP_LIST").to_matchable(),
9951                                Ref::new("EqualsSegment").to_matchable(),
9952                                Bracketed::new(vec![
9953                                    Delimited::new(vec![
9954                                        Ref::new("QuotedLiteralSegment").to_matchable(),
9955                                    ])
9956                                    .to_matchable(),
9957                                ])
9958                                .to_matchable(),
9959                            ])
9960                            .to_matchable(),
9961                            Sequence::new(vec![
9962                                Ref::keyword("BLOCKED_IP_LIST").to_matchable(),
9963                                Ref::new("EqualsSegment").to_matchable(),
9964                                Bracketed::new(vec![
9965                                    Delimited::new(vec![
9966                                        Ref::new("QuotedLiteralSegment").to_matchable(),
9967                                    ])
9968                                    .to_matchable(),
9969                                ])
9970                                .to_matchable(),
9971                            ])
9972                            .to_matchable(),
9973                            Sequence::new(vec![
9974                                Ref::keyword("COMMENT").to_matchable(),
9975                                Ref::new("EqualsSegment").to_matchable(),
9976                                Ref::new("QuotedLiteralSegment").to_matchable(),
9977                            ])
9978                            .to_matchable(),
9979                        ])
9980                        .to_matchable(),
9981                    ])
9982                    .to_matchable(),
9983                    Sequence::new(vec![
9984                        Ref::keyword("UNSET").to_matchable(),
9985                        Ref::keyword("COMMENT").to_matchable(),
9986                    ])
9987                    .to_matchable(),
9988                    Sequence::new(vec![
9989                        one_of(vec![
9990                            Ref::keyword("ADD").to_matchable(),
9991                            Ref::keyword("REMOVE").to_matchable(),
9992                        ])
9993                        .to_matchable(),
9994                        one_of(vec![
9995                            Ref::keyword("ALLOWED_NETWORK_RULE_LIST").to_matchable(),
9996                            Ref::keyword("BLOCKED_NETWORK_RULE_LIST").to_matchable(),
9997                        ])
9998                        .to_matchable(),
9999                        Ref::new("EqualsSegment").to_matchable(),
10000                        Ref::new("QuotedLiteralSegment").to_matchable(),
10001                    ])
10002                    .to_matchable(),
10003                    Sequence::new(vec![
10004                        Ref::keyword("RENAME").to_matchable(),
10005                        Ref::keyword("TO").to_matchable(),
10006                        Ref::new("SingleIdentifierGrammar").to_matchable(),
10007                    ])
10008                    .to_matchable(),
10009                    Sequence::new(vec![
10010                        Ref::keyword("SET").to_matchable(),
10011                        Ref::new("TagEqualsSegment").to_matchable(),
10012                    ])
10013                    .to_matchable(),
10014                    Sequence::new(vec![
10015                        Ref::keyword("UNSET").to_matchable(),
10016                        Ref::keyword("TAG").to_matchable(),
10017                        Ref::new("TagReferenceSegment").to_matchable(),
10018                        AnyNumberOf::new(vec![
10019                            Ref::new("CommaSegment").to_matchable(),
10020                            Ref::new("TagReferenceSegment").to_matchable(),
10021                        ])
10022                        .config(|this| this.optional())
10023                        .to_matchable(),
10024                    ])
10025                    .to_matchable(),
10026                ])
10027                .to_matchable(),
10028            ])
10029            .to_matchable()
10030            .into(),
10031        ),
10032    ]);
10033
10034    snowflake_dialect.expand();
10035    snowflake_dialect
10036}