prettier-plugin-bq 0.2.58 → 0.2.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/printer.js CHANGED
@@ -400,6 +400,8 @@ const printSQL = (path, options, print) => {
400
400
  return printAddColumnClause(path, options, print, node);
401
401
  case "AddConstraintClause":
402
402
  return printAddConstraintClause(path, options, print, node);
403
+ case "AggregatePipeOperator":
404
+ return printAggregatePipeOperator(path, options, print, node);
403
405
  case "AlterBICapacityStatement":
404
406
  return printAlterBICapacityStatement(path, options, print, node);
405
407
  case "AlterColumnStatement":
@@ -426,6 +428,8 @@ const printSQL = (path, options, print) => {
426
428
  return printAssertStatement(path, options, print, node);
427
429
  case "Asterisk":
428
430
  return printAsterisk(path, options, print, node);
431
+ case "BasePipeOperator":
432
+ return printBasePipeOperator(path, options, print, node);
429
433
  case "BeginStatement":
430
434
  return printBeginStatement(path, options, print, node);
431
435
  case "BetweenOperator":
@@ -450,6 +454,10 @@ const printSQL = (path, options, print) => {
450
454
  return printCaseExprArm(path, options, print, node);
451
455
  case "CastArgument":
452
456
  return printCastArgument(path, options, print, node);
457
+ case "CaseStatement":
458
+ return printCaseStatement(path, options, print, node);
459
+ case "CaseStatementArm":
460
+ return printCaseStatementArm(path, options, print, node);
453
461
  case "Comment":
454
462
  return printComment(path, options, print, node);
455
463
  case "Constraint":
@@ -502,6 +510,8 @@ const printSQL = (path, options, print) => {
502
510
  return printForStatement(path, options, print, node);
503
511
  case "ForSystemTimeAsOfClause":
504
512
  return printForSystemTimeAsOfclause(path, options, print, node);
513
+ case "FromStatement":
514
+ return printFromStatement(path, options, print, node);
505
515
  case "GrantStatement":
506
516
  return printGrantStatement(path, options, print, node);
507
517
  case "GroupByExprs":
@@ -534,6 +544,8 @@ const printSQL = (path, options, print) => {
534
544
  return printIsDistinctFromOperator(path, options, print, node);
535
545
  case "JoinOperator":
536
546
  return printJoinOperator(path, options, print, node);
547
+ case "JoinPipeOperator":
548
+ return printJoinPipeOperator(path, options, print, node);
537
549
  case "Keyword":
538
550
  return printKeyword(path, options, print, node);
539
551
  case "KeywordSequence":
@@ -552,6 +564,8 @@ const printSQL = (path, options, print) => {
552
564
  return printKeywordWithType(path, options, print, node);
553
565
  case "LimitClause":
554
566
  return printLimitClause(path, options, print, node);
567
+ case "LimitPipeOperator":
568
+ return printLimitPipeOperator(path, options, print, node);
555
569
  case "LoadStatement":
556
570
  return printLoadStatement(path, options, print, node);
557
571
  case "LoopStatement":
@@ -570,10 +584,14 @@ const printSQL = (path, options, print) => {
570
584
  return printOverwritePartitionsClause(path, options, print, node);
571
585
  case "Parameter":
572
586
  return printIdentifier(path, options, print, node);
587
+ case "PipeStatement":
588
+ return printPipeStatement(path, options, print, node);
573
589
  case "PivotConfig":
574
590
  return printPivotConfig(path, options, print, node);
575
591
  case "PivotOperator":
576
592
  return printPivotOperator(path, options, print, node);
593
+ case "PivotPipeOperator":
594
+ return printPivotPipeOperator(path, options, print, node);
577
595
  case "RevokeStatement":
578
596
  return printRevokeStatement(path, options, print, node);
579
597
  case "RaiseStatement":
@@ -600,6 +618,8 @@ const printSQL = (path, options, print) => {
600
618
  return printSymbol(path, options, print, node);
601
619
  case "TableSampleClause":
602
620
  return printTableSampleClause(path, options, print, node);
621
+ case "TableSamplePipeOperator":
622
+ return printTableSamplePipeOperator(path, options, print, node);
603
623
  case "TableSampleRatio":
604
624
  return printTableSampleRatio(path, options, print, node);
605
625
  case "Template":
@@ -618,10 +638,14 @@ const printSQL = (path, options, print) => {
618
638
  return printUnaryOperator(path, options, print, node);
619
639
  case "UndropStatement":
620
640
  return printUndropStatement(path, options, print, node);
641
+ case "UnionPipeOperator":
642
+ return printUnionPipeOperator(path, options, print, node);
621
643
  case "UnpivotConfig":
622
644
  return printUnpivotConfig(path, options, print, node);
623
645
  case "UnpivotOperator":
624
646
  return printUnpivotOperator(path, options, print, node);
647
+ case "UnpivotPipeOperator":
648
+ return printUnpivotPipeOperator(path, options, print, node);
625
649
  case "UpdateStatement":
626
650
  return printUpdateStatement(path, options, print, node);
627
651
  case "WhenClause":
@@ -654,16 +678,16 @@ exports.printSQL = printSQL;
654
678
  const printAccessOperator = (path, options, print, node) => {
655
679
  const p = new Printer(path, options, print, node);
656
680
  const docs = {
657
- leading_comments: "",
681
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
658
682
  left: p.child("left"),
659
683
  self: p.self("asItIs", true),
660
684
  trailing_comments: printTrailingComments(path, options, print, node),
661
685
  right: p.child("right", undefined, "all"),
662
686
  rparen: p.child("rparen", undefined, "all"),
663
- as: "",
687
+ as: "", // eslint-disable-line unicorn/no-unused-properties
664
688
  alias: printAlias(path, options, print, node),
665
689
  order: printOrder(path, options, print, node),
666
- null_order: "",
690
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
667
691
  comma: printComma(path, options, print, node),
668
692
  };
669
693
  return [
@@ -704,6 +728,32 @@ const printAddColumnClause = (path, options, print, node) => {
704
728
  ]),
705
729
  ];
706
730
  };
731
+ const printAggregatePipeOperator = (path, options, print, node) => {
732
+ const p = new Printer(path, options, print, node);
733
+ p.setNotRoot("exprs");
734
+ p.setGroupRecommended("exprs");
735
+ if (node.children.exprs) {
736
+ node.children.exprs.NodeVec[p.len("exprs") - 1].isFinalColumn = true;
737
+ }
738
+ const docs = {
739
+ leading_comments: printLeadingComments(path, options, print, node),
740
+ self: p.self(),
741
+ trailing_comments: printTrailingComments(path, options, print, node),
742
+ keywords: p.child("keywords", undefined, "all"),
743
+ exprs: p.child("exprs", (x) => group([line, x])),
744
+ groupby: p.child("groupby"),
745
+ };
746
+ return [
747
+ docs.leading_comments,
748
+ docs.self,
749
+ docs.trailing_comments,
750
+ p.has("keywords") ? " " : "",
751
+ docs.keywords,
752
+ indent(docs.exprs),
753
+ p.has("groupby") ? hardline : "",
754
+ docs.groupby,
755
+ ];
756
+ };
707
757
  const printAddConstraintClause = (path, options, print, node) => {
708
758
  const p = new Printer(path, options, print, node);
709
759
  const docs = {
@@ -743,7 +793,7 @@ const printAlterBICapacityStatement = (path, options, print, node) => {
743
793
  docs.set,
744
794
  " ",
745
795
  docs.options,
746
- softline,
796
+ p.has("semicolon") ? softline : "",
747
797
  docs.semicolon,
748
798
  ]),
749
799
  p.newLine(),
@@ -818,7 +868,7 @@ const printAlterModelStatement = (path, options, print, node) => {
818
868
  docs.set,
819
869
  " ",
820
870
  docs.options,
821
- softline,
871
+ p.has("semicolon") ? softline : "",
822
872
  docs.semicolon,
823
873
  ]),
824
874
  p.newLine(),
@@ -846,7 +896,7 @@ const printAlterOrganizationStatement = (path, options, print, node) => {
846
896
  docs.set,
847
897
  " ",
848
898
  docs.options,
849
- softline,
899
+ p.has("semicolon") ? softline : "",
850
900
  docs.semicolon,
851
901
  ]),
852
902
  p.newLine(),
@@ -877,7 +927,7 @@ const printAlterProjectStatement = (path, options, print, node) => {
877
927
  docs.set,
878
928
  " ",
879
929
  docs.options,
880
- softline,
930
+ p.has("semicolon") ? softline : "",
881
931
  docs.semicolon,
882
932
  ]),
883
933
  p.newLine(),
@@ -908,7 +958,7 @@ const printAlterReservationStatement = (path, options, print, node) => {
908
958
  docs.set,
909
959
  " ",
910
960
  docs.options,
911
- softline,
961
+ p.has("semicolon") ? softline : "",
912
962
  docs.semicolon,
913
963
  ]),
914
964
  p.newLine(),
@@ -924,6 +974,8 @@ const printAlterSchemaStatement = (path, options, print, node) => {
924
974
  if_exists: p.child("if_exists", (x) => group([line, x])),
925
975
  ident: p.child("ident", undefined, "all"),
926
976
  set: p.child("set"),
977
+ add: p.child("add"),
978
+ drop: p.child("drop"),
927
979
  options: p.child("options", undefined, "all"),
928
980
  default_collate: p.child("default_collate", undefined, "all"),
929
981
  semicolon: p.child("semicolon"),
@@ -939,11 +991,10 @@ const printAlterSchemaStatement = (path, options, print, node) => {
939
991
  p.has("ident") ? " " : "",
940
992
  docs.ident,
941
993
  line,
942
- docs.set,
943
- " ",
944
- docs.default_collate,
945
- docs.options,
946
- softline,
994
+ p.has("set") ? [docs.set, " ", docs.default_collate, docs.options] : "",
995
+ docs.add,
996
+ docs.drop,
997
+ p.has("semicolon") ? softline : "",
947
998
  docs.semicolon,
948
999
  ]),
949
1000
  p.newLine(),
@@ -1027,7 +1078,7 @@ const printAlterTableStatement = (path, options, print, node) => {
1027
1078
  docs.drop_columns,
1028
1079
  p.has("alter_column_stmt") ? hardline : "",
1029
1080
  docs.alter_column_stmt,
1030
- softline,
1081
+ p.has("semicolon") ? softline : "",
1031
1082
  docs.semicolon,
1032
1083
  ]),
1033
1084
  p.newLine(),
@@ -1065,7 +1116,7 @@ const printAlterViewStatement = (path, options, print, node) => {
1065
1116
  p.has("set") ? " " : "",
1066
1117
  docs.options,
1067
1118
  docs.alter_column_stmt,
1068
- softline,
1119
+ p.has("semicolon") ? softline : "",
1069
1120
  docs.semicolon,
1070
1121
  ]),
1071
1122
  p.newLine(),
@@ -1079,7 +1130,7 @@ const printAsterisk = (path, options, print, node) => {
1079
1130
  trailing_comments: printTrailingComments(path, options, print, node),
1080
1131
  except: p.child("except", (x) => [" ", x], "all"),
1081
1132
  replace: p.child("replace", (x) => [" ", x], "all"),
1082
- as: "",
1133
+ as: "", // eslint-disable-line unicorn/no-unused-properties
1083
1134
  alias: printAlias(path, options, print, node),
1084
1135
  comma: printComma(path, options, print, node),
1085
1136
  };
@@ -1093,6 +1144,63 @@ const printAsterisk = (path, options, print, node) => {
1093
1144
  docs.comma,
1094
1145
  ];
1095
1146
  };
1147
+ const printBasePipeOperator = (path, options, print, node) => {
1148
+ const p = new Printer(path, options, print, node);
1149
+ p.setNotRoot("exprs");
1150
+ p.setGroupRecommended("exprs");
1151
+ // trailing comma is...
1152
+ // allowed!
1153
+ // * select
1154
+ // * extend
1155
+ // * set
1156
+ // * drop
1157
+ // * rename
1158
+ // * aggregate
1159
+ // * order by
1160
+ // * union / intersect / except
1161
+ // NOT allowed!
1162
+ // * as
1163
+ // * where
1164
+ // * limit
1165
+ // * call
1166
+ // * join
1167
+ // other
1168
+ // * table sample
1169
+ // * pivot
1170
+ // * unpivot
1171
+ const commaTolerantOperators = [
1172
+ "SELECT",
1173
+ "EXTEND",
1174
+ "SET",
1175
+ "DROP",
1176
+ "RENAME",
1177
+ "AGGREGATE",
1178
+ "ORDER",
1179
+ "UNION",
1180
+ "INTERSECT",
1181
+ "EXCEPT",
1182
+ ];
1183
+ if (node.children.exprs &&
1184
+ node.token &&
1185
+ commaTolerantOperators.includes(node.token.literal.toUpperCase())) {
1186
+ node.children.exprs.NodeVec[p.len("exprs") - 1].isFinalColumn = true;
1187
+ }
1188
+ const docs = {
1189
+ leading_comments: printLeadingComments(path, options, print, node),
1190
+ self: p.self(),
1191
+ trailing_comments: printTrailingComments(path, options, print, node),
1192
+ keywords: p.child("keywords", undefined, "all"),
1193
+ exprs: p.child("exprs", (x) => group([line, x])),
1194
+ };
1195
+ return [
1196
+ docs.leading_comments,
1197
+ docs.self,
1198
+ docs.trailing_comments,
1199
+ p.has("keywords") ? " " : "",
1200
+ docs.keywords,
1201
+ indent(docs.exprs),
1202
+ ];
1203
+ };
1096
1204
  const printArrayLiteral = (path, options, print, node) => {
1097
1205
  const p = new Printer(path, options, print, node);
1098
1206
  const docs = {
@@ -1104,10 +1212,10 @@ const printArrayLiteral = (path, options, print, node) => {
1104
1212
  trailing_comments: printTrailingComments(path, options, print, node),
1105
1213
  exprs: p.child("exprs", (x) => group(x), "none", line),
1106
1214
  rparen: p.child("rparen"),
1107
- as: "",
1215
+ as: "", // eslint-disable-line unicorn/no-unused-properties
1108
1216
  alias: printAlias(path, options, print, node),
1109
1217
  order: printOrder(path, options, print, node),
1110
- null_order: "",
1218
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
1111
1219
  comma: printComma(path, options, print, node),
1112
1220
  };
1113
1221
  return [
@@ -1151,7 +1259,7 @@ const printAssertStatement = (path, options, print, node) => {
1151
1259
  docs.as,
1152
1260
  p.has("description") ? " " : "",
1153
1261
  docs.description,
1154
- softline,
1262
+ p.has("semicolon") ? softline : "",
1155
1263
  docs.semicolon,
1156
1264
  ]),
1157
1265
  p.newLine(),
@@ -1200,7 +1308,7 @@ const printBeginStatement = (path, options, print, node) => {
1200
1308
  docs.end,
1201
1309
  p.has("trailing_label") ? " " : "",
1202
1310
  docs.trailing_label,
1203
- softline,
1311
+ p.has("semicolon") ? softline : "",
1204
1312
  docs.semicolon,
1205
1313
  ]),
1206
1314
  p.newLine(),
@@ -1209,7 +1317,7 @@ const printBeginStatement = (path, options, print, node) => {
1209
1317
  const printBetweenOperator = (path, options, print, node) => {
1210
1318
  const p = new Printer(path, options, print, node);
1211
1319
  const docs = {
1212
- leading_comments: "",
1320
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
1213
1321
  left: p.child("left"),
1214
1322
  not: p.child("not", undefined, "all"),
1215
1323
  self: p.self("upper", true),
@@ -1217,10 +1325,10 @@ const printBetweenOperator = (path, options, print, node) => {
1217
1325
  right_min: p.child("right_min"),
1218
1326
  and: p.child("and"),
1219
1327
  right_max: p.child("right_max", undefined, "all"),
1220
- as: "",
1328
+ as: "", // eslint-disable-line unicorn/no-unused-properties
1221
1329
  alias: printAlias(path, options, print, node),
1222
1330
  order: printOrder(path, options, print, node),
1223
- null_order: "",
1331
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
1224
1332
  comma: printComma(path, options, print, node),
1225
1333
  };
1226
1334
  return [
@@ -1248,10 +1356,10 @@ const printBooleanLiteral = (path, options, print, node) => {
1248
1356
  leading_comments: printLeadingComments(path, options, print, node),
1249
1357
  self: p.self(),
1250
1358
  trailing_comments: printTrailingComments(path, options, print, node),
1251
- as: "",
1359
+ as: "", // eslint-disable-line unicorn/no-unused-properties
1252
1360
  alias: printAlias(path, options, print, node),
1253
1361
  order: printOrder(path, options, print, node),
1254
- null_order: "",
1362
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
1255
1363
  comma: printComma(path, options, print, node),
1256
1364
  };
1257
1365
  return [
@@ -1278,10 +1386,10 @@ const printBinaryOperator = (path, options, print, node) => {
1278
1386
  trailing_comments: printTrailingComments(path, options, print, node),
1279
1387
  quantifier: p.child("quantifier", undefined, "all"),
1280
1388
  right: p.child("right", undefined, "all"),
1281
- as: "",
1389
+ as: "", // eslint-disable-line unicorn/no-unused-properties
1282
1390
  alias: printAlias(path, options, print, node),
1283
1391
  order: printOrder(path, options, print, node),
1284
- null_order: "",
1392
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
1285
1393
  comma: printComma(path, options, print, node),
1286
1394
  };
1287
1395
  // NOTE
@@ -1407,12 +1515,24 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
1407
1515
  toUpper(parent.token);
1408
1516
  }
1409
1517
  break;
1518
+ case "KLL_QUANTILES":
1519
+ if (keywords_1.kllQuantilesFunctions.includes(func.token.literal.toUpperCase())) {
1520
+ func.isPreDefinedFunction = true;
1521
+ toUpper(parent.token);
1522
+ }
1523
+ break;
1410
1524
  case "ML":
1411
1525
  if (keywords_1.mlFunctions.includes(func.token.literal.toUpperCase())) {
1412
1526
  func.isPreDefinedFunction = true;
1413
1527
  toUpper(parent.token);
1414
1528
  }
1415
1529
  break;
1530
+ case "AI":
1531
+ if (keywords_1.aiFunctions.includes(func.token.literal.toUpperCase())) {
1532
+ func.isPreDefinedFunction = true;
1533
+ toUpper(parent.token);
1534
+ }
1535
+ break;
1416
1536
  }
1417
1537
  }
1418
1538
  else if (parent.node_type === "DotOperator") {
@@ -1449,6 +1569,27 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
1449
1569
  toUpper(grandParent.token);
1450
1570
  }
1451
1571
  break;
1572
+ case "KLL_QUANTILES":
1573
+ if (keywords_1.kllQuantilesFunctions.includes(func.token.literal.toUpperCase())) {
1574
+ func.isPreDefinedFunction = true;
1575
+ toUpper(parent.token);
1576
+ toUpper(grandParent.token);
1577
+ }
1578
+ break;
1579
+ case "ML":
1580
+ if (keywords_1.mlFunctions.includes(func.token.literal.toUpperCase())) {
1581
+ func.isPreDefinedFunction = true;
1582
+ toUpper(parent.token);
1583
+ toUpper(grandParent.token);
1584
+ }
1585
+ break;
1586
+ case "AI":
1587
+ if (keywords_1.aiFunctions.includes(func.token.literal.toUpperCase())) {
1588
+ func.isPreDefinedFunction = true;
1589
+ toUpper(parent.token);
1590
+ toUpper(grandParent.token);
1591
+ }
1592
+ break;
1452
1593
  }
1453
1594
  }
1454
1595
  }
@@ -1482,7 +1623,7 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
1482
1623
  }
1483
1624
  }
1484
1625
  const docs = {
1485
- leading_comments: "",
1626
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
1486
1627
  func: p.child("func"),
1487
1628
  self: p.self("asItIs", true),
1488
1629
  trailing_comments: printTrailingComments(path, options, print, node),
@@ -1494,10 +1635,10 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
1494
1635
  having: p.child("having"),
1495
1636
  rparen: p.child("rparen"),
1496
1637
  over: p.child("over", (x) => [" ", x], "all"),
1497
- as: "",
1638
+ as: "", // eslint-disable-line unicorn/no-unused-properties
1498
1639
  alias: printAlias(path, options, print, node),
1499
1640
  order: printOrder(path, options, print, node),
1500
- null_order: "",
1641
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
1501
1642
  comma: printComma(path, options, print, node),
1502
1643
  };
1503
1644
  // TODO
@@ -1548,8 +1689,8 @@ const printCallingTableFunction = (path, options, print, node) => {
1548
1689
  const docs = {
1549
1690
  self: printCallingFunctionGeneral(path, options, print, node),
1550
1691
  pivot: printPivotOrUnpivotOperator(path, options, print, node),
1551
- unpivot: "",
1552
- with_offset: "",
1692
+ unpivot: "", // eslint-disable-line unicorn/no-unused-properties
1693
+ with_offset: "", // eslint-disable-line unicorn/no-unused-properties
1553
1694
  /* eslint-disable unicorn/no-unused-properties */
1554
1695
  leading_comments: "",
1555
1696
  func: "",
@@ -1568,7 +1709,7 @@ const printCallingUnnest = (path, options, print, node) => {
1568
1709
  self: printCallingFunctionGeneral(path, options, print, node),
1569
1710
  with_offset: p.child("with_offset", undefined, "all"),
1570
1711
  pivot: printPivotOrUnpivotOperator(path, options, print, node),
1571
- unpivot: "",
1712
+ unpivot: "", // eslint-disable-line unicorn/no-unused-properties
1572
1713
  /* eslint-disable unicorn/no-unused-properties */
1573
1714
  leading_comments: "",
1574
1715
  func: "",
@@ -1602,7 +1743,7 @@ const printCallStatement = (path, options, print, node) => {
1602
1743
  docs.trailing_comments,
1603
1744
  " ",
1604
1745
  docs.procedure,
1605
- softline,
1746
+ p.has("semicolon") ? softline : "",
1606
1747
  docs.semicolon,
1607
1748
  ]),
1608
1749
  p.newLine(),
@@ -1617,10 +1758,10 @@ const printCaseExpr = (path, options, print, node) => {
1617
1758
  expr: p.child("expr", undefined, "all"),
1618
1759
  arms: p.child("arms", (x) => [line, group(x)], "none"),
1619
1760
  end: p.child("end"),
1620
- as: "",
1761
+ as: "", // eslint-disable-line unicorn/no-unused-properties
1621
1762
  alias: printAlias(path, options, print, node),
1622
1763
  order: printOrder(path, options, print, node),
1623
- null_order: "",
1764
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
1624
1765
  comma: printComma(path, options, print, node),
1625
1766
  };
1626
1767
  let res = [
@@ -1683,10 +1824,61 @@ const printCaseExprArm = (path, options, print, node) => {
1683
1824
  ];
1684
1825
  }
1685
1826
  };
1827
+ const printCaseStatement = (path, options, print, node) => {
1828
+ const p = new Printer(path, options, print, node);
1829
+ const docs = {
1830
+ leading_comments: printLeadingComments(path, options, print, node),
1831
+ self: p.self(),
1832
+ trailing_comments: printTrailingComments(path, options, print, node),
1833
+ expr: p.child("expr", undefined, "all"),
1834
+ arms: p.child("arms", (x) => [line, group(x)]),
1835
+ end_case: group(p.child("end_case", undefined, "none", line)),
1836
+ semicolon: p.child("semicolon"),
1837
+ };
1838
+ return [
1839
+ docs.leading_comments,
1840
+ group([
1841
+ docs.self,
1842
+ docs.trailing_comments,
1843
+ p.has("expr") ? " " : "",
1844
+ docs.expr,
1845
+ indent(docs.arms),
1846
+ line,
1847
+ docs.end_case,
1848
+ p.has("semicolon") ? softline : "",
1849
+ docs.semicolon,
1850
+ ]),
1851
+ p.newLine(),
1852
+ ];
1853
+ };
1854
+ const printCaseStatementArm = (path, options, print, node) => {
1855
+ const p = new Printer(path, options, print, node);
1856
+ p.setNotRoot("stmts");
1857
+ const docs = {
1858
+ leading_comments: printLeadingComments(path, options, print, node),
1859
+ self: p.self(),
1860
+ trailing_comments: printTrailingComments(path, options, print, node),
1861
+ expr: p.child("expr", undefined, "all"),
1862
+ then: p.child("then", undefined, "all"),
1863
+ stmts: p.child("stmts", (x) => [hardline, group(x)]),
1864
+ };
1865
+ return [
1866
+ docs.leading_comments,
1867
+ group([
1868
+ docs.self,
1869
+ docs.trailing_comments,
1870
+ p.has("expr") ? " " : "",
1871
+ docs.expr,
1872
+ p.has("then") ? " " : "",
1873
+ docs.then,
1874
+ indent([docs.stmts]),
1875
+ ]),
1876
+ ];
1877
+ };
1686
1878
  const printCastArgument = (path, options, print, node) => {
1687
1879
  const p = new Printer(path, options, print, node);
1688
1880
  const docs = {
1689
- leading_comments: "",
1881
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
1690
1882
  cast_from: p.child("cast_from"),
1691
1883
  self: p.self("upper", true),
1692
1884
  trailing_comments: printTrailingComments(path, options, print, node),
@@ -1750,16 +1942,16 @@ const printComment = (path, options, print, node) => {
1750
1942
  const printConstraint = (path, options, print, node) => {
1751
1943
  const p = new Printer(path, options, print, node);
1752
1944
  const docs = {
1753
- constraint: p.child("constraint", undefined, "all"),
1754
- if_not_exists: p.child("if_not_exists", (x) => group([line, x]), "all"),
1755
- ident: p.child("ident", undefined, "all"),
1756
- leading_comments: "",
1757
- self: p.self("upper", true),
1945
+ constraint: p.child("constraint", undefined, "all"), // CONSTRAINT
1946
+ if_not_exists: p.child("if_not_exists", (x) => group([line, x]), "all"), // IF NOT EXISTS
1947
+ ident: p.child("ident", undefined, "all"), // ident
1948
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
1949
+ self: p.self("upper", true), // PRIMARY | FOREIGN
1758
1950
  trailing_comments: printTrailingComments(path, options, print, node),
1759
- key: p.child("key", undefined, "all"),
1760
- columns: p.child("columns", undefined, "all"),
1761
- references: p.child("references", undefined, "all"),
1762
- enforced: p.child("enforced", undefined, "all"),
1951
+ key: p.child("key", undefined, "all"), // KEY
1952
+ columns: p.child("columns", undefined, "all"), // (col)
1953
+ references: p.child("references", undefined, "all"), // REFERENCES tablename(col)
1954
+ enforced: p.child("enforced", undefined, "all"), // NOT ENFORCED
1763
1955
  comma: p.child("comma", undefined, "all"),
1764
1956
  };
1765
1957
  return [
@@ -1796,9 +1988,10 @@ const printCreateFunctionStatement = (path, options, print, node) => {
1796
1988
  ident: p.child("ident", undefined, "all"),
1797
1989
  group: p.child("group", undefined, "all"),
1798
1990
  returns: p.child("returns"),
1799
- remote: p.child("remote"),
1800
1991
  determinism: group(p.child("determinism", undefined, "none", line)),
1801
1992
  language: p.child("language"),
1993
+ remote: p.child("remote"),
1994
+ connection: p.child("connection", undefined, p.has("remote") ? "all" : "none"),
1802
1995
  options: p.child("options"),
1803
1996
  as: p.child("as"),
1804
1997
  semicolon: p.child("semicolon"),
@@ -1825,17 +2018,18 @@ const printCreateFunctionStatement = (path, options, print, node) => {
1825
2018
  ]),
1826
2019
  p.has("returns") ? line : "",
1827
2020
  docs.returns,
1828
- p.has("remote") ? line : "",
1829
- docs.remote,
1830
2021
  p.has("determinism") ? line : "",
1831
2022
  docs.determinism,
1832
2023
  p.has("language") ? line : "",
1833
2024
  docs.language,
2025
+ p.has("remote") || p.has("connection")
2026
+ ? [line, docs.remote, p.has("remote") ? " " : "", docs.connection]
2027
+ : "",
1834
2028
  p.has("options") ? line : "",
1835
2029
  docs.options,
1836
2030
  p.has("as") ? line : "",
1837
2031
  docs.as,
1838
- softline,
2032
+ p.has("semicolon") ? softline : "",
1839
2033
  docs.semicolon,
1840
2034
  ]),
1841
2035
  p.newLine(),
@@ -1885,7 +2079,7 @@ const printCreateModelStatement = (path, options, print, node) => {
1885
2079
  docs.query,
1886
2080
  p.has("training_data_custom_holiday") ? line : "",
1887
2081
  docs.training_data_custom_holiday,
1888
- softline,
2082
+ p.has("semicolon") ? softline : "",
1889
2083
  docs.semicolon,
1890
2084
  ]),
1891
2085
  p.newLine(),
@@ -1937,7 +2131,7 @@ const printCreateProcedureStatement = (path, options, print, node) => {
1937
2131
  docs.stmt,
1938
2132
  p.has("as") ? line : "",
1939
2133
  docs.as,
1940
- softline,
2134
+ p.has("semicolon") ? softline : "",
1941
2135
  docs.semicolon,
1942
2136
  ]),
1943
2137
  p.newLine(),
@@ -1973,7 +2167,7 @@ const printCreateReservationStatement = (path, options, print, node) => {
1973
2167
  p.has("json_string") ? " " : "",
1974
2168
  docs.json_string,
1975
2169
  docs.options,
1976
- softline,
2170
+ p.has("semicolon") ? softline : "",
1977
2171
  docs.semicolon,
1978
2172
  ]),
1979
2173
  p.newLine(),
@@ -2017,7 +2211,7 @@ const printCreateRowAccessPolicyStatement = (path, options, print, node) => {
2017
2211
  docs.filter,
2018
2212
  " ",
2019
2213
  docs.using,
2020
- softline,
2214
+ p.has("semicolon") ? softline : "",
2021
2215
  docs.semicolon,
2022
2216
  ]),
2023
2217
  p.newLine(),
@@ -2056,7 +2250,7 @@ const printCreateSchemaStatement = (path, options, print, node) => {
2056
2250
  docs.with_connection,
2057
2251
  p.has("options") ? line : "",
2058
2252
  docs.options,
2059
- softline,
2253
+ p.has("semicolon") ? softline : "",
2060
2254
  docs.semicolon,
2061
2255
  ]),
2062
2256
  p.newLine(),
@@ -2100,7 +2294,7 @@ const printCreateIndexStatement = (path, options, print, node) => {
2100
2294
  docs.storing,
2101
2295
  p.has("options") ? line : "",
2102
2296
  docs.options,
2103
- softline,
2297
+ p.has("semicolon") ? softline : "",
2104
2298
  docs.semicolon,
2105
2299
  ]),
2106
2300
  p.newLine(),
@@ -2172,7 +2366,7 @@ const printCreateTableStatement = (path, options, print, node) => {
2172
2366
  docs.options,
2173
2367
  p.has("as") ? line : "",
2174
2368
  docs.as,
2175
- softline,
2369
+ p.has("semicolon") ? softline : "",
2176
2370
  docs.semicolon,
2177
2371
  ]),
2178
2372
  p.newLine(),
@@ -2219,7 +2413,7 @@ const printCreateViewStatement = (path, options, print, node) => {
2219
2413
  docs.options,
2220
2414
  line,
2221
2415
  docs.as,
2222
- softline,
2416
+ p.has("semicolon") ? softline : "",
2223
2417
  docs.semicolon,
2224
2418
  ]),
2225
2419
  p.newLine(),
@@ -2246,7 +2440,7 @@ const printDeclareStatement = (path, options, print, node) => {
2246
2440
  docs.variable_type,
2247
2441
  p.has("default") ? line : "",
2248
2442
  docs.default,
2249
- softline,
2443
+ p.has("semicolon") ? softline : "",
2250
2444
  docs.semicolon,
2251
2445
  ]),
2252
2446
  p.newLine(),
@@ -2273,7 +2467,7 @@ const printDeleteStatement = (path, options, print, node) => {
2273
2467
  docs.table_name,
2274
2468
  line,
2275
2469
  docs.where,
2276
- softline,
2470
+ p.has("semicolon") ? softline : "",
2277
2471
  docs.semicolon,
2278
2472
  ]),
2279
2473
  p.newLine(),
@@ -2304,20 +2498,20 @@ const printDotOperator = (path, options, print, node) => {
2304
2498
  const p = new Printer(path, options, print, node);
2305
2499
  p.setNotGlobal("right");
2306
2500
  const docs = {
2307
- leading_comments: "",
2501
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
2308
2502
  left: p.child("left"),
2309
2503
  self: p.self("upper", true),
2310
2504
  trailing_comments: printTrailingComments(path, options, print, node),
2311
2505
  right: p.child("right", undefined, "all"),
2312
- as: "",
2506
+ as: "", // eslint-disable-line unicorn/no-unused-properties
2313
2507
  alias: printAlias(path, options, print, node),
2314
2508
  for_system_time_as_of: p.child("for_system_time_as_of", undefined, "all"),
2315
2509
  pivot: printPivotOrUnpivotOperator(path, options, print, node),
2316
- unpivot: "",
2510
+ unpivot: "", // eslint-disable-line unicorn/no-unused-properties
2317
2511
  with_offset: p.child("with_offset", undefined, "all"),
2318
2512
  tablesample: p.child("tablesample", undefined, "all"),
2319
2513
  order: printOrder(path, options, print, node),
2320
- null_order: "",
2514
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
2321
2515
  comma: printComma(path, options, print, node),
2322
2516
  };
2323
2517
  return [
@@ -2359,7 +2553,7 @@ const printDropRowAccessPolicyStatement = (path, options, print, node) => {
2359
2553
  docs.ident,
2360
2554
  line,
2361
2555
  docs.on,
2362
- softline,
2556
+ p.has("semicolon") ? softline : "",
2363
2557
  docs.semicolon,
2364
2558
  ]),
2365
2559
  p.newLine(),
@@ -2401,7 +2595,7 @@ const printDropStatement = (path, options, print, node) => {
2401
2595
  docs.on,
2402
2596
  p.has("cascade_or_restrict") ? " " : "",
2403
2597
  docs.cascade_or_restrict,
2404
- softline,
2598
+ p.has("semicolon") ? softline : "",
2405
2599
  docs.semicolon,
2406
2600
  ]),
2407
2601
  p.newLine(),
@@ -2433,10 +2627,10 @@ const printEmptyStruct = (path, options, print, node) => {
2433
2627
  self: p.self(),
2434
2628
  trailing_comments: printTrailingComments(path, options, print, node),
2435
2629
  rparen: p.child("rparen"),
2436
- as: "",
2630
+ as: "", // eslint-disable-line unicorn/no-unused-properties
2437
2631
  alias: printAlias(path, options, print, node),
2438
2632
  order: printOrder(path, options, print, node),
2439
- null_order: "",
2633
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
2440
2634
  comma: printComma(path, options, print, node),
2441
2635
  };
2442
2636
  return [
@@ -2481,7 +2675,7 @@ const printExecuteStatement = (path, options, print, node) => {
2481
2675
  docs.into,
2482
2676
  p.has("using") ? line : "",
2483
2677
  docs.using,
2484
- softline,
2678
+ p.has("semicolon") ? softline : "",
2485
2679
  docs.semicolon,
2486
2680
  ]),
2487
2681
  p.newLine(),
@@ -2512,7 +2706,7 @@ const printExportDataStatement = (path, options, print, node) => {
2512
2706
  docs.options,
2513
2707
  line,
2514
2708
  docs.as,
2515
- softline,
2709
+ p.has("semicolon") ? softline : "",
2516
2710
  docs.semicolon,
2517
2711
  ]),
2518
2712
  p.newLine(),
@@ -2540,7 +2734,7 @@ const printExportModelStatement = (path, options, print, node) => {
2540
2734
  docs.ident,
2541
2735
  line,
2542
2736
  docs.options,
2543
- softline,
2737
+ p.has("semicolon") ? softline : "",
2544
2738
  docs.semicolon,
2545
2739
  ]),
2546
2740
  p.newLine(),
@@ -2550,7 +2744,7 @@ const printExtractArgument = (path, options, print, node) => {
2550
2744
  const p = new Printer(path, options, print, node);
2551
2745
  node.children.extract_datepart.Node.isDatePart = true;
2552
2746
  const docs = {
2553
- leading_comments: "",
2747
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
2554
2748
  extract_datepart: p.child("extract_datepart"),
2555
2749
  self: p.self("upper", true),
2556
2750
  trailing_comments: printTrailingComments(path, options, print, node),
@@ -2614,7 +2808,7 @@ const printForStatement = (path, options, print, node) => {
2614
2808
  docs.end_for,
2615
2809
  p.has("trailing_label") ? " " : "",
2616
2810
  docs.trailing_label,
2617
- softline,
2811
+ p.has("semicolon") ? softline : "",
2618
2812
  docs.semicolon,
2619
2813
  ]),
2620
2814
  p.newLine(),
@@ -2638,6 +2832,28 @@ const printForSystemTimeAsOfclause = (path, options, print, node) => {
2638
2832
  docs.expr,
2639
2833
  ];
2640
2834
  };
2835
+ const printFromStatement = (path, options, print, node) => {
2836
+ const p = new Printer(path, options, print, node);
2837
+ const docs = {
2838
+ leading_comments: printLeadingComments(path, options, print, node),
2839
+ self: p.self("upper"),
2840
+ trailing_comments: printTrailingComments(path, options, print, node),
2841
+ expr: p.child("expr", undefined, "first"),
2842
+ semicolon: p.child("semicolon"),
2843
+ };
2844
+ return [
2845
+ docs.leading_comments,
2846
+ group([
2847
+ docs.self,
2848
+ docs.trailing_comments,
2849
+ " ",
2850
+ docs.expr,
2851
+ p.has("semicolon") ? softline : "",
2852
+ docs.semicolon,
2853
+ ]),
2854
+ p.newLine(),
2855
+ ];
2856
+ };
2641
2857
  const printGrantStatement = (path, options, print, node) => {
2642
2858
  const p = new Printer(path, options, print, node);
2643
2859
  const docs = {
@@ -2663,7 +2879,7 @@ const printGrantStatement = (path, options, print, node) => {
2663
2879
  docs.ident,
2664
2880
  line,
2665
2881
  group(docs.to),
2666
- softline,
2882
+ p.has("semicolon") ? softline : "",
2667
2883
  docs.semicolon,
2668
2884
  ]),
2669
2885
  p.newLine(),
@@ -2704,13 +2920,13 @@ const printGroupedExpr = (path, options, print, node) => {
2704
2920
  trailing_comments: printTrailingComments(path, options, print, node),
2705
2921
  expr: p.child("expr"),
2706
2922
  rparen: p.child("rparen"),
2707
- as: "",
2923
+ as: "", // eslint-disable-line unicorn/no-unused-properties
2708
2924
  alias: printAlias(path, options, print, node),
2709
2925
  pivot: printPivotOrUnpivotOperator(path, options, print, node),
2710
- unpivot: "",
2711
- with_offset: "",
2926
+ unpivot: "", // eslint-disable-line unicorn/no-unused-properties
2927
+ with_offset: "", // eslint-disable-line unicorn/no-unused-properties
2712
2928
  order: printOrder(path, options, print, node),
2713
- null_order: "",
2929
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
2714
2930
  comma: printComma(path, options, print, node),
2715
2931
  };
2716
2932
  return [
@@ -2789,15 +3005,15 @@ const printGroupedStatement = (path, options, print, node) => {
2789
3005
  trailing_comments: printTrailingComments(path, options, print, node),
2790
3006
  stmt: p.child("stmt"),
2791
3007
  rparen: p.child("rparen"),
2792
- as: "",
3008
+ as: "", // eslint-disable-line unicorn/no-unused-properties
2793
3009
  alias: printAlias(path, options, print, node),
2794
3010
  pivot: printPivotOrUnpivotOperator(path, options, print, node),
2795
- unpivot: "",
2796
- with_offset: "",
3011
+ unpivot: "", // eslint-disable-line unicorn/no-unused-properties
3012
+ with_offset: "", // eslint-disable-line unicorn/no-unused-properties
2797
3013
  orderby: p.child("orderby"),
2798
3014
  limit: p.child("limit"),
2799
3015
  order: printOrder(path, options, print, node),
2800
- null_order: "",
3016
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
2801
3017
  comma: printComma(path, options, print, node),
2802
3018
  semicolon: p.child("semicolon", undefined, "all"),
2803
3019
  };
@@ -2876,15 +3092,15 @@ const printIdentifier = (path, options, print, node) => {
2876
3092
  leading_comments: printLeadingComments(path, options, print, node),
2877
3093
  self: node.isPreDefinedFunction || node.isDatePart ? p.self("upper") : p.self(),
2878
3094
  trailing_comments: printTrailingComments(path, options, print, node),
2879
- as: "",
3095
+ as: "", // eslint-disable-line unicorn/no-unused-properties
2880
3096
  alias: printAlias(path, options, print, node),
2881
3097
  for_system_time_as_of: p.child("for_system_time_as_of", undefined, "all"),
2882
3098
  pivot: printPivotOrUnpivotOperator(path, options, print, node),
2883
- unpivot: "",
3099
+ unpivot: "", // eslint-disable-line unicorn/no-unused-properties
2884
3100
  with_offset: p.child("with_offset", undefined, "all"),
2885
3101
  tablesample: p.child("tablesample", undefined, "all"),
2886
3102
  order: printOrder(path, options, print, node),
2887
- null_order: "",
3103
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
2888
3104
  comma: printComma(path, options, print, node),
2889
3105
  };
2890
3106
  return [
@@ -2946,7 +3162,7 @@ const printIfStatement = (path, options, print, node) => {
2946
3162
  docs.else,
2947
3163
  line,
2948
3164
  docs.end_if,
2949
- softline,
3165
+ p.has("semicolon") ? softline : "",
2950
3166
  docs.semicolon,
2951
3167
  ]),
2952
3168
  p.newLine(),
@@ -2956,16 +3172,16 @@ const printInOperator = (path, options, print, node) => {
2956
3172
  const p = new Printer(path, options, print, node);
2957
3173
  p.setNotRoot("right");
2958
3174
  const docs = {
2959
- leading_comments: "",
3175
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
2960
3176
  left: p.child("left"),
2961
3177
  not: p.child("not"),
2962
3178
  self: p.self("asItIs", true),
2963
3179
  trailing_comments: printTrailingComments(path, options, print, node),
2964
3180
  right: p.child("right", undefined, "all"),
2965
- as: "",
3181
+ as: "", // eslint-disable-line unicorn/no-unused-properties
2966
3182
  alias: printAlias(path, options, print, node),
2967
3183
  order: printOrder(path, options, print, node),
2968
- null_order: "",
3184
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
2969
3185
  comma: printComma(path, options, print, node),
2970
3186
  };
2971
3187
  return [
@@ -3006,7 +3222,7 @@ const printInsertStatement = (path, options, print, node) => {
3006
3222
  docs.columns,
3007
3223
  line,
3008
3224
  docs.input,
3009
- node.notRoot ? "" : softline,
3225
+ p.has("semicolon") ? softline : "",
3010
3226
  docs.semicolon,
3011
3227
  ]),
3012
3228
  p.newLine(),
@@ -3022,7 +3238,7 @@ const printIntervalLiteral = (path, options, print, node) => {
3022
3238
  date_part: p.child("date_part", undefined, "all"),
3023
3239
  to: p.child("to", undefined, "all"),
3024
3240
  to_date_part: p.child("to_date_part", undefined, "all"),
3025
- as: "",
3241
+ as: "", // eslint-disable-line unicorn/no-unused-properties
3026
3242
  alias: printAlias(path, options, print, node),
3027
3243
  comma: printComma(path, options, print, node),
3028
3244
  };
@@ -3054,10 +3270,10 @@ const printIsDistinctFromOperator = (path, options, print, node) => {
3054
3270
  distinct: p.child("distinct", undefined, "all"),
3055
3271
  from: p.child("from", undefined, "all"),
3056
3272
  right: p.child("right", undefined, "all"),
3057
- as: "",
3273
+ as: "", // eslint-disable-line unicorn/no-unused-properties
3058
3274
  alias: printAlias(path, options, print, node),
3059
3275
  order: printOrder(path, options, print, node),
3060
- null_order: "",
3276
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
3061
3277
  comma: printComma(path, options, print, node),
3062
3278
  };
3063
3279
  return [
@@ -3088,7 +3304,7 @@ const printJoinOperator = (path, options, print, node) => {
3088
3304
  p.setNotRoot("left");
3089
3305
  p.setNotRoot("right");
3090
3306
  const docs = {
3091
- leading_comments: "",
3307
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
3092
3308
  left: p.child("left"),
3093
3309
  join_type: p.child("join_type"),
3094
3310
  outer: p.consumeAllCommentsOfX("outer"),
@@ -3097,10 +3313,10 @@ const printJoinOperator = (path, options, print, node) => {
3097
3313
  right: p.child("right", undefined, "all"),
3098
3314
  on: p.child("on", undefined, "all"),
3099
3315
  using: p.child("using", undefined, "all"),
3100
- as: "",
3316
+ as: "", // eslint-disable-line unicorn/no-unused-properties
3101
3317
  alias: printAlias(path, options, print, node),
3102
3318
  pivot: printPivotOrUnpivotOperator(path, options, print, node),
3103
- unpivot: "",
3319
+ unpivot: "", // eslint-disable-line unicorn/no-unused-properties
3104
3320
  with_offset: "", // eslint-disable-line unicorn/no-unused-properties
3105
3321
  };
3106
3322
  return [
@@ -3125,6 +3341,37 @@ const printJoinOperator = (path, options, print, node) => {
3125
3341
  docs.pivot,
3126
3342
  ];
3127
3343
  };
3344
+ const printJoinPipeOperator = (path, options, print, node) => {
3345
+ const p = new Printer(path, options, print, node);
3346
+ p.setNotRoot("exprs");
3347
+ p.setGroupRecommended("exprs");
3348
+ const docs = {
3349
+ method: p.child("method"),
3350
+ leading_comments: p.has("method")
3351
+ ? ""
3352
+ : printLeadingComments(path, options, print, node),
3353
+ self: p.self("asItIs", p.has("method")),
3354
+ trailing_comments: printTrailingComments(path, options, print, node),
3355
+ keywords: p.child("keywords", undefined, "all"),
3356
+ exprs: p.child("exprs", (x) => group([line, x])),
3357
+ on: p.child("on"),
3358
+ using: p.child("using"),
3359
+ };
3360
+ return [
3361
+ docs.method,
3362
+ p.has("method") ? " " : "",
3363
+ docs.leading_comments,
3364
+ docs.self,
3365
+ docs.trailing_comments,
3366
+ p.has("keywords") ? " " : "",
3367
+ docs.keywords,
3368
+ indent(docs.exprs),
3369
+ p.has("on") ? line : "",
3370
+ docs.on,
3371
+ p.has("using") ? line : "",
3372
+ docs.using,
3373
+ ];
3374
+ };
3128
3375
  const printKeyword = (path, options, print, node) => {
3129
3376
  const p = new Printer(path, options, print, node);
3130
3377
  const docs = {
@@ -3260,6 +3507,29 @@ const printLimitClause = (path, options, print, node) => {
3260
3507
  docs.offset,
3261
3508
  ];
3262
3509
  };
3510
+ const printLimitPipeOperator = (path, options, print, node) => {
3511
+ const p = new Printer(path, options, print, node);
3512
+ p.setNotRoot("exprs");
3513
+ p.setGroupRecommended("exprs");
3514
+ const docs = {
3515
+ leading_comments: printLeadingComments(path, options, print, node),
3516
+ self: p.self(),
3517
+ trailing_comments: printTrailingComments(path, options, print, node),
3518
+ keywords: p.child("keywords", undefined, "all"),
3519
+ exprs: p.child("exprs", (x) => group([line, x])),
3520
+ offset: p.child("offset"),
3521
+ };
3522
+ return [
3523
+ docs.leading_comments,
3524
+ docs.self,
3525
+ docs.trailing_comments,
3526
+ p.has("keywords") ? " " : "",
3527
+ docs.keywords,
3528
+ indent(docs.exprs),
3529
+ p.has("offset") ? line : "",
3530
+ docs.offset,
3531
+ ];
3532
+ };
3263
3533
  const printLoadStatement = (path, options, print, node) => {
3264
3534
  const p = new Printer(path, options, print, node);
3265
3535
  const docs = {
@@ -3318,7 +3588,7 @@ const printLoadStatement = (path, options, print, node) => {
3318
3588
  docs.connection,
3319
3589
  p.has("with") ? " " : "",
3320
3590
  docs.connection_name,
3321
- softline,
3591
+ p.has("semicolon") ? softline : "",
3322
3592
  docs.semicolon,
3323
3593
  ]),
3324
3594
  p.newLine(),
@@ -3361,7 +3631,7 @@ const printLoopStatement = (path, options, print, node) => {
3361
3631
  docs.end_loop,
3362
3632
  p.has("trailing_label") ? " " : "",
3363
3633
  docs.trailing_label,
3364
- softline,
3634
+ p.has("semicolon") ? softline : "",
3365
3635
  docs.semicolon,
3366
3636
  ]),
3367
3637
  p.newLine(),
@@ -3393,7 +3663,7 @@ const printMergeStatement = (path, options, print, node) => {
3393
3663
  line,
3394
3664
  docs.on,
3395
3665
  docs.whens,
3396
- softline,
3666
+ p.has("semicolon") ? softline : "",
3397
3667
  docs.semicolon,
3398
3668
  ]),
3399
3669
  p.newLine(),
@@ -3406,16 +3676,16 @@ const printMultiTokenIdentifier = (path, options, print, node) => {
3406
3676
  self: p.self(),
3407
3677
  trailing_comments: printTrailingComments(path, options, print, node),
3408
3678
  trailing_idents: p.child("trailing_idents", undefined, "all"),
3409
- as: "",
3679
+ as: "", // eslint-disable-line unicorn/no-unused-properties
3410
3680
  alias: printAlias(path, options, print, node),
3411
3681
  for_system_time_as_of: p.child("for_system_time_as_of", undefined, "all"),
3412
3682
  pivot: printPivotOrUnpivotOperator(path, options, print, node),
3413
- unpivot: "",
3683
+ unpivot: "", // eslint-disable-line unicorn/no-unused-properties
3414
3684
  with_offset: p.child("with_offset", undefined, "all"),
3415
3685
  tablesample: p.child("tablesample", undefined, "all"),
3416
3686
  // NOTE order, null_order, comma may be unnecessary for the time being.
3417
3687
  order: printOrder(path, options, print, node),
3418
- null_order: "",
3688
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
3419
3689
  comma: printComma(path, options, print, node),
3420
3690
  };
3421
3691
  return [
@@ -3439,10 +3709,10 @@ const printNullLiteral = (path, options, print, node) => {
3439
3709
  leading_comments: printLeadingComments(path, options, print, node),
3440
3710
  self: p.self("upper"),
3441
3711
  trailing_comments: printTrailingComments(path, options, print, node),
3442
- as: "",
3712
+ as: "", // eslint-disable-line unicorn/no-unused-properties
3443
3713
  alias: printAlias(path, options, print, node),
3444
3714
  order: printOrder(path, options, print, node),
3445
- null_order: "",
3715
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
3446
3716
  comma: printComma(path, options, print, node),
3447
3717
  };
3448
3718
  return [
@@ -3458,12 +3728,12 @@ const printNumericLiteral = (path, options, print, node) => {
3458
3728
  const p = new Printer(path, options, print, node);
3459
3729
  const docs = {
3460
3730
  leading_comments: printLeadingComments(path, options, print, node),
3461
- self: p.self("lower"),
3731
+ self: p.self("lower"), // in the case of `3.14e10`
3462
3732
  trailing_comments: printTrailingComments(path, options, print, node),
3463
- as: "",
3733
+ as: "", // eslint-disable-line unicorn/no-unused-properties
3464
3734
  alias: printAlias(path, options, print, node),
3465
3735
  order: printOrder(path, options, print, node),
3466
- null_order: "",
3736
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
3467
3737
  comma: printComma(path, options, print, node),
3468
3738
  };
3469
3739
  return [
@@ -3478,7 +3748,7 @@ const printNumericLiteral = (path, options, print, node) => {
3478
3748
  const printOverClause = (path, options, print, node) => {
3479
3749
  const p = new Printer(path, options, print, node);
3480
3750
  const docs = {
3481
- leading_comments: "",
3751
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
3482
3752
  self: p.self("upper", true),
3483
3753
  trailing_comments: printTrailingComments(path, options, print, node),
3484
3754
  window: p.child("window", (x) => [" ", x], "all"),
@@ -3488,7 +3758,7 @@ const printOverClause = (path, options, print, node) => {
3488
3758
  const printOverwritePartitionsClause = (path, options, print, node) => {
3489
3759
  const p = new Printer(path, options, print, node);
3490
3760
  const docs = {
3491
- leading_comments: "",
3761
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
3492
3762
  overwrite: p.child("overwrite"),
3493
3763
  self: p.self("upper", true),
3494
3764
  trailing_comments: printTrailingComments(path, options, print, node),
@@ -3503,6 +3773,28 @@ const printOverwritePartitionsClause = (path, options, print, node) => {
3503
3773
  docs.grouped_expr,
3504
3774
  ]);
3505
3775
  };
3776
+ const printPipeStatement = (path, options, print, node) => {
3777
+ const p = new Printer(path, options, print, node);
3778
+ p.setNotRoot("left");
3779
+ p.setNotRoot("right");
3780
+ const docs = {
3781
+ left: p.child("left"),
3782
+ leading_comments: printLeadingComments(path, options, print, node),
3783
+ self: p.self("upper"),
3784
+ trailing_comments: printTrailingComments(path, options, print, node),
3785
+ right: p.child("right"),
3786
+ semicolon: p.child("semicolon"),
3787
+ };
3788
+ return [
3789
+ docs.left,
3790
+ hardline,
3791
+ docs.leading_comments,
3792
+ group([docs.self, docs.trailing_comments, indent([line, docs.right])]),
3793
+ p.has("semicolon") ? softline : "",
3794
+ docs.semicolon,
3795
+ p.newLine(),
3796
+ ];
3797
+ };
3506
3798
  const printPivotConfig = (path, options, print, node) => {
3507
3799
  const p = new Printer(path, options, print, node);
3508
3800
  const docs = {
@@ -3545,6 +3837,31 @@ const printPivotOperator = (path, options, print, node) => {
3545
3837
  p.has("alias") ? [" ", docs.alias] : "",
3546
3838
  ];
3547
3839
  };
3840
+ const printPivotPipeOperator = (path, options, print, node) => {
3841
+ const p = new Printer(path, options, print, node);
3842
+ const docs = {
3843
+ leading_comments: printLeadingComments(path, options, print, node),
3844
+ self: p.self(),
3845
+ trailing_comments: printTrailingComments(path, options, print, node),
3846
+ keywords: p.child("keywords", undefined, "all"),
3847
+ config: p.child("config", undefined, "first"),
3848
+ as: p.child("as", undefined, "all"),
3849
+ alias: p.child("alias", undefined, "all"),
3850
+ };
3851
+ return [
3852
+ docs.leading_comments,
3853
+ docs.self,
3854
+ docs.trailing_comments,
3855
+ p.has("keywords") ? " " : "",
3856
+ docs.keywords,
3857
+ " ",
3858
+ docs.config,
3859
+ p.has("alias")
3860
+ ? [" ", docs.as || (options.printKeywordsInUpperCase ? "AS" : "as")]
3861
+ : "",
3862
+ p.has("alias") ? [" ", docs.alias] : "",
3863
+ ];
3864
+ };
3548
3865
  const printRevokeStatement = (path, options, print, node) => {
3549
3866
  const p = new Printer(path, options, print, node);
3550
3867
  const docs = {
@@ -3570,7 +3887,7 @@ const printRevokeStatement = (path, options, print, node) => {
3570
3887
  docs.ident,
3571
3888
  line,
3572
3889
  group(docs.from),
3573
- softline,
3890
+ p.has("semicolon") ? softline : "",
3574
3891
  docs.semicolon,
3575
3892
  ]),
3576
3893
  p.newLine(),
@@ -3592,7 +3909,7 @@ const printRaiseStatement = (path, options, print, node) => {
3592
3909
  docs.trailing_comments,
3593
3910
  p.has("using") ? " " : "",
3594
3911
  docs.using,
3595
- softline,
3912
+ p.has("semicolon") ? softline : "",
3596
3913
  docs.semicolon,
3597
3914
  ]),
3598
3915
  p.newLine(),
@@ -3602,13 +3919,13 @@ const printRangeLiteral = (path, options, print, node) => {
3602
3919
  const p = new Printer(path, options, print, node);
3603
3920
  const docs = {
3604
3921
  type: p.child("type"),
3605
- leading_comments: "",
3922
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
3606
3923
  self: p.self("asItIs", true),
3607
3924
  trailing_comments: printTrailingComments(path, options, print, node),
3608
- as: "",
3925
+ as: "", // eslint-disable-line unicorn/no-unused-properties
3609
3926
  alias: printAlias(path, options, print, node),
3610
3927
  order: printOrder(path, options, print, node),
3611
- null_order: "",
3928
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
3612
3929
  comma: printComma(path, options, print, node),
3613
3930
  };
3614
3931
  return [
@@ -3690,7 +4007,7 @@ const printRepeatStatement = (path, options, print, node) => {
3690
4007
  docs.end_repeat,
3691
4008
  p.has("trailing_label") ? " " : "",
3692
4009
  docs.trailing_label,
3693
- softline,
4010
+ p.has("semicolon") ? softline : "",
3694
4011
  docs.semicolon,
3695
4012
  ]),
3696
4013
  p.newLine(),
@@ -3791,14 +4108,19 @@ const printSetOperator = (path, options, print, node) => {
3791
4108
  const docs = {
3792
4109
  with: p.child("with"),
3793
4110
  left: p.child("left"),
3794
- leading_comments: printLeadingComments(path, options, print, node),
3795
- self: p.self("upper"),
4111
+ method: p.child("method"),
4112
+ leading_comments: p.has("method")
4113
+ ? ""
4114
+ : printLeadingComments(path, options, print, node),
4115
+ self: p.self("upper", p.has("method")),
3796
4116
  trailing_comments: printTrailingComments(path, options, print, node),
3797
4117
  distinct_or_all: p.child("distinct_or_all", undefined, "all"),
4118
+ by: p.child("by", undefined, "all"),
4119
+ corresponding: p.child("corresponding", undefined, "all"),
3798
4120
  right: p.child("right"),
3799
4121
  semicolon: p.child("semicolon", undefined, "all"),
3800
4122
  };
3801
- const res = [
4123
+ return [
3802
4124
  docs.with,
3803
4125
  p.has("with")
3804
4126
  ? options.printBlankLineAfterCte
@@ -3807,23 +4129,20 @@ const printSetOperator = (path, options, print, node) => {
3807
4129
  : "",
3808
4130
  docs.left,
3809
4131
  line,
4132
+ p.has("method") ? [docs.method, " "] : "",
3810
4133
  docs.leading_comments,
3811
4134
  docs.self,
3812
4135
  docs.trailing_comments,
3813
4136
  " ",
3814
4137
  docs.distinct_or_all,
4138
+ p.has("by") ? [" ", docs.by] : "",
4139
+ p.has("corresponding") ? [" ", docs.corresponding] : "",
3815
4140
  line,
3816
4141
  docs.right,
3817
4142
  p.has("semicolon") ? softline : "",
3818
4143
  docs.semicolon,
3819
4144
  p.newLine(),
3820
4145
  ];
3821
- if (node.notRoot) {
3822
- return res;
3823
- }
3824
- else {
3825
- return group(res);
3826
- }
3827
4146
  };
3828
4147
  const printSetStatement = (path, options, print, node) => {
3829
4148
  const p = new Printer(path, options, print, node);
@@ -3841,7 +4160,7 @@ const printSetStatement = (path, options, print, node) => {
3841
4160
  docs.self,
3842
4161
  docs.trailing_comments,
3843
4162
  indent([line, docs.expr]),
3844
- softline,
4163
+ p.has("semicolon") ? softline : "",
3845
4164
  docs.semicolon,
3846
4165
  ]),
3847
4166
  p.newLine(),
@@ -3869,10 +4188,10 @@ const printStringLiteral = (path, options, print, node) => {
3869
4188
  leading_comments: printLeadingComments(path, options, print, node),
3870
4189
  self: p.self(),
3871
4190
  trailing_comments: printTrailingComments(path, options, print, node),
3872
- as: "",
4191
+ as: "", // eslint-disable-line unicorn/no-unused-properties
3873
4192
  alias: printAlias(path, options, print, node),
3874
4193
  order: printOrder(path, options, print, node),
3875
- null_order: "",
4194
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
3876
4195
  comma: printComma(path, options, print, node),
3877
4196
  };
3878
4197
  return [
@@ -3896,10 +4215,10 @@ const printStructLiteral = (path, options, print, node) => {
3896
4215
  trailing_comments: printTrailingComments(path, options, print, node),
3897
4216
  exprs: p.child("exprs", (x) => group(x), "none", line),
3898
4217
  rparen: p.child("rparen"),
3899
- as: "",
4218
+ as: "", // eslint-disable-line unicorn/no-unused-properties
3900
4219
  alias: printAlias(path, options, print, node),
3901
4220
  order: printOrder(path, options, print, node),
3902
- null_order: "",
4221
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
3903
4222
  comma: printComma(path, options, print, node),
3904
4223
  };
3905
4224
  return [
@@ -3947,6 +4266,26 @@ const printTableSampleClause = (path, options, print, node) => {
3947
4266
  docs.group,
3948
4267
  ];
3949
4268
  };
4269
+ // table sample
4270
+ const printTableSamplePipeOperator = (path, options, print, node) => {
4271
+ const p = new Printer(path, options, print, node);
4272
+ const docs = {
4273
+ leading_comments: printLeadingComments(path, options, print, node),
4274
+ self: p.self(),
4275
+ trailing_comments: printTrailingComments(path, options, print, node),
4276
+ keywords: p.child("keywords", undefined, "all"),
4277
+ group: p.child("group", undefined, "all"),
4278
+ };
4279
+ return [
4280
+ docs.leading_comments,
4281
+ docs.self,
4282
+ docs.trailing_comments,
4283
+ p.has("keywords") ? " " : "",
4284
+ docs.keywords,
4285
+ " ",
4286
+ docs.group,
4287
+ ];
4288
+ };
3950
4289
  const printTableSampleRatio = (path, options, print, node) => {
3951
4290
  const p = new Printer(path, options, print, node);
3952
4291
  const docs = {
@@ -4033,17 +4372,17 @@ const printType = (path, options, print, node) => {
4033
4372
  leading_comments: printLeadingComments(path, options, print, node),
4034
4373
  self: p.self("upper"),
4035
4374
  trailing_comments: printTrailingComments(path, options, print, node),
4036
- type: p.child("type", undefined, "all"),
4037
- type_declaration: p.child("type_declaration", undefined, "all"),
4038
- parameter: p.child("parameter", undefined, "all"),
4039
- collate: p.child("collate", undefined, "all"),
4040
- constraint: p.child("constraint", undefined, "all"),
4041
- primarykey: p.child("primarykey", undefined, "all"),
4042
- references: p.child("references", undefined, "all"),
4043
- enforced: p.child("enforced", undefined, "all"),
4044
- not_null: p.child("not_null", (x) => group([line, x])),
4045
- default: p.child("default", undefined, "all"),
4046
- options: p.child("options", undefined, "all"),
4375
+ type: p.child("type", undefined, "all"), // INT64 | ARRAY
4376
+ type_declaration: p.child("type_declaration", undefined, "all"), // <INT64>
4377
+ parameter: p.child("parameter", undefined, "all"), // STRING(10)
4378
+ collate: p.child("collate", undefined, "all"), // DEFAUT COLLATE 'und:ci'
4379
+ constraint: p.child("constraint", undefined, "all"), // CONSTRAINT ident
4380
+ primarykey: p.child("primarykey", undefined, "all"), // PRIMARY KEY
4381
+ references: p.child("references", undefined, "all"), // REFERENCES tablename(col)
4382
+ enforced: p.child("enforced", undefined, "all"), // NOT ENFORCED
4383
+ not_null: p.child("not_null", (x) => group([line, x])), // NOT NULL
4384
+ default: p.child("default", undefined, "all"), // DEFAULT CURRENT_TIMESTAMP
4385
+ options: p.child("options", undefined, "all"), // OPTIONS()
4047
4386
  aggregate: p.child("aggregate", (x) => group([line, x])), // NOT AGGREGATEj:w
4048
4387
  };
4049
4388
  return [
@@ -4075,7 +4414,7 @@ const printType = (path, options, print, node) => {
4075
4414
  const printTypeDeclaration = (path, options, print, node) => {
4076
4415
  const p = new Printer(path, options, print, node);
4077
4416
  const docs = {
4078
- leading_comments: "",
4417
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
4079
4418
  in_out: p.child("in_out"),
4080
4419
  self: p.self("asItIs", true),
4081
4420
  trailing_comments: printTrailingComments(path, options, print, node),
@@ -4111,10 +4450,10 @@ const printUnaryOperator = (path, options, print, node) => {
4111
4450
  self: p.includedIn(lowerCaseOperators) ? p.self("lower") : p.self("upper"),
4112
4451
  trailing_comments: printTrailingComments(path, options, print, node),
4113
4452
  right: p.child("right", undefined, "all"),
4114
- as: "",
4453
+ as: "", // eslint-disable-line unicorn/no-unused-properties
4115
4454
  alias: printAlias(path, options, print, node),
4116
4455
  order: printOrder(path, options, print, node),
4117
- null_order: "",
4456
+ null_order: "", // eslint-disable-line unicorn/no-unused-properties
4118
4457
  comma: printComma(path, options, print, node),
4119
4458
  };
4120
4459
  return [
@@ -4149,12 +4488,45 @@ const printUndropStatement = (path, options, print, node) => {
4149
4488
  docs.if_not_exists,
4150
4489
  " ",
4151
4490
  docs.ident,
4152
- softline,
4491
+ p.has("semicolon") ? softline : "",
4153
4492
  docs.semicolon,
4154
4493
  ]),
4155
4494
  p.newLine(),
4156
4495
  ];
4157
4496
  };
4497
+ const printUnionPipeOperator = (path, options, print, node) => {
4498
+ const p = new Printer(path, options, print, node);
4499
+ p.setNotRoot("exprs");
4500
+ p.setGroupRecommended("exprs");
4501
+ if (node.children.exprs) {
4502
+ // trailing comma is allowed
4503
+ node.children.exprs.NodeVec[p.len("exprs") - 1].isFinalColumn = true;
4504
+ }
4505
+ const docs = {
4506
+ method: p.child("method"),
4507
+ leading_comments: p.has("method")
4508
+ ? ""
4509
+ : printLeadingComments(path, options, print, node),
4510
+ self: p.self("asItIs", p.has("method")),
4511
+ trailing_comments: printTrailingComments(path, options, print, node),
4512
+ keywords: p.child("keywords", undefined, "all"),
4513
+ by: p.child("by", undefined, "all"),
4514
+ corresponding: p.child("corresponding", undefined, "all"),
4515
+ exprs: p.child("exprs", (x) => group([line, x])),
4516
+ };
4517
+ return [
4518
+ docs.method,
4519
+ p.has("method") ? " " : "",
4520
+ docs.leading_comments,
4521
+ docs.self,
4522
+ docs.trailing_comments,
4523
+ p.has("keywords") ? " " : "",
4524
+ docs.keywords,
4525
+ p.has("by") ? [" ", docs.by] : "",
4526
+ p.has("corresponding") ? [" ", docs.corresponding] : "",
4527
+ indent(docs.exprs),
4528
+ ];
4529
+ };
4158
4530
  const printUnpivotConfig = (path, options, print, node) => {
4159
4531
  const p = new Printer(path, options, print, node);
4160
4532
  const docs = {
@@ -4199,6 +4571,31 @@ const printUnpivotOperator = (path, options, print, node) => {
4199
4571
  p.has("alias") ? [" ", docs.alias] : "",
4200
4572
  ];
4201
4573
  };
4574
+ const printUnpivotPipeOperator = (path, options, print, node) => {
4575
+ const p = new Printer(path, options, print, node);
4576
+ const docs = {
4577
+ leading_comments: printLeadingComments(path, options, print, node),
4578
+ self: p.self(),
4579
+ trailing_comments: printTrailingComments(path, options, print, node),
4580
+ keywords: p.child("keywords", undefined, "all"),
4581
+ config: p.child("config", undefined, "first"),
4582
+ as: p.child("as", undefined, "all"),
4583
+ alias: p.child("alias", undefined, "all"),
4584
+ };
4585
+ return [
4586
+ docs.leading_comments,
4587
+ docs.self,
4588
+ docs.trailing_comments,
4589
+ p.has("keywords") ? " " : "",
4590
+ docs.keywords,
4591
+ " ",
4592
+ docs.config,
4593
+ p.has("alias")
4594
+ ? [" ", docs.as || (options.printKeywordsInUpperCase ? "AS" : "as")]
4595
+ : "",
4596
+ p.has("alias") ? [" ", docs.alias] : "",
4597
+ ];
4598
+ };
4202
4599
  const printUpdateStatement = (path, options, print, node) => {
4203
4600
  const p = new Printer(path, options, print, node);
4204
4601
  const docs = {
@@ -4224,7 +4621,7 @@ const printUpdateStatement = (path, options, print, node) => {
4224
4621
  docs.from,
4225
4622
  line,
4226
4623
  docs.where,
4227
- node.notRoot ? "" : softline,
4624
+ p.has("semicolon") ? softline : "",
4228
4625
  docs.semicolon,
4229
4626
  ]),
4230
4627
  p.newLine(),
@@ -4302,7 +4699,7 @@ const printWhileStatement = (path, options, print, node) => {
4302
4699
  docs.end_while,
4303
4700
  p.has("trailing_label") ? " " : "",
4304
4701
  docs.trailing_label,
4305
- softline,
4702
+ p.has("semicolon") ? softline : "",
4306
4703
  docs.semicolon,
4307
4704
  ]),
4308
4705
  p.newLine(),
@@ -4376,7 +4773,7 @@ const printWindowSpecification = (path, options, print, node) => {
4376
4773
  p.has("orderby") ||
4377
4774
  p.has("frame"));
4378
4775
  const docs = {
4379
- leading_comments: "",
4776
+ leading_comments: "", // eslint-disable-line unicorn/no-unused-properties
4380
4777
  self: p.self("upper", true),
4381
4778
  trailing_comments: printTrailingComments(path, options, print, node),
4382
4779
  name: p.child("name"),