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