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