prettier-plugin-bq 0.2.59 → 0.2.61
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/keywords.d.ts +2 -0
- package/dist/keywords.js +18 -2
- package/dist/keywords.js.map +1 -1
- package/dist/printer.js +356 -5
- package/dist/printer.js.map +1 -1
- package/package.json +4 -4
package/dist/printer.js
CHANGED
|
@@ -422,6 +422,8 @@ const printSQL = (path, options, print) => {
|
|
|
422
422
|
return printAlterTableStatement(path, options, print, node);
|
|
423
423
|
case "AlterViewStatement":
|
|
424
424
|
return printAlterViewStatement(path, options, print, node);
|
|
425
|
+
case "AlterVectorIndexStatement":
|
|
426
|
+
return printAlterVectorIndexStatement(path, options, print, node);
|
|
425
427
|
case "ArrayLiteral":
|
|
426
428
|
return printArrayLiteral(path, options, print, node);
|
|
427
429
|
case "AssertStatement":
|
|
@@ -512,6 +514,8 @@ const printSQL = (path, options, print) => {
|
|
|
512
514
|
return printForSystemTimeAsOfclause(path, options, print, node);
|
|
513
515
|
case "FromStatement":
|
|
514
516
|
return printFromStatement(path, options, print, node);
|
|
517
|
+
case "FunctionChain":
|
|
518
|
+
return printFunctionChain(path, options, print, node);
|
|
515
519
|
case "GrantStatement":
|
|
516
520
|
return printGrantStatement(path, options, print, node);
|
|
517
521
|
case "GroupByExprs":
|
|
@@ -522,6 +526,8 @@ const printSQL = (path, options, print) => {
|
|
|
522
526
|
return printGroupedExprs(path, options, print, node);
|
|
523
527
|
case "GroupedIdentWithOptions":
|
|
524
528
|
return printGroupedIdentWithOptions(path, options, print, node);
|
|
529
|
+
case "GroupedPattern":
|
|
530
|
+
return printGroupedPattern(path, options, print, node);
|
|
525
531
|
case "GroupedStatement":
|
|
526
532
|
return printGroupedStatement(path, options, print, node);
|
|
527
533
|
case "GroupedType":
|
|
@@ -570,6 +576,12 @@ const printSQL = (path, options, print) => {
|
|
|
570
576
|
return printLoadStatement(path, options, print, node);
|
|
571
577
|
case "LoopStatement":
|
|
572
578
|
return printLoopStatement(path, options, print, node);
|
|
579
|
+
case "MatchRecognizeClause":
|
|
580
|
+
return printMatchRecognizeClause(path, options, print, node);
|
|
581
|
+
case "MatchRecognizeConfig":
|
|
582
|
+
return printMatchRecognizeConfig(path, options, print, node);
|
|
583
|
+
case "MatchRecognizePipeOperator":
|
|
584
|
+
return printMatchRecognizePipeOperator(path, options, print, node);
|
|
573
585
|
case "MergeStatement":
|
|
574
586
|
return printMergeStatement(path, options, print, node);
|
|
575
587
|
case "MultiTokenIdentifier":
|
|
@@ -578,12 +590,20 @@ const printSQL = (path, options, print) => {
|
|
|
578
590
|
return printNullLiteral(path, options, print, node);
|
|
579
591
|
case "NumericLiteral":
|
|
580
592
|
return printNumericLiteral(path, options, print, node);
|
|
593
|
+
case "OrPattern":
|
|
594
|
+
return printOrPattern(path, options, print, node);
|
|
581
595
|
case "OverClause":
|
|
582
596
|
return printOverClause(path, options, print, node);
|
|
583
597
|
case "OverwritePartitionsClause":
|
|
584
598
|
return printOverwritePartitionsClause(path, options, print, node);
|
|
585
599
|
case "Parameter":
|
|
586
600
|
return printIdentifier(path, options, print, node);
|
|
601
|
+
case "Pattern":
|
|
602
|
+
return printPattern(path, options, print, node);
|
|
603
|
+
case "PatternClause":
|
|
604
|
+
return printPatternClause(path, options, print, node);
|
|
605
|
+
case "PatternQuantifier":
|
|
606
|
+
return printPatternQuantifier(path, options, print, node);
|
|
587
607
|
case "PipeStatement":
|
|
588
608
|
return printPipeStatement(path, options, print, node);
|
|
589
609
|
case "PivotConfig":
|
|
@@ -602,6 +622,8 @@ const printSQL = (path, options, print) => {
|
|
|
602
622
|
return printRenameColumnClause(path, options, print, node);
|
|
603
623
|
case "RepeatStatement":
|
|
604
624
|
return printRepeatStatement(path, options, print, node);
|
|
625
|
+
case "SelectPipeOperator":
|
|
626
|
+
return printSelectPipeOperator(path, options, print, node);
|
|
605
627
|
case "SelectStatement":
|
|
606
628
|
return printSelectStatement(path, options, print, node);
|
|
607
629
|
case "SetOperator":
|
|
@@ -666,6 +688,8 @@ const printSQL = (path, options, print) => {
|
|
|
666
688
|
return printWithOffsetClause(path, options, print, node);
|
|
667
689
|
case "WithPartitionColumnsClause":
|
|
668
690
|
return printWithPartitionColumnsClause(path, options, print, node);
|
|
691
|
+
case "WithPipeOperator":
|
|
692
|
+
return printWithPipeOperator(path, options, print, node);
|
|
669
693
|
case "WithQuery":
|
|
670
694
|
return printWithQuery(path, options, print, node);
|
|
671
695
|
case "XXXByExprs":
|
|
@@ -1122,6 +1146,39 @@ const printAlterViewStatement = (path, options, print, node) => {
|
|
|
1122
1146
|
p.newLine(),
|
|
1123
1147
|
];
|
|
1124
1148
|
};
|
|
1149
|
+
const printAlterVectorIndexStatement = (path, options, print, node) => {
|
|
1150
|
+
const p = new Printer(path, options, print, node);
|
|
1151
|
+
const docs = {
|
|
1152
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
1153
|
+
self: p.self("upper"),
|
|
1154
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
1155
|
+
what: p.child("what", undefined, "all"),
|
|
1156
|
+
if_exists: p.child("if_exists", (x) => group([line, x])),
|
|
1157
|
+
ident: p.child("ident", undefined, "all"),
|
|
1158
|
+
on: p.child("on"),
|
|
1159
|
+
operation: p.child("operation"),
|
|
1160
|
+
semicolon: p.child("semicolon"),
|
|
1161
|
+
};
|
|
1162
|
+
return [
|
|
1163
|
+
docs.leading_comments,
|
|
1164
|
+
group([
|
|
1165
|
+
docs.self,
|
|
1166
|
+
docs.trailing_comments,
|
|
1167
|
+
" ",
|
|
1168
|
+
docs.what,
|
|
1169
|
+
docs.if_exists,
|
|
1170
|
+
p.has("ident") ? " " : "",
|
|
1171
|
+
docs.ident,
|
|
1172
|
+
line,
|
|
1173
|
+
docs.on,
|
|
1174
|
+
line,
|
|
1175
|
+
docs.operation,
|
|
1176
|
+
p.has("semicolon") ? softline : "",
|
|
1177
|
+
docs.semicolon,
|
|
1178
|
+
]),
|
|
1179
|
+
p.newLine(),
|
|
1180
|
+
];
|
|
1181
|
+
};
|
|
1125
1182
|
const printAsterisk = (path, options, print, node) => {
|
|
1126
1183
|
const p = new Printer(path, options, print, node);
|
|
1127
1184
|
const docs = {
|
|
@@ -1521,6 +1578,12 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1521
1578
|
toUpper(parent.token);
|
|
1522
1579
|
}
|
|
1523
1580
|
break;
|
|
1581
|
+
case "OBJ":
|
|
1582
|
+
if (keywords_1.objFunctions.includes(func.token.literal.toUpperCase())) {
|
|
1583
|
+
func.isPreDefinedFunction = true;
|
|
1584
|
+
toUpper(parent.token);
|
|
1585
|
+
}
|
|
1586
|
+
break;
|
|
1524
1587
|
case "ML":
|
|
1525
1588
|
if (keywords_1.mlFunctions.includes(func.token.literal.toUpperCase())) {
|
|
1526
1589
|
func.isPreDefinedFunction = true;
|
|
@@ -1533,6 +1596,12 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1533
1596
|
toUpper(parent.token);
|
|
1534
1597
|
}
|
|
1535
1598
|
break;
|
|
1599
|
+
case "VECTOR_INDEX":
|
|
1600
|
+
if (keywords_1.vectorIndexFunctions.includes(func.token.literal.toUpperCase())) {
|
|
1601
|
+
func.isPreDefinedFunction = true;
|
|
1602
|
+
toUpper(parent.token);
|
|
1603
|
+
}
|
|
1604
|
+
break;
|
|
1536
1605
|
}
|
|
1537
1606
|
}
|
|
1538
1607
|
else if (parent.node_type === "DotOperator") {
|
|
@@ -1576,6 +1645,13 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1576
1645
|
toUpper(grandParent.token);
|
|
1577
1646
|
}
|
|
1578
1647
|
break;
|
|
1648
|
+
case "OBJ":
|
|
1649
|
+
if (keywords_1.objFunctions.includes(func.token.literal.toUpperCase())) {
|
|
1650
|
+
func.isPreDefinedFunction = true;
|
|
1651
|
+
toUpper(parent.token);
|
|
1652
|
+
toUpper(grandParent.token);
|
|
1653
|
+
}
|
|
1654
|
+
break;
|
|
1579
1655
|
case "ML":
|
|
1580
1656
|
if (keywords_1.mlFunctions.includes(func.token.literal.toUpperCase())) {
|
|
1581
1657
|
func.isPreDefinedFunction = true;
|
|
@@ -1590,6 +1666,13 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1590
1666
|
toUpper(grandParent.token);
|
|
1591
1667
|
}
|
|
1592
1668
|
break;
|
|
1669
|
+
case "VECTOR_INDEX":
|
|
1670
|
+
if (keywords_1.vectorIndexFunctions.includes(func.token.literal.toUpperCase())) {
|
|
1671
|
+
func.isPreDefinedFunction = true;
|
|
1672
|
+
toUpper(parent.token);
|
|
1673
|
+
toUpper(grandParent.token);
|
|
1674
|
+
}
|
|
1675
|
+
break;
|
|
1593
1676
|
}
|
|
1594
1677
|
}
|
|
1595
1678
|
}
|
|
@@ -1605,7 +1688,9 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1605
1688
|
}
|
|
1606
1689
|
// XXX_DIFF
|
|
1607
1690
|
if (["DATE_DIFF", "DATETIME_DIFF", "TIME_DIFF", "TIMESTAMP_DIFF"].includes(func_literal)) {
|
|
1608
|
-
args.NodeVec[2]
|
|
1691
|
+
const node = args.NodeVec[2];
|
|
1692
|
+
if (node)
|
|
1693
|
+
node.isDatePart = true; // not chained function
|
|
1609
1694
|
}
|
|
1610
1695
|
// XXX_TRUNC
|
|
1611
1696
|
if ([
|
|
@@ -1614,11 +1699,15 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1614
1699
|
"TIME_TRUNC",
|
|
1615
1700
|
"TIMESTAMP_TRUNC",
|
|
1616
1701
|
].includes(func_literal)) {
|
|
1617
|
-
args.NodeVec[1]
|
|
1702
|
+
const node = args.NodeVec[1];
|
|
1703
|
+
if (node)
|
|
1704
|
+
node.isDatePart = true; // not chained function
|
|
1618
1705
|
}
|
|
1619
1706
|
// LAST_DAY
|
|
1620
1707
|
if (func_literal === "LAST_DAY" && 2 <= p.len("args")) {
|
|
1621
|
-
args.NodeVec[1]
|
|
1708
|
+
const node = args.NodeVec[1];
|
|
1709
|
+
if (node)
|
|
1710
|
+
node.isDatePart = true; // not chained function
|
|
1622
1711
|
}
|
|
1623
1712
|
}
|
|
1624
1713
|
}
|
|
@@ -1686,10 +1775,12 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1686
1775
|
];
|
|
1687
1776
|
};
|
|
1688
1777
|
const printCallingTableFunction = (path, options, print, node) => {
|
|
1778
|
+
const p = new Printer(path, options, print, node);
|
|
1689
1779
|
const docs = {
|
|
1690
1780
|
self: printCallingFunctionGeneral(path, options, print, node),
|
|
1691
1781
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
1692
1782
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
1783
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
1693
1784
|
with_offset: "", // eslint-disable-line unicorn/no-unused-properties
|
|
1694
1785
|
/* eslint-disable unicorn/no-unused-properties */
|
|
1695
1786
|
leading_comments: "",
|
|
@@ -1701,7 +1792,12 @@ const printCallingTableFunction = (path, options, print, node) => {
|
|
|
1701
1792
|
alias: "",
|
|
1702
1793
|
/* eslint-enable unicorn/no-unused-properties */
|
|
1703
1794
|
};
|
|
1704
|
-
return [
|
|
1795
|
+
return [
|
|
1796
|
+
docs.self,
|
|
1797
|
+
docs.pivot,
|
|
1798
|
+
p.has("match_recognize") ? " " : "",
|
|
1799
|
+
docs.match_recognize,
|
|
1800
|
+
];
|
|
1705
1801
|
};
|
|
1706
1802
|
const printCallingUnnest = (path, options, print, node) => {
|
|
1707
1803
|
const p = new Printer(path, options, print, node);
|
|
@@ -1710,6 +1806,7 @@ const printCallingUnnest = (path, options, print, node) => {
|
|
|
1710
1806
|
with_offset: p.child("with_offset", undefined, "all"),
|
|
1711
1807
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
1712
1808
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
1809
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
1713
1810
|
/* eslint-disable unicorn/no-unused-properties */
|
|
1714
1811
|
leading_comments: "",
|
|
1715
1812
|
func: "",
|
|
@@ -1725,6 +1822,8 @@ const printCallingUnnest = (path, options, print, node) => {
|
|
|
1725
1822
|
p.has("with_offset") ? " " : "",
|
|
1726
1823
|
docs.with_offset,
|
|
1727
1824
|
docs.pivot,
|
|
1825
|
+
p.has("match_recognize") ? " " : "",
|
|
1826
|
+
docs.match_recognize,
|
|
1728
1827
|
];
|
|
1729
1828
|
};
|
|
1730
1829
|
const printCallStatement = (path, options, print, node) => {
|
|
@@ -2270,6 +2369,7 @@ const printCreateIndexStatement = (path, options, print, node) => {
|
|
|
2270
2369
|
tablename: p.child("tablename", undefined, "all"),
|
|
2271
2370
|
column_group: p.child("column_group", undefined, "all"),
|
|
2272
2371
|
storing: p.child("storing"),
|
|
2372
|
+
partitionby: p.child("partitionby"),
|
|
2273
2373
|
options: p.child("options"),
|
|
2274
2374
|
semicolon: p.child("semicolon"),
|
|
2275
2375
|
};
|
|
@@ -2292,6 +2392,8 @@ const printCreateIndexStatement = (path, options, print, node) => {
|
|
|
2292
2392
|
docs.column_group,
|
|
2293
2393
|
p.has("storing") ? line : "",
|
|
2294
2394
|
docs.storing,
|
|
2395
|
+
p.has("partitionby") ? line : "",
|
|
2396
|
+
docs.partitionby,
|
|
2295
2397
|
p.has("options") ? line : "",
|
|
2296
2398
|
docs.options,
|
|
2297
2399
|
p.has("semicolon") ? softline : "",
|
|
@@ -2508,6 +2610,7 @@ const printDotOperator = (path, options, print, node) => {
|
|
|
2508
2610
|
for_system_time_as_of: p.child("for_system_time_as_of", undefined, "all"),
|
|
2509
2611
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
2510
2612
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
2613
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
2511
2614
|
with_offset: p.child("with_offset", undefined, "all"),
|
|
2512
2615
|
tablesample: p.child("tablesample", undefined, "all"),
|
|
2513
2616
|
order: printOrder(path, options, print, node),
|
|
@@ -2522,6 +2625,8 @@ const printDotOperator = (path, options, print, node) => {
|
|
|
2522
2625
|
docs.alias,
|
|
2523
2626
|
p.has("for_system_time_as_of") ? [" ", docs.for_system_time_as_of] : "",
|
|
2524
2627
|
docs.pivot,
|
|
2628
|
+
p.has("match_recognize") ? " " : "",
|
|
2629
|
+
docs.match_recognize,
|
|
2525
2630
|
p.has("with_offset") ? " " : "",
|
|
2526
2631
|
docs.with_offset,
|
|
2527
2632
|
p.has("tablesample") ? [" ", docs.tablesample] : "",
|
|
@@ -2835,6 +2940,7 @@ const printForSystemTimeAsOfclause = (path, options, print, node) => {
|
|
|
2835
2940
|
const printFromStatement = (path, options, print, node) => {
|
|
2836
2941
|
const p = new Printer(path, options, print, node);
|
|
2837
2942
|
const docs = {
|
|
2943
|
+
with: p.child("with"),
|
|
2838
2944
|
leading_comments: printLeadingComments(path, options, print, node),
|
|
2839
2945
|
self: p.self("upper"),
|
|
2840
2946
|
trailing_comments: printTrailingComments(path, options, print, node),
|
|
@@ -2842,8 +2948,11 @@ const printFromStatement = (path, options, print, node) => {
|
|
|
2842
2948
|
semicolon: p.child("semicolon"),
|
|
2843
2949
|
};
|
|
2844
2950
|
return [
|
|
2951
|
+
docs.with,
|
|
2952
|
+
p.has("with") ? hardline : "",
|
|
2845
2953
|
docs.leading_comments,
|
|
2846
2954
|
group([
|
|
2955
|
+
p.has("with") ? breakParent : "",
|
|
2847
2956
|
docs.self,
|
|
2848
2957
|
docs.trailing_comments,
|
|
2849
2958
|
" ",
|
|
@@ -2854,6 +2963,47 @@ const printFromStatement = (path, options, print, node) => {
|
|
|
2854
2963
|
p.newLine(),
|
|
2855
2964
|
];
|
|
2856
2965
|
};
|
|
2966
|
+
const printFunctionChain = (path, options, print, node) => {
|
|
2967
|
+
const p = new Printer(path, options, print, node);
|
|
2968
|
+
const docs = {
|
|
2969
|
+
left: p.child("left"),
|
|
2970
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
2971
|
+
self: p.self("upper"),
|
|
2972
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
2973
|
+
right: p.child("right", undefined, "all"),
|
|
2974
|
+
as: "", // eslint-disable-line unicorn/no-unused-properties
|
|
2975
|
+
alias: printAlias(path, options, print, node),
|
|
2976
|
+
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
2977
|
+
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
2978
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
2979
|
+
with_offset: p.child("with_offset", undefined, "all"),
|
|
2980
|
+
order: printOrder(path, options, print, node),
|
|
2981
|
+
null_order: "", // eslint-disable-line unicorn/no-unused-properties
|
|
2982
|
+
comma: printComma(path, options, print, node),
|
|
2983
|
+
};
|
|
2984
|
+
let res = [
|
|
2985
|
+
docs.left,
|
|
2986
|
+
softline,
|
|
2987
|
+
docs.leading_comments,
|
|
2988
|
+
docs.self,
|
|
2989
|
+
docs.trailing_comments,
|
|
2990
|
+
docs.right,
|
|
2991
|
+
docs.alias,
|
|
2992
|
+
];
|
|
2993
|
+
if (node.groupRecommended) {
|
|
2994
|
+
res = group(res);
|
|
2995
|
+
}
|
|
2996
|
+
return [
|
|
2997
|
+
res,
|
|
2998
|
+
docs.pivot,
|
|
2999
|
+
p.has("match_recognize") ? " " : "",
|
|
3000
|
+
docs.match_recognize,
|
|
3001
|
+
p.has("with_offset") ? " " : "",
|
|
3002
|
+
docs.with_offset,
|
|
3003
|
+
docs.order,
|
|
3004
|
+
docs.comma,
|
|
3005
|
+
];
|
|
3006
|
+
};
|
|
2857
3007
|
const printGrantStatement = (path, options, print, node) => {
|
|
2858
3008
|
const p = new Printer(path, options, print, node);
|
|
2859
3009
|
const docs = {
|
|
@@ -2924,6 +3074,7 @@ const printGroupedExpr = (path, options, print, node) => {
|
|
|
2924
3074
|
alias: printAlias(path, options, print, node),
|
|
2925
3075
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
2926
3076
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3077
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
2927
3078
|
with_offset: "", // eslint-disable-line unicorn/no-unused-properties
|
|
2928
3079
|
order: printOrder(path, options, print, node),
|
|
2929
3080
|
null_order: "", // eslint-disable-line unicorn/no-unused-properties
|
|
@@ -2940,6 +3091,8 @@ const printGroupedExpr = (path, options, print, node) => {
|
|
|
2940
3091
|
]),
|
|
2941
3092
|
docs.alias,
|
|
2942
3093
|
docs.pivot,
|
|
3094
|
+
p.has("match_recognize") ? " " : "",
|
|
3095
|
+
docs.match_recognize,
|
|
2943
3096
|
docs.order,
|
|
2944
3097
|
docs.comma,
|
|
2945
3098
|
];
|
|
@@ -2995,6 +3148,28 @@ const printGroupedIdentWithOptions = (path, options, print, node) => {
|
|
|
2995
3148
|
]),
|
|
2996
3149
|
];
|
|
2997
3150
|
};
|
|
3151
|
+
const printGroupedPattern = (path, options, print, node) => {
|
|
3152
|
+
const p = new Printer(path, options, print, node);
|
|
3153
|
+
const docs = {
|
|
3154
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
3155
|
+
self: p.self(),
|
|
3156
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
3157
|
+
patterns: p.child("patterns", undefined, "none", line),
|
|
3158
|
+
rparen: p.child("rparen"),
|
|
3159
|
+
suffixes: p.child("suffixes", undefined, "all"),
|
|
3160
|
+
};
|
|
3161
|
+
return [
|
|
3162
|
+
docs.leading_comments,
|
|
3163
|
+
group([
|
|
3164
|
+
docs.self,
|
|
3165
|
+
docs.trailing_comments,
|
|
3166
|
+
indent([softline, docs.patterns]),
|
|
3167
|
+
softline,
|
|
3168
|
+
docs.rparen,
|
|
3169
|
+
docs.suffixes,
|
|
3170
|
+
]),
|
|
3171
|
+
];
|
|
3172
|
+
};
|
|
2998
3173
|
const printGroupedStatement = (path, options, print, node) => {
|
|
2999
3174
|
const p = new Printer(path, options, print, node);
|
|
3000
3175
|
p.setNotRoot("stmt");
|
|
@@ -3009,6 +3184,7 @@ const printGroupedStatement = (path, options, print, node) => {
|
|
|
3009
3184
|
alias: printAlias(path, options, print, node),
|
|
3010
3185
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
3011
3186
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3187
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
3012
3188
|
with_offset: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3013
3189
|
orderby: p.child("orderby"),
|
|
3014
3190
|
limit: p.child("limit"),
|
|
@@ -3036,6 +3212,8 @@ const printGroupedStatement = (path, options, print, node) => {
|
|
|
3036
3212
|
softline,
|
|
3037
3213
|
docs.rparen,
|
|
3038
3214
|
docs.pivot,
|
|
3215
|
+
p.has("match_recognize") ? " " : "",
|
|
3216
|
+
docs.match_recognize,
|
|
3039
3217
|
]),
|
|
3040
3218
|
p.has("orderby") ? line : "",
|
|
3041
3219
|
docs.orderby,
|
|
@@ -3097,6 +3275,7 @@ const printIdentifier = (path, options, print, node) => {
|
|
|
3097
3275
|
for_system_time_as_of: p.child("for_system_time_as_of", undefined, "all"),
|
|
3098
3276
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
3099
3277
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3278
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
3100
3279
|
with_offset: p.child("with_offset", undefined, "all"),
|
|
3101
3280
|
tablesample: p.child("tablesample", undefined, "all"),
|
|
3102
3281
|
order: printOrder(path, options, print, node),
|
|
@@ -3110,6 +3289,8 @@ const printIdentifier = (path, options, print, node) => {
|
|
|
3110
3289
|
docs.alias,
|
|
3111
3290
|
p.has("for_system_time_as_of") ? [" ", docs.for_system_time_as_of] : "",
|
|
3112
3291
|
docs.pivot,
|
|
3292
|
+
p.has("match_recognize") ? " " : "",
|
|
3293
|
+
docs.match_recognize,
|
|
3113
3294
|
p.has("with_offset") ? " " : "",
|
|
3114
3295
|
docs.with_offset,
|
|
3115
3296
|
p.has("tablesample") ? [" ", docs.tablesample] : "",
|
|
@@ -3317,6 +3498,7 @@ const printJoinOperator = (path, options, print, node) => {
|
|
|
3317
3498
|
alias: printAlias(path, options, print, node),
|
|
3318
3499
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
3319
3500
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3501
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
3320
3502
|
with_offset: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3321
3503
|
};
|
|
3322
3504
|
return [
|
|
@@ -3339,6 +3521,8 @@ const printJoinOperator = (path, options, print, node) => {
|
|
|
3339
3521
|
docs.using,
|
|
3340
3522
|
docs.alias,
|
|
3341
3523
|
docs.pivot,
|
|
3524
|
+
p.has("match_recognize") ? " " : "",
|
|
3525
|
+
docs.match_recognize,
|
|
3342
3526
|
];
|
|
3343
3527
|
};
|
|
3344
3528
|
const printJoinPipeOperator = (path, options, print, node) => {
|
|
@@ -3637,6 +3821,71 @@ const printLoopStatement = (path, options, print, node) => {
|
|
|
3637
3821
|
p.newLine(),
|
|
3638
3822
|
];
|
|
3639
3823
|
};
|
|
3824
|
+
const printMatchRecognizeClause = (path, options, print, node) => {
|
|
3825
|
+
const p = new Printer(path, options, print, node);
|
|
3826
|
+
const docs = {
|
|
3827
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
3828
|
+
self: p.self("upper"),
|
|
3829
|
+
config: p.child("config", undefined, "all"),
|
|
3830
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
3831
|
+
as: p.child("as", undefined, "all"),
|
|
3832
|
+
alias: p.child("alias", undefined, "all"),
|
|
3833
|
+
};
|
|
3834
|
+
return [
|
|
3835
|
+
docs.leading_comments,
|
|
3836
|
+
docs.self,
|
|
3837
|
+
docs.trailing_comments,
|
|
3838
|
+
" ",
|
|
3839
|
+
docs.config,
|
|
3840
|
+
p.has("alias")
|
|
3841
|
+
? [" ", docs.as || (options.printKeywordsInUpperCase ? "AS" : "as")]
|
|
3842
|
+
: "",
|
|
3843
|
+
p.has("alias") ? [" ", docs.alias] : "",
|
|
3844
|
+
];
|
|
3845
|
+
};
|
|
3846
|
+
const printMatchRecognizeConfig = (path, options, print, node) => {
|
|
3847
|
+
const p = new Printer(path, options, print, node);
|
|
3848
|
+
const docs = {
|
|
3849
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
3850
|
+
self: p.self("upper", true),
|
|
3851
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
3852
|
+
partitionby: p.child("partitionby"),
|
|
3853
|
+
orderby: p.child("orderby"),
|
|
3854
|
+
measures: p.child("measures"),
|
|
3855
|
+
skip_rule: p.child("skip_rule"),
|
|
3856
|
+
pattern: p.child("pattern"),
|
|
3857
|
+
define: p.child("define"),
|
|
3858
|
+
options: p.child("options"),
|
|
3859
|
+
rparen: p.child("rparen"),
|
|
3860
|
+
};
|
|
3861
|
+
return [
|
|
3862
|
+
docs.leading_comments,
|
|
3863
|
+
docs.self,
|
|
3864
|
+
docs.trailing_comments,
|
|
3865
|
+
indent([
|
|
3866
|
+
hardline,
|
|
3867
|
+
group(docs.partitionby),
|
|
3868
|
+
p.has("partitionby") ? line : "",
|
|
3869
|
+
group(docs.orderby),
|
|
3870
|
+
// some are necessary but handle as if optional for simplicity
|
|
3871
|
+
p.has("measures") ? line : "",
|
|
3872
|
+
docs.measures,
|
|
3873
|
+
p.has("skip_rule") ? line : "",
|
|
3874
|
+
docs.skip_rule,
|
|
3875
|
+
p.has("pattern") ? line : "",
|
|
3876
|
+
docs.pattern,
|
|
3877
|
+
p.has("define") ? line : "",
|
|
3878
|
+
docs.define,
|
|
3879
|
+
p.has("options") ? line : "",
|
|
3880
|
+
docs.options,
|
|
3881
|
+
]),
|
|
3882
|
+
softline,
|
|
3883
|
+
docs.rparen,
|
|
3884
|
+
];
|
|
3885
|
+
};
|
|
3886
|
+
const printMatchRecognizePipeOperator = (path, options, print, node) => {
|
|
3887
|
+
return printMatchRecognizeClause(path, options, print, node);
|
|
3888
|
+
};
|
|
3640
3889
|
const printMergeStatement = (path, options, print, node) => {
|
|
3641
3890
|
const p = new Printer(path, options, print, node);
|
|
3642
3891
|
const docs = {
|
|
@@ -3681,6 +3930,7 @@ const printMultiTokenIdentifier = (path, options, print, node) => {
|
|
|
3681
3930
|
for_system_time_as_of: p.child("for_system_time_as_of", undefined, "all"),
|
|
3682
3931
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
3683
3932
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3933
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
3684
3934
|
with_offset: p.child("with_offset", undefined, "all"),
|
|
3685
3935
|
tablesample: p.child("tablesample", undefined, "all"),
|
|
3686
3936
|
// NOTE order, null_order, comma may be unnecessary for the time being.
|
|
@@ -3696,6 +3946,8 @@ const printMultiTokenIdentifier = (path, options, print, node) => {
|
|
|
3696
3946
|
docs.alias,
|
|
3697
3947
|
p.has("for_system_time_as_of") ? [" ", docs.for_system_time_as_of] : "",
|
|
3698
3948
|
docs.pivot,
|
|
3949
|
+
p.has("match_recognize") ? " " : "",
|
|
3950
|
+
docs.match_recognize,
|
|
3699
3951
|
p.has("with_offset") ? " " : "",
|
|
3700
3952
|
docs.with_offset,
|
|
3701
3953
|
p.has("tablesample") ? [" ", docs.tablesample] : "",
|
|
@@ -3745,6 +3997,24 @@ const printNumericLiteral = (path, options, print, node) => {
|
|
|
3745
3997
|
docs.comma,
|
|
3746
3998
|
];
|
|
3747
3999
|
};
|
|
4000
|
+
const printOrPattern = (path, options, print, node) => {
|
|
4001
|
+
var _a;
|
|
4002
|
+
const p = new Printer(path, options, print, node);
|
|
4003
|
+
const docs = {
|
|
4004
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
4005
|
+
self: p.self("upper"),
|
|
4006
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
4007
|
+
left: p.child("left", undefined, "none", line),
|
|
4008
|
+
right: p.child("right", undefined, "all", line),
|
|
4009
|
+
};
|
|
4010
|
+
const left_is_or_pattern = ((_a = node.children.left.NodeVec[0]) === null || _a === void 0 ? void 0 : _a.node_type) === "OrPattern";
|
|
4011
|
+
return [
|
|
4012
|
+
left_is_or_pattern ? docs.left : group(docs.left),
|
|
4013
|
+
line,
|
|
4014
|
+
docs.leading_comments,
|
|
4015
|
+
group([docs.self, docs.trailing_comments, indent([line, docs.right])]),
|
|
4016
|
+
];
|
|
4017
|
+
};
|
|
3748
4018
|
const printOverClause = (path, options, print, node) => {
|
|
3749
4019
|
const p = new Printer(path, options, print, node);
|
|
3750
4020
|
const docs = {
|
|
@@ -3773,6 +4043,58 @@ const printOverwritePartitionsClause = (path, options, print, node) => {
|
|
|
3773
4043
|
docs.grouped_expr,
|
|
3774
4044
|
]);
|
|
3775
4045
|
};
|
|
4046
|
+
const printPattern = (path, options, print, node) => {
|
|
4047
|
+
const p = new Printer(path, options, print, node);
|
|
4048
|
+
const docs = {
|
|
4049
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
4050
|
+
self: p.self("asItIs"),
|
|
4051
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
4052
|
+
suffixes: p.child("suffixes", undefined, "all"),
|
|
4053
|
+
};
|
|
4054
|
+
return [
|
|
4055
|
+
docs.leading_comments,
|
|
4056
|
+
docs.self,
|
|
4057
|
+
docs.trailing_comments,
|
|
4058
|
+
docs.suffixes,
|
|
4059
|
+
];
|
|
4060
|
+
};
|
|
4061
|
+
const printPatternClause = (path, options, print, node) => {
|
|
4062
|
+
const p = new Printer(path, options, print, node);
|
|
4063
|
+
const docs = {
|
|
4064
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
4065
|
+
self: p.self("upper"),
|
|
4066
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
4067
|
+
pattern: p.child("pattern", undefined, "all"),
|
|
4068
|
+
};
|
|
4069
|
+
return [
|
|
4070
|
+
docs.leading_comments,
|
|
4071
|
+
docs.self,
|
|
4072
|
+
docs.trailing_comments,
|
|
4073
|
+
" ",
|
|
4074
|
+
docs.pattern,
|
|
4075
|
+
];
|
|
4076
|
+
};
|
|
4077
|
+
const printPatternQuantifier = (path, options, print, node) => {
|
|
4078
|
+
const p = new Printer(path, options, print, node);
|
|
4079
|
+
const docs = {
|
|
4080
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
4081
|
+
self: p.self("upper"),
|
|
4082
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
4083
|
+
min: p.child("min", undefined, "all"),
|
|
4084
|
+
comma: p.child("comma", undefined, "all"),
|
|
4085
|
+
max: p.child("max", undefined, "all"),
|
|
4086
|
+
rbrace: p.child("rbrace", undefined, "all"),
|
|
4087
|
+
};
|
|
4088
|
+
return [
|
|
4089
|
+
docs.leading_comments,
|
|
4090
|
+
docs.self,
|
|
4091
|
+
docs.trailing_comments,
|
|
4092
|
+
docs.min,
|
|
4093
|
+
docs.comma,
|
|
4094
|
+
docs.max,
|
|
4095
|
+
docs.rbrace,
|
|
4096
|
+
];
|
|
4097
|
+
};
|
|
3776
4098
|
const printPipeStatement = (path, options, print, node) => {
|
|
3777
4099
|
const p = new Printer(path, options, print, node);
|
|
3778
4100
|
p.setNotRoot("left");
|
|
@@ -4013,6 +4335,32 @@ const printRepeatStatement = (path, options, print, node) => {
|
|
|
4013
4335
|
p.newLine(),
|
|
4014
4336
|
];
|
|
4015
4337
|
};
|
|
4338
|
+
const printSelectPipeOperator = (path, options, print, node) => {
|
|
4339
|
+
const p = new Printer(path, options, print, node);
|
|
4340
|
+
p.setNotRoot("exprs");
|
|
4341
|
+
p.setGroupRecommended("exprs");
|
|
4342
|
+
if (node.children.exprs) {
|
|
4343
|
+
node.children.exprs.NodeVec[p.len("exprs") - 1].isFinalColumn = true;
|
|
4344
|
+
}
|
|
4345
|
+
const docs = {
|
|
4346
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
4347
|
+
self: p.self(),
|
|
4348
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
4349
|
+
keywords: p.child("keywords", undefined, "all"),
|
|
4350
|
+
exprs: p.child("exprs", (x) => group([line, x])),
|
|
4351
|
+
window: p.child("window"),
|
|
4352
|
+
};
|
|
4353
|
+
return [
|
|
4354
|
+
docs.leading_comments,
|
|
4355
|
+
docs.self,
|
|
4356
|
+
docs.trailing_comments,
|
|
4357
|
+
p.has("keywords") ? " " : "",
|
|
4358
|
+
docs.keywords,
|
|
4359
|
+
indent(docs.exprs),
|
|
4360
|
+
p.has("window") ? line : "",
|
|
4361
|
+
docs.window,
|
|
4362
|
+
];
|
|
4363
|
+
};
|
|
4016
4364
|
const printSelectStatement = (path, options, print, node) => {
|
|
4017
4365
|
const p = new Printer(path, options, print, node);
|
|
4018
4366
|
p.setNotRoot("exprs");
|
|
@@ -4866,6 +5214,9 @@ const printWithPartitionColumnsClause = (path, options, print, node) => {
|
|
|
4866
5214
|
]),
|
|
4867
5215
|
];
|
|
4868
5216
|
};
|
|
5217
|
+
const printWithPipeOperator = (path, options, print, node) => {
|
|
5218
|
+
return printWithClause(path, options, print, node);
|
|
5219
|
+
};
|
|
4869
5220
|
const printWithQuery = (path, options, print, node) => {
|
|
4870
5221
|
const p = new Printer(path, options, print, node);
|
|
4871
5222
|
p.setNotRoot("stmt");
|
|
@@ -4922,7 +5273,7 @@ const printAlias = (path, options, print, node) => {
|
|
|
4922
5273
|
else {
|
|
4923
5274
|
as_ = options.printKeywordsInUpperCase ? "AS" : "as";
|
|
4924
5275
|
}
|
|
4925
|
-
return [" ", as_, " ", p.child("alias", undefined, "all")];
|
|
5276
|
+
return [" ", as_, " ", group(p.child("alias", undefined, "all"))];
|
|
4926
5277
|
};
|
|
4927
5278
|
const printComma = (path, options, print, node) => {
|
|
4928
5279
|
const p = new Printer(path, options, print, node);
|