prettier-plugin-bq 0.2.60 → 1.0.0-beta.1
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/LICENSE +1 -1
- package/dist/keywords.d.ts +1 -0
- package/dist/keywords.js +12 -2
- package/dist/keywords.js.map +1 -1
- package/dist/printer.d.ts +1 -0
- package/dist/printer.js +339 -6
- package/dist/printer.js.map +1 -1
- package/package.json +8 -20
- package/README.md +0 -41
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 = {
|
|
@@ -1539,6 +1596,12 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1539
1596
|
toUpper(parent.token);
|
|
1540
1597
|
}
|
|
1541
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;
|
|
1542
1605
|
}
|
|
1543
1606
|
}
|
|
1544
1607
|
else if (parent.node_type === "DotOperator") {
|
|
@@ -1603,6 +1666,13 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1603
1666
|
toUpper(grandParent.token);
|
|
1604
1667
|
}
|
|
1605
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;
|
|
1606
1676
|
}
|
|
1607
1677
|
}
|
|
1608
1678
|
}
|
|
@@ -1614,11 +1684,11 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1614
1684
|
// NORMALIZE
|
|
1615
1685
|
if (["NORMALIZE", "NORMALIZE_AND_CASEFOLD"].includes(func_literal) &&
|
|
1616
1686
|
2 <= p.len("args")) {
|
|
1617
|
-
toUpper(args.NodeVec[1].token);
|
|
1687
|
+
toUpper(args.NodeVec[node.isChained ? 0 : 1].token);
|
|
1618
1688
|
}
|
|
1619
1689
|
// XXX_DIFF
|
|
1620
1690
|
if (["DATE_DIFF", "DATETIME_DIFF", "TIME_DIFF", "TIMESTAMP_DIFF"].includes(func_literal)) {
|
|
1621
|
-
args.NodeVec[2].isDatePart = true;
|
|
1691
|
+
args.NodeVec[node.isChained ? 1 : 2].isDatePart = true;
|
|
1622
1692
|
}
|
|
1623
1693
|
// XXX_TRUNC
|
|
1624
1694
|
if ([
|
|
@@ -1627,11 +1697,11 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1627
1697
|
"TIME_TRUNC",
|
|
1628
1698
|
"TIMESTAMP_TRUNC",
|
|
1629
1699
|
].includes(func_literal)) {
|
|
1630
|
-
args.NodeVec[1].isDatePart = true;
|
|
1700
|
+
args.NodeVec[node.isChained ? 0 : 1].isDatePart = true;
|
|
1631
1701
|
}
|
|
1632
1702
|
// LAST_DAY
|
|
1633
1703
|
if (func_literal === "LAST_DAY" && 2 <= p.len("args")) {
|
|
1634
|
-
args.NodeVec[1].isDatePart = true;
|
|
1704
|
+
args.NodeVec[node.isChained ? 0 : 1].isDatePart = true;
|
|
1635
1705
|
}
|
|
1636
1706
|
}
|
|
1637
1707
|
}
|
|
@@ -1699,10 +1769,12 @@ const printCallingFunctionGeneral = (path, options, print, node) => {
|
|
|
1699
1769
|
];
|
|
1700
1770
|
};
|
|
1701
1771
|
const printCallingTableFunction = (path, options, print, node) => {
|
|
1772
|
+
const p = new Printer(path, options, print, node);
|
|
1702
1773
|
const docs = {
|
|
1703
1774
|
self: printCallingFunctionGeneral(path, options, print, node),
|
|
1704
1775
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
1705
1776
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
1777
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
1706
1778
|
with_offset: "", // eslint-disable-line unicorn/no-unused-properties
|
|
1707
1779
|
/* eslint-disable unicorn/no-unused-properties */
|
|
1708
1780
|
leading_comments: "",
|
|
@@ -1714,7 +1786,12 @@ const printCallingTableFunction = (path, options, print, node) => {
|
|
|
1714
1786
|
alias: "",
|
|
1715
1787
|
/* eslint-enable unicorn/no-unused-properties */
|
|
1716
1788
|
};
|
|
1717
|
-
return [
|
|
1789
|
+
return [
|
|
1790
|
+
docs.self,
|
|
1791
|
+
docs.pivot,
|
|
1792
|
+
p.has("match_recognize") ? " " : "",
|
|
1793
|
+
docs.match_recognize,
|
|
1794
|
+
];
|
|
1718
1795
|
};
|
|
1719
1796
|
const printCallingUnnest = (path, options, print, node) => {
|
|
1720
1797
|
const p = new Printer(path, options, print, node);
|
|
@@ -1723,6 +1800,7 @@ const printCallingUnnest = (path, options, print, node) => {
|
|
|
1723
1800
|
with_offset: p.child("with_offset", undefined, "all"),
|
|
1724
1801
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
1725
1802
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
1803
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
1726
1804
|
/* eslint-disable unicorn/no-unused-properties */
|
|
1727
1805
|
leading_comments: "",
|
|
1728
1806
|
func: "",
|
|
@@ -1738,6 +1816,8 @@ const printCallingUnnest = (path, options, print, node) => {
|
|
|
1738
1816
|
p.has("with_offset") ? " " : "",
|
|
1739
1817
|
docs.with_offset,
|
|
1740
1818
|
docs.pivot,
|
|
1819
|
+
p.has("match_recognize") ? " " : "",
|
|
1820
|
+
docs.match_recognize,
|
|
1741
1821
|
];
|
|
1742
1822
|
};
|
|
1743
1823
|
const printCallStatement = (path, options, print, node) => {
|
|
@@ -2283,6 +2363,7 @@ const printCreateIndexStatement = (path, options, print, node) => {
|
|
|
2283
2363
|
tablename: p.child("tablename", undefined, "all"),
|
|
2284
2364
|
column_group: p.child("column_group", undefined, "all"),
|
|
2285
2365
|
storing: p.child("storing"),
|
|
2366
|
+
partitionby: p.child("partitionby"),
|
|
2286
2367
|
options: p.child("options"),
|
|
2287
2368
|
semicolon: p.child("semicolon"),
|
|
2288
2369
|
};
|
|
@@ -2305,6 +2386,8 @@ const printCreateIndexStatement = (path, options, print, node) => {
|
|
|
2305
2386
|
docs.column_group,
|
|
2306
2387
|
p.has("storing") ? line : "",
|
|
2307
2388
|
docs.storing,
|
|
2389
|
+
p.has("partitionby") ? line : "",
|
|
2390
|
+
docs.partitionby,
|
|
2308
2391
|
p.has("options") ? line : "",
|
|
2309
2392
|
docs.options,
|
|
2310
2393
|
p.has("semicolon") ? softline : "",
|
|
@@ -2521,6 +2604,7 @@ const printDotOperator = (path, options, print, node) => {
|
|
|
2521
2604
|
for_system_time_as_of: p.child("for_system_time_as_of", undefined, "all"),
|
|
2522
2605
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
2523
2606
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
2607
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
2524
2608
|
with_offset: p.child("with_offset", undefined, "all"),
|
|
2525
2609
|
tablesample: p.child("tablesample", undefined, "all"),
|
|
2526
2610
|
order: printOrder(path, options, print, node),
|
|
@@ -2535,6 +2619,8 @@ const printDotOperator = (path, options, print, node) => {
|
|
|
2535
2619
|
docs.alias,
|
|
2536
2620
|
p.has("for_system_time_as_of") ? [" ", docs.for_system_time_as_of] : "",
|
|
2537
2621
|
docs.pivot,
|
|
2622
|
+
p.has("match_recognize") ? " " : "",
|
|
2623
|
+
docs.match_recognize,
|
|
2538
2624
|
p.has("with_offset") ? " " : "",
|
|
2539
2625
|
docs.with_offset,
|
|
2540
2626
|
p.has("tablesample") ? [" ", docs.tablesample] : "",
|
|
@@ -2848,6 +2934,7 @@ const printForSystemTimeAsOfclause = (path, options, print, node) => {
|
|
|
2848
2934
|
const printFromStatement = (path, options, print, node) => {
|
|
2849
2935
|
const p = new Printer(path, options, print, node);
|
|
2850
2936
|
const docs = {
|
|
2937
|
+
with: p.child("with"),
|
|
2851
2938
|
leading_comments: printLeadingComments(path, options, print, node),
|
|
2852
2939
|
self: p.self("upper"),
|
|
2853
2940
|
trailing_comments: printTrailingComments(path, options, print, node),
|
|
@@ -2855,8 +2942,11 @@ const printFromStatement = (path, options, print, node) => {
|
|
|
2855
2942
|
semicolon: p.child("semicolon"),
|
|
2856
2943
|
};
|
|
2857
2944
|
return [
|
|
2945
|
+
docs.with,
|
|
2946
|
+
p.has("with") ? hardline : "",
|
|
2858
2947
|
docs.leading_comments,
|
|
2859
2948
|
group([
|
|
2949
|
+
p.has("with") ? breakParent : "",
|
|
2860
2950
|
docs.self,
|
|
2861
2951
|
docs.trailing_comments,
|
|
2862
2952
|
" ",
|
|
@@ -2867,6 +2957,48 @@ const printFromStatement = (path, options, print, node) => {
|
|
|
2867
2957
|
p.newLine(),
|
|
2868
2958
|
];
|
|
2869
2959
|
};
|
|
2960
|
+
const printFunctionChain = (path, options, print, node) => {
|
|
2961
|
+
const p = new Printer(path, options, print, node);
|
|
2962
|
+
node.children.right.Node.isChained = true;
|
|
2963
|
+
const docs = {
|
|
2964
|
+
left: p.child("left"),
|
|
2965
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
2966
|
+
self: p.self("upper"),
|
|
2967
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
2968
|
+
right: p.child("right", undefined, "all"),
|
|
2969
|
+
as: "", // eslint-disable-line unicorn/no-unused-properties
|
|
2970
|
+
alias: printAlias(path, options, print, node),
|
|
2971
|
+
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
2972
|
+
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
2973
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
2974
|
+
with_offset: p.child("with_offset", undefined, "all"),
|
|
2975
|
+
order: printOrder(path, options, print, node),
|
|
2976
|
+
null_order: "", // eslint-disable-line unicorn/no-unused-properties
|
|
2977
|
+
comma: printComma(path, options, print, node),
|
|
2978
|
+
};
|
|
2979
|
+
let res = [
|
|
2980
|
+
docs.left,
|
|
2981
|
+
softline,
|
|
2982
|
+
docs.leading_comments,
|
|
2983
|
+
docs.self,
|
|
2984
|
+
docs.trailing_comments,
|
|
2985
|
+
docs.right,
|
|
2986
|
+
docs.alias,
|
|
2987
|
+
];
|
|
2988
|
+
if (node.groupRecommended) {
|
|
2989
|
+
res = group(res);
|
|
2990
|
+
}
|
|
2991
|
+
return [
|
|
2992
|
+
res,
|
|
2993
|
+
docs.pivot,
|
|
2994
|
+
p.has("match_recognize") ? " " : "",
|
|
2995
|
+
docs.match_recognize,
|
|
2996
|
+
p.has("with_offset") ? " " : "",
|
|
2997
|
+
docs.with_offset,
|
|
2998
|
+
docs.order,
|
|
2999
|
+
docs.comma,
|
|
3000
|
+
];
|
|
3001
|
+
};
|
|
2870
3002
|
const printGrantStatement = (path, options, print, node) => {
|
|
2871
3003
|
const p = new Printer(path, options, print, node);
|
|
2872
3004
|
const docs = {
|
|
@@ -2937,6 +3069,7 @@ const printGroupedExpr = (path, options, print, node) => {
|
|
|
2937
3069
|
alias: printAlias(path, options, print, node),
|
|
2938
3070
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
2939
3071
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3072
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
2940
3073
|
with_offset: "", // eslint-disable-line unicorn/no-unused-properties
|
|
2941
3074
|
order: printOrder(path, options, print, node),
|
|
2942
3075
|
null_order: "", // eslint-disable-line unicorn/no-unused-properties
|
|
@@ -2953,6 +3086,8 @@ const printGroupedExpr = (path, options, print, node) => {
|
|
|
2953
3086
|
]),
|
|
2954
3087
|
docs.alias,
|
|
2955
3088
|
docs.pivot,
|
|
3089
|
+
p.has("match_recognize") ? " " : "",
|
|
3090
|
+
docs.match_recognize,
|
|
2956
3091
|
docs.order,
|
|
2957
3092
|
docs.comma,
|
|
2958
3093
|
];
|
|
@@ -3008,6 +3143,28 @@ const printGroupedIdentWithOptions = (path, options, print, node) => {
|
|
|
3008
3143
|
]),
|
|
3009
3144
|
];
|
|
3010
3145
|
};
|
|
3146
|
+
const printGroupedPattern = (path, options, print, node) => {
|
|
3147
|
+
const p = new Printer(path, options, print, node);
|
|
3148
|
+
const docs = {
|
|
3149
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
3150
|
+
self: p.self(),
|
|
3151
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
3152
|
+
patterns: p.child("patterns", undefined, "none", line),
|
|
3153
|
+
rparen: p.child("rparen"),
|
|
3154
|
+
suffixes: p.child("suffixes", undefined, "all"),
|
|
3155
|
+
};
|
|
3156
|
+
return [
|
|
3157
|
+
docs.leading_comments,
|
|
3158
|
+
group([
|
|
3159
|
+
docs.self,
|
|
3160
|
+
docs.trailing_comments,
|
|
3161
|
+
indent([softline, docs.patterns]),
|
|
3162
|
+
softline,
|
|
3163
|
+
docs.rparen,
|
|
3164
|
+
docs.suffixes,
|
|
3165
|
+
]),
|
|
3166
|
+
];
|
|
3167
|
+
};
|
|
3011
3168
|
const printGroupedStatement = (path, options, print, node) => {
|
|
3012
3169
|
const p = new Printer(path, options, print, node);
|
|
3013
3170
|
p.setNotRoot("stmt");
|
|
@@ -3022,6 +3179,7 @@ const printGroupedStatement = (path, options, print, node) => {
|
|
|
3022
3179
|
alias: printAlias(path, options, print, node),
|
|
3023
3180
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
3024
3181
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3182
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
3025
3183
|
with_offset: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3026
3184
|
orderby: p.child("orderby"),
|
|
3027
3185
|
limit: p.child("limit"),
|
|
@@ -3049,6 +3207,8 @@ const printGroupedStatement = (path, options, print, node) => {
|
|
|
3049
3207
|
softline,
|
|
3050
3208
|
docs.rparen,
|
|
3051
3209
|
docs.pivot,
|
|
3210
|
+
p.has("match_recognize") ? " " : "",
|
|
3211
|
+
docs.match_recognize,
|
|
3052
3212
|
]),
|
|
3053
3213
|
p.has("orderby") ? line : "",
|
|
3054
3214
|
docs.orderby,
|
|
@@ -3110,6 +3270,7 @@ const printIdentifier = (path, options, print, node) => {
|
|
|
3110
3270
|
for_system_time_as_of: p.child("for_system_time_as_of", undefined, "all"),
|
|
3111
3271
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
3112
3272
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3273
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
3113
3274
|
with_offset: p.child("with_offset", undefined, "all"),
|
|
3114
3275
|
tablesample: p.child("tablesample", undefined, "all"),
|
|
3115
3276
|
order: printOrder(path, options, print, node),
|
|
@@ -3123,6 +3284,8 @@ const printIdentifier = (path, options, print, node) => {
|
|
|
3123
3284
|
docs.alias,
|
|
3124
3285
|
p.has("for_system_time_as_of") ? [" ", docs.for_system_time_as_of] : "",
|
|
3125
3286
|
docs.pivot,
|
|
3287
|
+
p.has("match_recognize") ? " " : "",
|
|
3288
|
+
docs.match_recognize,
|
|
3126
3289
|
p.has("with_offset") ? " " : "",
|
|
3127
3290
|
docs.with_offset,
|
|
3128
3291
|
p.has("tablesample") ? [" ", docs.tablesample] : "",
|
|
@@ -3330,6 +3493,7 @@ const printJoinOperator = (path, options, print, node) => {
|
|
|
3330
3493
|
alias: printAlias(path, options, print, node),
|
|
3331
3494
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
3332
3495
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3496
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
3333
3497
|
with_offset: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3334
3498
|
};
|
|
3335
3499
|
return [
|
|
@@ -3352,6 +3516,8 @@ const printJoinOperator = (path, options, print, node) => {
|
|
|
3352
3516
|
docs.using,
|
|
3353
3517
|
docs.alias,
|
|
3354
3518
|
docs.pivot,
|
|
3519
|
+
p.has("match_recognize") ? " " : "",
|
|
3520
|
+
docs.match_recognize,
|
|
3355
3521
|
];
|
|
3356
3522
|
};
|
|
3357
3523
|
const printJoinPipeOperator = (path, options, print, node) => {
|
|
@@ -3650,6 +3816,71 @@ const printLoopStatement = (path, options, print, node) => {
|
|
|
3650
3816
|
p.newLine(),
|
|
3651
3817
|
];
|
|
3652
3818
|
};
|
|
3819
|
+
const printMatchRecognizeClause = (path, options, print, node) => {
|
|
3820
|
+
const p = new Printer(path, options, print, node);
|
|
3821
|
+
const docs = {
|
|
3822
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
3823
|
+
self: p.self("upper"),
|
|
3824
|
+
config: p.child("config", undefined, "all"),
|
|
3825
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
3826
|
+
as: p.child("as", undefined, "all"),
|
|
3827
|
+
alias: p.child("alias", undefined, "all"),
|
|
3828
|
+
};
|
|
3829
|
+
return [
|
|
3830
|
+
docs.leading_comments,
|
|
3831
|
+
docs.self,
|
|
3832
|
+
docs.trailing_comments,
|
|
3833
|
+
" ",
|
|
3834
|
+
docs.config,
|
|
3835
|
+
p.has("alias")
|
|
3836
|
+
? [" ", docs.as || (options.printKeywordsInUpperCase ? "AS" : "as")]
|
|
3837
|
+
: "",
|
|
3838
|
+
p.has("alias") ? [" ", docs.alias] : "",
|
|
3839
|
+
];
|
|
3840
|
+
};
|
|
3841
|
+
const printMatchRecognizeConfig = (path, options, print, node) => {
|
|
3842
|
+
const p = new Printer(path, options, print, node);
|
|
3843
|
+
const docs = {
|
|
3844
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
3845
|
+
self: p.self("upper", true),
|
|
3846
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
3847
|
+
partitionby: p.child("partitionby"),
|
|
3848
|
+
orderby: p.child("orderby"),
|
|
3849
|
+
measures: p.child("measures"),
|
|
3850
|
+
skip_rule: p.child("skip_rule"),
|
|
3851
|
+
pattern: p.child("pattern"),
|
|
3852
|
+
define: p.child("define"),
|
|
3853
|
+
options: p.child("options"),
|
|
3854
|
+
rparen: p.child("rparen"),
|
|
3855
|
+
};
|
|
3856
|
+
return [
|
|
3857
|
+
docs.leading_comments,
|
|
3858
|
+
docs.self,
|
|
3859
|
+
docs.trailing_comments,
|
|
3860
|
+
indent([
|
|
3861
|
+
hardline,
|
|
3862
|
+
group(docs.partitionby),
|
|
3863
|
+
p.has("partitionby") ? line : "",
|
|
3864
|
+
group(docs.orderby),
|
|
3865
|
+
// some are necessary but handle as if optional for simplicity
|
|
3866
|
+
p.has("measures") ? line : "",
|
|
3867
|
+
docs.measures,
|
|
3868
|
+
p.has("skip_rule") ? line : "",
|
|
3869
|
+
docs.skip_rule,
|
|
3870
|
+
p.has("pattern") ? line : "",
|
|
3871
|
+
docs.pattern,
|
|
3872
|
+
p.has("define") ? line : "",
|
|
3873
|
+
docs.define,
|
|
3874
|
+
p.has("options") ? line : "",
|
|
3875
|
+
docs.options,
|
|
3876
|
+
]),
|
|
3877
|
+
softline,
|
|
3878
|
+
docs.rparen,
|
|
3879
|
+
];
|
|
3880
|
+
};
|
|
3881
|
+
const printMatchRecognizePipeOperator = (path, options, print, node) => {
|
|
3882
|
+
return printMatchRecognizeClause(path, options, print, node);
|
|
3883
|
+
};
|
|
3653
3884
|
const printMergeStatement = (path, options, print, node) => {
|
|
3654
3885
|
const p = new Printer(path, options, print, node);
|
|
3655
3886
|
const docs = {
|
|
@@ -3694,6 +3925,7 @@ const printMultiTokenIdentifier = (path, options, print, node) => {
|
|
|
3694
3925
|
for_system_time_as_of: p.child("for_system_time_as_of", undefined, "all"),
|
|
3695
3926
|
pivot: printPivotOrUnpivotOperator(path, options, print, node),
|
|
3696
3927
|
unpivot: "", // eslint-disable-line unicorn/no-unused-properties
|
|
3928
|
+
match_recognize: p.child("match_recognize", undefined, "all"),
|
|
3697
3929
|
with_offset: p.child("with_offset", undefined, "all"),
|
|
3698
3930
|
tablesample: p.child("tablesample", undefined, "all"),
|
|
3699
3931
|
// NOTE order, null_order, comma may be unnecessary for the time being.
|
|
@@ -3709,6 +3941,8 @@ const printMultiTokenIdentifier = (path, options, print, node) => {
|
|
|
3709
3941
|
docs.alias,
|
|
3710
3942
|
p.has("for_system_time_as_of") ? [" ", docs.for_system_time_as_of] : "",
|
|
3711
3943
|
docs.pivot,
|
|
3944
|
+
p.has("match_recognize") ? " " : "",
|
|
3945
|
+
docs.match_recognize,
|
|
3712
3946
|
p.has("with_offset") ? " " : "",
|
|
3713
3947
|
docs.with_offset,
|
|
3714
3948
|
p.has("tablesample") ? [" ", docs.tablesample] : "",
|
|
@@ -3758,6 +3992,24 @@ const printNumericLiteral = (path, options, print, node) => {
|
|
|
3758
3992
|
docs.comma,
|
|
3759
3993
|
];
|
|
3760
3994
|
};
|
|
3995
|
+
const printOrPattern = (path, options, print, node) => {
|
|
3996
|
+
var _a;
|
|
3997
|
+
const p = new Printer(path, options, print, node);
|
|
3998
|
+
const docs = {
|
|
3999
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
4000
|
+
self: p.self("upper"),
|
|
4001
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
4002
|
+
left: p.child("left", undefined, "none", line),
|
|
4003
|
+
right: p.child("right", undefined, "all", line),
|
|
4004
|
+
};
|
|
4005
|
+
const left_is_or_pattern = ((_a = node.children.left.NodeVec[0]) === null || _a === void 0 ? void 0 : _a.node_type) === "OrPattern";
|
|
4006
|
+
return [
|
|
4007
|
+
left_is_or_pattern ? docs.left : group(docs.left),
|
|
4008
|
+
line,
|
|
4009
|
+
docs.leading_comments,
|
|
4010
|
+
group([docs.self, docs.trailing_comments, indent([line, docs.right])]),
|
|
4011
|
+
];
|
|
4012
|
+
};
|
|
3761
4013
|
const printOverClause = (path, options, print, node) => {
|
|
3762
4014
|
const p = new Printer(path, options, print, node);
|
|
3763
4015
|
const docs = {
|
|
@@ -3786,6 +4038,58 @@ const printOverwritePartitionsClause = (path, options, print, node) => {
|
|
|
3786
4038
|
docs.grouped_expr,
|
|
3787
4039
|
]);
|
|
3788
4040
|
};
|
|
4041
|
+
const printPattern = (path, options, print, node) => {
|
|
4042
|
+
const p = new Printer(path, options, print, node);
|
|
4043
|
+
const docs = {
|
|
4044
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
4045
|
+
self: p.self("asItIs"),
|
|
4046
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
4047
|
+
suffixes: p.child("suffixes", undefined, "all"),
|
|
4048
|
+
};
|
|
4049
|
+
return [
|
|
4050
|
+
docs.leading_comments,
|
|
4051
|
+
docs.self,
|
|
4052
|
+
docs.trailing_comments,
|
|
4053
|
+
docs.suffixes,
|
|
4054
|
+
];
|
|
4055
|
+
};
|
|
4056
|
+
const printPatternClause = (path, options, print, node) => {
|
|
4057
|
+
const p = new Printer(path, options, print, node);
|
|
4058
|
+
const docs = {
|
|
4059
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
4060
|
+
self: p.self("upper"),
|
|
4061
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
4062
|
+
pattern: p.child("pattern", undefined, "all"),
|
|
4063
|
+
};
|
|
4064
|
+
return [
|
|
4065
|
+
docs.leading_comments,
|
|
4066
|
+
docs.self,
|
|
4067
|
+
docs.trailing_comments,
|
|
4068
|
+
" ",
|
|
4069
|
+
docs.pattern,
|
|
4070
|
+
];
|
|
4071
|
+
};
|
|
4072
|
+
const printPatternQuantifier = (path, options, print, node) => {
|
|
4073
|
+
const p = new Printer(path, options, print, node);
|
|
4074
|
+
const docs = {
|
|
4075
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
4076
|
+
self: p.self("upper"),
|
|
4077
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
4078
|
+
min: p.child("min", undefined, "all"),
|
|
4079
|
+
comma: p.child("comma", undefined, "all"),
|
|
4080
|
+
max: p.child("max", undefined, "all"),
|
|
4081
|
+
rbrace: p.child("rbrace", undefined, "all"),
|
|
4082
|
+
};
|
|
4083
|
+
return [
|
|
4084
|
+
docs.leading_comments,
|
|
4085
|
+
docs.self,
|
|
4086
|
+
docs.trailing_comments,
|
|
4087
|
+
docs.min,
|
|
4088
|
+
docs.comma,
|
|
4089
|
+
docs.max,
|
|
4090
|
+
docs.rbrace,
|
|
4091
|
+
];
|
|
4092
|
+
};
|
|
3789
4093
|
const printPipeStatement = (path, options, print, node) => {
|
|
3790
4094
|
const p = new Printer(path, options, print, node);
|
|
3791
4095
|
p.setNotRoot("left");
|
|
@@ -4026,6 +4330,32 @@ const printRepeatStatement = (path, options, print, node) => {
|
|
|
4026
4330
|
p.newLine(),
|
|
4027
4331
|
];
|
|
4028
4332
|
};
|
|
4333
|
+
const printSelectPipeOperator = (path, options, print, node) => {
|
|
4334
|
+
const p = new Printer(path, options, print, node);
|
|
4335
|
+
p.setNotRoot("exprs");
|
|
4336
|
+
p.setGroupRecommended("exprs");
|
|
4337
|
+
if (node.children.exprs) {
|
|
4338
|
+
node.children.exprs.NodeVec[p.len("exprs") - 1].isFinalColumn = true;
|
|
4339
|
+
}
|
|
4340
|
+
const docs = {
|
|
4341
|
+
leading_comments: printLeadingComments(path, options, print, node),
|
|
4342
|
+
self: p.self(),
|
|
4343
|
+
trailing_comments: printTrailingComments(path, options, print, node),
|
|
4344
|
+
keywords: p.child("keywords", undefined, "all"),
|
|
4345
|
+
exprs: p.child("exprs", (x) => group([line, x])),
|
|
4346
|
+
window: p.child("window"),
|
|
4347
|
+
};
|
|
4348
|
+
return [
|
|
4349
|
+
docs.leading_comments,
|
|
4350
|
+
docs.self,
|
|
4351
|
+
docs.trailing_comments,
|
|
4352
|
+
p.has("keywords") ? " " : "",
|
|
4353
|
+
docs.keywords,
|
|
4354
|
+
indent(docs.exprs),
|
|
4355
|
+
p.has("window") ? line : "",
|
|
4356
|
+
docs.window,
|
|
4357
|
+
];
|
|
4358
|
+
};
|
|
4029
4359
|
const printSelectStatement = (path, options, print, node) => {
|
|
4030
4360
|
const p = new Printer(path, options, print, node);
|
|
4031
4361
|
p.setNotRoot("exprs");
|
|
@@ -4879,6 +5209,9 @@ const printWithPartitionColumnsClause = (path, options, print, node) => {
|
|
|
4879
5209
|
]),
|
|
4880
5210
|
];
|
|
4881
5211
|
};
|
|
5212
|
+
const printWithPipeOperator = (path, options, print, node) => {
|
|
5213
|
+
return printWithClause(path, options, print, node);
|
|
5214
|
+
};
|
|
4882
5215
|
const printWithQuery = (path, options, print, node) => {
|
|
4883
5216
|
const p = new Printer(path, options, print, node);
|
|
4884
5217
|
p.setNotRoot("stmt");
|
|
@@ -4935,7 +5268,7 @@ const printAlias = (path, options, print, node) => {
|
|
|
4935
5268
|
else {
|
|
4936
5269
|
as_ = options.printKeywordsInUpperCase ? "AS" : "as";
|
|
4937
5270
|
}
|
|
4938
|
-
return [" ", as_, " ", p.child("alias", undefined, "all")];
|
|
5271
|
+
return [" ", as_, " ", group(p.child("alias", undefined, "all"))];
|
|
4939
5272
|
};
|
|
4940
5273
|
const printComma = (path, options, print, node) => {
|
|
4941
5274
|
const p = new Printer(path, options, print, node);
|