@elastic/esql 1.0.1 → 1.1.0
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/README.md +0 -2
- package/lib/ast/visitor/contexts.d.ts +5 -1
- package/lib/ast/visitor/contexts.d.ts.map +1 -1
- package/lib/ast/visitor/global_visitor_context.d.ts +3 -1
- package/lib/ast/visitor/global_visitor_context.d.ts.map +1 -1
- package/lib/ast/visitor/types.d.ts +5 -3
- package/lib/ast/visitor/types.d.ts.map +1 -1
- package/lib/embedded_languages/promql/index.d.ts +2 -0
- package/lib/embedded_languages/promql/index.d.ts.map +1 -1
- package/lib/embedded_languages/promql/parser/cst_to_ast_converter.d.ts.map +1 -1
- package/lib/index.js +420 -12
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +416 -12
- package/lib/index.mjs.map +1 -1
- package/lib/parser/core/cst_to_ast_converter.d.ts +3 -0
- package/lib/parser/core/cst_to_ast_converter.d.ts.map +1 -1
- package/lib/pretty_print/basic_pretty_printer.d.ts.map +1 -1
- package/lib/pretty_print/wrapping_pretty_printer.d.ts.map +1 -1
- package/lib/types.d.ts +9 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -75,12 +75,14 @@ __export(index_exports, {
|
|
|
75
75
|
ParameterHole: () => ParameterHole,
|
|
76
76
|
ParensExpressionVisitorContext: () => ParensExpressionVisitorContext,
|
|
77
77
|
Parser: () => Parser4,
|
|
78
|
+
PromQLBasicPrettyPrinter: () => PromQLBasicPrettyPrinter,
|
|
78
79
|
PromQLBuilder: () => PromQLBuilder,
|
|
79
80
|
PromQLCstToAstConverter: () => PromQLCstToAstConverter,
|
|
80
81
|
PromQLErrorListener: () => PromQLErrorListener,
|
|
81
82
|
PromQLParser: () => PromQLParser,
|
|
82
83
|
PromqlWalker: () => PromqlWalker,
|
|
83
84
|
QueryVisitorContext: () => QueryVisitorContext,
|
|
85
|
+
RegisteredDomainCommandVisitorContext: () => RegisteredDomainCommandVisitorContext,
|
|
84
86
|
RenameCommandVisitorContext: () => RenameCommandVisitorContext,
|
|
85
87
|
RerankCommandVisitorContext: () => RerankCommandVisitorContext,
|
|
86
88
|
RowCommandVisitorContext: () => RowCommandVisitorContext,
|
|
@@ -94,6 +96,7 @@ __export(index_exports, {
|
|
|
94
96
|
TIME_SPAN_UNITS: () => TIME_SPAN_UNITS,
|
|
95
97
|
TimeseriesCommandVisitorContext: () => TimeseriesCommandVisitorContext,
|
|
96
98
|
UnaryExpressionGroup: () => UnaryExpressionGroup,
|
|
99
|
+
UriPartsCommandVisitorContext: () => UriPartsCommandVisitorContext,
|
|
97
100
|
Visitor: () => Visitor,
|
|
98
101
|
VisitorContext: () => VisitorContext,
|
|
99
102
|
Walker: () => Walker,
|
|
@@ -128,6 +131,7 @@ __export(index_exports, {
|
|
|
128
131
|
isParamLiteral: () => isParamLiteral,
|
|
129
132
|
isParametrized: () => isParametrized,
|
|
130
133
|
isParens: () => isParens,
|
|
134
|
+
isPromqlNode: () => isPromqlNode,
|
|
131
135
|
isProperNode: () => isProperNode,
|
|
132
136
|
isQuery: () => isQuery,
|
|
133
137
|
isSource: () => isSource,
|
|
@@ -24396,6 +24400,301 @@ var LeafPrinter = {
|
|
|
24396
24400
|
}
|
|
24397
24401
|
};
|
|
24398
24402
|
|
|
24403
|
+
// src/embedded_languages/promql/pretty_print/helpers.ts
|
|
24404
|
+
var promqlBinaryPrecedenceGroup = (node) => {
|
|
24405
|
+
if (node.type !== "binary-expression") {
|
|
24406
|
+
return 0 /* none */;
|
|
24407
|
+
}
|
|
24408
|
+
switch (node.name) {
|
|
24409
|
+
case "^":
|
|
24410
|
+
return 6 /* power */;
|
|
24411
|
+
case "*":
|
|
24412
|
+
case "/":
|
|
24413
|
+
case "%":
|
|
24414
|
+
return 5 /* multiplicative */;
|
|
24415
|
+
case "+":
|
|
24416
|
+
case "-":
|
|
24417
|
+
return 4 /* additive */;
|
|
24418
|
+
case "==":
|
|
24419
|
+
case "!=":
|
|
24420
|
+
case "<":
|
|
24421
|
+
case "<=":
|
|
24422
|
+
case ">":
|
|
24423
|
+
case ">=":
|
|
24424
|
+
return 3 /* comparison */;
|
|
24425
|
+
case "and":
|
|
24426
|
+
case "unless":
|
|
24427
|
+
return 2 /* andUnless */;
|
|
24428
|
+
case "or":
|
|
24429
|
+
return 1 /* or */;
|
|
24430
|
+
default:
|
|
24431
|
+
return 0 /* none */;
|
|
24432
|
+
}
|
|
24433
|
+
};
|
|
24434
|
+
var isPromQLRightAssociative = (op) => op === "^";
|
|
24435
|
+
|
|
24436
|
+
// src/embedded_languages/promql/pretty_print/basic_pretty_printer.ts
|
|
24437
|
+
var PromQLBasicPrettyPrinter = class _PromQLBasicPrettyPrinter {
|
|
24438
|
+
/**
|
|
24439
|
+
* Print any PromQL AST node.
|
|
24440
|
+
*/
|
|
24441
|
+
static print = (node, opts) => {
|
|
24442
|
+
const printer = new _PromQLBasicPrettyPrinter(opts);
|
|
24443
|
+
return printer.print(node);
|
|
24444
|
+
};
|
|
24445
|
+
/**
|
|
24446
|
+
* Print a PromQL query expression.
|
|
24447
|
+
*/
|
|
24448
|
+
static query = (query2, opts) => {
|
|
24449
|
+
const printer = new _PromQLBasicPrettyPrinter(opts);
|
|
24450
|
+
return printer.printQuery(query2);
|
|
24451
|
+
};
|
|
24452
|
+
/**
|
|
24453
|
+
* Print a PromQL expression.
|
|
24454
|
+
*/
|
|
24455
|
+
static expression = (expr, opts) => {
|
|
24456
|
+
const printer = new _PromQLBasicPrettyPrinter(opts);
|
|
24457
|
+
return printer.printExpression(expr);
|
|
24458
|
+
};
|
|
24459
|
+
opts;
|
|
24460
|
+
constructor(opts = {}) {
|
|
24461
|
+
this.opts = {
|
|
24462
|
+
lowercaseFunctions: opts.lowercaseFunctions ?? false,
|
|
24463
|
+
lowercaseKeywords: opts.lowercaseKeywords ?? false,
|
|
24464
|
+
lowercaseOperators: opts.lowercaseOperators ?? false
|
|
24465
|
+
};
|
|
24466
|
+
}
|
|
24467
|
+
print(node) {
|
|
24468
|
+
if (node.type === "query") {
|
|
24469
|
+
return this.printQuery(node);
|
|
24470
|
+
}
|
|
24471
|
+
return this.printExpression(node);
|
|
24472
|
+
}
|
|
24473
|
+
printQuery(query2) {
|
|
24474
|
+
if (!query2.expression) {
|
|
24475
|
+
return "";
|
|
24476
|
+
}
|
|
24477
|
+
return this.printExpression(query2.expression);
|
|
24478
|
+
}
|
|
24479
|
+
printExpression(expr) {
|
|
24480
|
+
if (!expr) {
|
|
24481
|
+
return "";
|
|
24482
|
+
}
|
|
24483
|
+
switch (expr.type) {
|
|
24484
|
+
case "function":
|
|
24485
|
+
return this.printFunction(expr);
|
|
24486
|
+
case "selector":
|
|
24487
|
+
return this.printSelector(expr);
|
|
24488
|
+
case "binary-expression":
|
|
24489
|
+
return this.printBinaryExpression(expr);
|
|
24490
|
+
case "unary-expression":
|
|
24491
|
+
return this.printUnaryExpression(expr);
|
|
24492
|
+
case "subquery":
|
|
24493
|
+
return this.printSubquery(expr);
|
|
24494
|
+
case "parens":
|
|
24495
|
+
return this.printParens(expr);
|
|
24496
|
+
case "literal":
|
|
24497
|
+
return this.printLiteral(expr);
|
|
24498
|
+
case "identifier":
|
|
24499
|
+
return this.printIdentifier(expr);
|
|
24500
|
+
case "unknown":
|
|
24501
|
+
return "<unknown>";
|
|
24502
|
+
default:
|
|
24503
|
+
return "";
|
|
24504
|
+
}
|
|
24505
|
+
}
|
|
24506
|
+
printFunction(node) {
|
|
24507
|
+
const name = this.opts.lowercaseFunctions ? node.name.toLowerCase() : node.name;
|
|
24508
|
+
const args = node.args.map((arg) => this.printExpression(arg)).join(", ");
|
|
24509
|
+
const grouping = node.grouping ? this.printGrouping(node.grouping) : "";
|
|
24510
|
+
if (grouping && node.groupingPosition === "before") {
|
|
24511
|
+
return `${name} ${grouping} (${args})`;
|
|
24512
|
+
} else if (grouping) {
|
|
24513
|
+
return `${name}(${args}) ${grouping}`;
|
|
24514
|
+
} else {
|
|
24515
|
+
return `${name}(${args})`;
|
|
24516
|
+
}
|
|
24517
|
+
}
|
|
24518
|
+
printGrouping(node) {
|
|
24519
|
+
const keyword = this.opts.lowercaseKeywords ? node.name.toLowerCase() : node.name;
|
|
24520
|
+
const labels = node.args.map((l) => this.printLabelName(l)).join(", ");
|
|
24521
|
+
return `${keyword} (${labels})`;
|
|
24522
|
+
}
|
|
24523
|
+
printSelector(node) {
|
|
24524
|
+
let result = "";
|
|
24525
|
+
if (node.metric) {
|
|
24526
|
+
result += this.printIdentifier(node.metric);
|
|
24527
|
+
}
|
|
24528
|
+
if (node.labelMap) {
|
|
24529
|
+
result += this.printLabelMap(node.labelMap);
|
|
24530
|
+
}
|
|
24531
|
+
if (node.duration) {
|
|
24532
|
+
result += `[${this.printExpression(node.duration)}]`;
|
|
24533
|
+
}
|
|
24534
|
+
if (node.evaluation) {
|
|
24535
|
+
result += this.printEvaluation(node.evaluation);
|
|
24536
|
+
}
|
|
24537
|
+
return result;
|
|
24538
|
+
}
|
|
24539
|
+
printLabelMap(node) {
|
|
24540
|
+
const labels = node.args.map((l) => this.printLabel(l)).join(", ");
|
|
24541
|
+
return `{${labels}}`;
|
|
24542
|
+
}
|
|
24543
|
+
printLabel(node) {
|
|
24544
|
+
const labelName = this.printLabelName(node.labelName);
|
|
24545
|
+
const value = node.value ? this.printLiteral(node.value) : "";
|
|
24546
|
+
return `${labelName}${node.operator}${value}`;
|
|
24547
|
+
}
|
|
24548
|
+
printLabelName(node) {
|
|
24549
|
+
switch (node.type) {
|
|
24550
|
+
case "identifier":
|
|
24551
|
+
return this.printIdentifier(node);
|
|
24552
|
+
case "literal":
|
|
24553
|
+
return this.printLiteral(node);
|
|
24554
|
+
default:
|
|
24555
|
+
return "";
|
|
24556
|
+
}
|
|
24557
|
+
}
|
|
24558
|
+
printEvaluation(node) {
|
|
24559
|
+
let result = "";
|
|
24560
|
+
if (node.offset) {
|
|
24561
|
+
result += ` ${this.printOffset(node.offset)}`;
|
|
24562
|
+
}
|
|
24563
|
+
if (node.at) {
|
|
24564
|
+
result += ` ${this.printAt(node.at)}`;
|
|
24565
|
+
}
|
|
24566
|
+
return result;
|
|
24567
|
+
}
|
|
24568
|
+
printOffset(node) {
|
|
24569
|
+
const keyword = "offset";
|
|
24570
|
+
const sign = node.negative ? "- " : "";
|
|
24571
|
+
const duration = this.printExpression(node.duration);
|
|
24572
|
+
return `${keyword} ${sign}${duration}`;
|
|
24573
|
+
}
|
|
24574
|
+
printAt(node) {
|
|
24575
|
+
const sign = node.negative ? "- " : "";
|
|
24576
|
+
if (typeof node.value === "string") {
|
|
24577
|
+
return `@ ${sign}${node.value}`;
|
|
24578
|
+
}
|
|
24579
|
+
return `@ ${sign}${this.printLiteral(node.value)}`;
|
|
24580
|
+
}
|
|
24581
|
+
printBinaryExpression(node) {
|
|
24582
|
+
const group = promqlBinaryPrecedenceGroup(node);
|
|
24583
|
+
const leftGroup = promqlBinaryPrecedenceGroup(node.left);
|
|
24584
|
+
const rightGroup = promqlBinaryPrecedenceGroup(node.right);
|
|
24585
|
+
const operator = this.formatOperator(node.name);
|
|
24586
|
+
const isRightAssociative = isPromQLRightAssociative(node.name);
|
|
24587
|
+
let left = this.printExpression(node.left);
|
|
24588
|
+
let right = this.printExpression(node.right);
|
|
24589
|
+
if (leftGroup !== 0 /* none */ && (leftGroup < group || leftGroup === group && isRightAssociative)) {
|
|
24590
|
+
left = `(${left})`;
|
|
24591
|
+
}
|
|
24592
|
+
if (rightGroup !== 0 /* none */ && (rightGroup < group || rightGroup === group && !isRightAssociative)) {
|
|
24593
|
+
right = `(${right})`;
|
|
24594
|
+
}
|
|
24595
|
+
let modifiers = "";
|
|
24596
|
+
if (node.bool) {
|
|
24597
|
+
const boolKeyword = "bool";
|
|
24598
|
+
modifiers += ` ${boolKeyword}`;
|
|
24599
|
+
}
|
|
24600
|
+
if (node.modifier) {
|
|
24601
|
+
modifiers += ` ${this.printModifier(node.modifier)}`;
|
|
24602
|
+
}
|
|
24603
|
+
return `${left} ${operator}${modifiers} ${right}`;
|
|
24604
|
+
}
|
|
24605
|
+
printModifier(node) {
|
|
24606
|
+
const keyword = this.opts.lowercaseKeywords ? node.name.toLowerCase() : node.name;
|
|
24607
|
+
const labels = node.labels.map((l) => this.printLabelName(l)).join(", ");
|
|
24608
|
+
let result = `${keyword}(${labels})`;
|
|
24609
|
+
if (node.groupModifier) {
|
|
24610
|
+
result += ` ${this.printGroupModifier(node.groupModifier)}`;
|
|
24611
|
+
}
|
|
24612
|
+
return result;
|
|
24613
|
+
}
|
|
24614
|
+
printGroupModifier(node) {
|
|
24615
|
+
const keyword = this.opts.lowercaseKeywords ? node.name.toLowerCase() : node.name;
|
|
24616
|
+
const labels = node.labels.map((l) => this.printLabelName(l)).join(", ");
|
|
24617
|
+
if (labels) {
|
|
24618
|
+
return `${keyword}(${labels})`;
|
|
24619
|
+
}
|
|
24620
|
+
return keyword;
|
|
24621
|
+
}
|
|
24622
|
+
formatOperator(op) {
|
|
24623
|
+
if (op === "and" || op === "or" || op === "unless") {
|
|
24624
|
+
return this.opts.lowercaseOperators ? op.toLowerCase() : op;
|
|
24625
|
+
}
|
|
24626
|
+
return op;
|
|
24627
|
+
}
|
|
24628
|
+
printUnaryExpression(node) {
|
|
24629
|
+
const arg = this.printExpression(node.arg);
|
|
24630
|
+
return `${node.name}${arg}`;
|
|
24631
|
+
}
|
|
24632
|
+
printSubquery(node) {
|
|
24633
|
+
const expr = this.printExpression(node.expr);
|
|
24634
|
+
const range = this.printExpression(node.range);
|
|
24635
|
+
const resolution = node.resolution ? this.printExpression(node.resolution) : "";
|
|
24636
|
+
let result = `${expr}[${range}:${resolution}]`;
|
|
24637
|
+
if (node.evaluation) {
|
|
24638
|
+
result += this.printEvaluation(node.evaluation);
|
|
24639
|
+
}
|
|
24640
|
+
return result;
|
|
24641
|
+
}
|
|
24642
|
+
printParens(node) {
|
|
24643
|
+
const child = this.printExpression(node.child);
|
|
24644
|
+
return `(${child})`;
|
|
24645
|
+
}
|
|
24646
|
+
printLiteral(node) {
|
|
24647
|
+
switch (node.literalType) {
|
|
24648
|
+
case "integer":
|
|
24649
|
+
return this.printIntegerLiteral(node);
|
|
24650
|
+
case "decimal":
|
|
24651
|
+
return this.printDecimalLiteral(node);
|
|
24652
|
+
case "hexadecimal":
|
|
24653
|
+
return this.printHexLiteral(node);
|
|
24654
|
+
case "string":
|
|
24655
|
+
return this.printStringLiteral(node);
|
|
24656
|
+
case "time":
|
|
24657
|
+
return this.printTimeLiteral(node);
|
|
24658
|
+
default:
|
|
24659
|
+
return String(node.value);
|
|
24660
|
+
}
|
|
24661
|
+
}
|
|
24662
|
+
printIntegerLiteral(node) {
|
|
24663
|
+
return String(node.value);
|
|
24664
|
+
}
|
|
24665
|
+
printDecimalLiteral(node) {
|
|
24666
|
+
const value = node.value;
|
|
24667
|
+
if (Number.isNaN(value)) {
|
|
24668
|
+
return "NaN";
|
|
24669
|
+
}
|
|
24670
|
+
if (!Number.isFinite(value)) {
|
|
24671
|
+
return value > 0 ? "Inf" : "-Inf";
|
|
24672
|
+
}
|
|
24673
|
+
const str2 = String(value);
|
|
24674
|
+
if (!str2.includes(".") && !str2.includes("e") && !str2.includes("E")) {
|
|
24675
|
+
return str2 + ".0";
|
|
24676
|
+
}
|
|
24677
|
+
return str2;
|
|
24678
|
+
}
|
|
24679
|
+
printHexLiteral(node) {
|
|
24680
|
+
return "0x" + node.value.toString(16);
|
|
24681
|
+
}
|
|
24682
|
+
printStringLiteral(node) {
|
|
24683
|
+
const { value, valueUnquoted } = node;
|
|
24684
|
+
if (value !== valueUnquoted) {
|
|
24685
|
+
return value;
|
|
24686
|
+
}
|
|
24687
|
+
const escaped = valueUnquoted.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
|
|
24688
|
+
return `"${escaped}"`;
|
|
24689
|
+
}
|
|
24690
|
+
printTimeLiteral(node) {
|
|
24691
|
+
return node.value;
|
|
24692
|
+
}
|
|
24693
|
+
printIdentifier(node) {
|
|
24694
|
+
return node.name;
|
|
24695
|
+
}
|
|
24696
|
+
};
|
|
24697
|
+
|
|
24399
24698
|
// src/ast/grouping.ts
|
|
24400
24699
|
var BinaryExpressionGroup = /* @__PURE__ */ ((BinaryExpressionGroup2) => {
|
|
24401
24700
|
BinaryExpressionGroup2[BinaryExpressionGroup2["none"] = 0] = "none";
|
|
@@ -24742,12 +25041,16 @@ var ForkCommandVisitorContext = class extends CommandVisitorContext {
|
|
|
24742
25041
|
};
|
|
24743
25042
|
var CompletionCommandVisitorContext = class extends CommandVisitorContext {
|
|
24744
25043
|
};
|
|
25044
|
+
var RegisteredDomainCommandVisitorContext = class extends CommandVisitorContext {
|
|
25045
|
+
};
|
|
24745
25046
|
var SampleCommandVisitorContext = class extends CommandVisitorContext {
|
|
24746
25047
|
};
|
|
24747
25048
|
var FuseCommandVisitorContext = class extends CommandVisitorContext {
|
|
24748
25049
|
};
|
|
24749
25050
|
var MmrCommandVisitorContext = class extends CommandVisitorContext {
|
|
24750
25051
|
};
|
|
25052
|
+
var UriPartsCommandVisitorContext = class extends CommandVisitorContext {
|
|
25053
|
+
};
|
|
24751
25054
|
var ExpressionVisitorContext = class extends VisitorContext {
|
|
24752
25055
|
};
|
|
24753
25056
|
var ColumnExpressionVisitorContext = class extends VisitorContext {
|
|
@@ -24975,6 +25278,14 @@ var GlobalVisitorContext = class {
|
|
|
24975
25278
|
input
|
|
24976
25279
|
);
|
|
24977
25280
|
}
|
|
25281
|
+
case "registered_domain": {
|
|
25282
|
+
if (!this.methods.visitRegisteredDomainCommand) break;
|
|
25283
|
+
return this.visitRegisteredDomainCommand(
|
|
25284
|
+
parent,
|
|
25285
|
+
commandNode,
|
|
25286
|
+
input
|
|
25287
|
+
);
|
|
25288
|
+
}
|
|
24978
25289
|
case "sample": {
|
|
24979
25290
|
if (!this.methods.visitSampleCommand) break;
|
|
24980
25291
|
return this.visitSampleCommand(parent, commandNode, input);
|
|
@@ -24987,6 +25298,14 @@ var GlobalVisitorContext = class {
|
|
|
24987
25298
|
if (!this.methods.visitMmrCommand) break;
|
|
24988
25299
|
return this.visitMmrCommand(parent, commandNode, input);
|
|
24989
25300
|
}
|
|
25301
|
+
case "uri_parts": {
|
|
25302
|
+
if (!this.methods.visitUriPartsCommand) break;
|
|
25303
|
+
return this.visitUriPartsCommand(
|
|
25304
|
+
parent,
|
|
25305
|
+
commandNode,
|
|
25306
|
+
input
|
|
25307
|
+
);
|
|
25308
|
+
}
|
|
24990
25309
|
}
|
|
24991
25310
|
return this.visitCommandGeneric(parent, commandNode, input);
|
|
24992
25311
|
}
|
|
@@ -25097,6 +25416,10 @@ var GlobalVisitorContext = class {
|
|
|
25097
25416
|
const context = new CompletionCommandVisitorContext(this, node, parent);
|
|
25098
25417
|
return this.visitWithSpecificContext("visitCompletionCommand", context, input);
|
|
25099
25418
|
}
|
|
25419
|
+
visitRegisteredDomainCommand(parent, node, input) {
|
|
25420
|
+
const context = new RegisteredDomainCommandVisitorContext(this, node, parent);
|
|
25421
|
+
return this.visitWithSpecificContext("visitRegisteredDomainCommand", context, input);
|
|
25422
|
+
}
|
|
25100
25423
|
visitSampleCommand(parent, node, input) {
|
|
25101
25424
|
const context = new ForkCommandVisitorContext(this, node, parent);
|
|
25102
25425
|
return this.visitWithSpecificContext("visitSampleCommand", context, input);
|
|
@@ -25109,6 +25432,10 @@ var GlobalVisitorContext = class {
|
|
|
25109
25432
|
const context = new MmrCommandVisitorContext(this, node, parent);
|
|
25110
25433
|
return this.visitWithSpecificContext("visitMmrCommand", context, input);
|
|
25111
25434
|
}
|
|
25435
|
+
visitUriPartsCommand(parent, node, input) {
|
|
25436
|
+
const context = new UriPartsCommandVisitorContext(this, node, parent);
|
|
25437
|
+
return this.visitWithSpecificContext("visitUriPartsCommand", context, input);
|
|
25438
|
+
}
|
|
25112
25439
|
// #endregion
|
|
25113
25440
|
// #region Expression visiting -------------------------------------------------------
|
|
25114
25441
|
visitExpressionGeneric(parent, node, input) {
|
|
@@ -25630,9 +25957,12 @@ var BasicPrettyPrinter = class _BasicPrettyPrinter {
|
|
|
25630
25957
|
if (ctx.node.type === "unknown") {
|
|
25631
25958
|
return this.decorateWithComments(ctx.node, ctx.node.text || "<UNKNOWN>");
|
|
25632
25959
|
}
|
|
25960
|
+
if (isPromqlNode(ctx.node)) {
|
|
25961
|
+
const text = PromQLBasicPrettyPrinter.print(ctx.node);
|
|
25962
|
+
return this.decorateWithComments(ctx.node, text || "<UNKNOWN>");
|
|
25963
|
+
}
|
|
25633
25964
|
if (ctx.node.text) {
|
|
25634
|
-
|
|
25635
|
-
text = text.replace(/<EOF>/g, "").trim();
|
|
25965
|
+
const text = ctx.node.text.replace(/<EOF>/g, "").trim();
|
|
25636
25966
|
return this.decorateWithComments(ctx.node, text || "<UNKNOWN>");
|
|
25637
25967
|
}
|
|
25638
25968
|
return "<EXPRESSION>";
|
|
@@ -26213,6 +26543,9 @@ var WrappingPrettyPrinter = class _WrappingPrettyPrinter {
|
|
|
26213
26543
|
return { txt, indented };
|
|
26214
26544
|
}
|
|
26215
26545
|
visitor = new Visitor().on("visitExpression", (ctx, inp) => {
|
|
26546
|
+
if (isPromqlNode(ctx.node)) {
|
|
26547
|
+
return { txt: PromQLBasicPrettyPrinter.print(ctx.node) };
|
|
26548
|
+
}
|
|
26216
26549
|
let text = ctx.node.text ?? "<EXPRESSION>";
|
|
26217
26550
|
if (text) {
|
|
26218
26551
|
text = text.replace(/<EOF>/g, "").trim();
|
|
@@ -57634,11 +57967,11 @@ var PromQLCstToAstConverter = class {
|
|
|
57634
57967
|
const joiningKind = joiningToken.text?.toLowerCase() === "group_left" ? "group_left" : "group_right";
|
|
57635
57968
|
const groupLabelsCtx = ctx._groupLabels;
|
|
57636
57969
|
const groupLabels = groupLabelsCtx ? this.fromLabelList(groupLabelsCtx) : [];
|
|
57637
|
-
groupModifier = PromQLBuilder.groupModifier(
|
|
57638
|
-
|
|
57639
|
-
|
|
57640
|
-
|
|
57641
|
-
|
|
57970
|
+
groupModifier = PromQLBuilder.groupModifier(
|
|
57971
|
+
joiningKind,
|
|
57972
|
+
groupLabels,
|
|
57973
|
+
this.createParserFieldsFromToken(joiningToken, joiningToken.text ?? "")
|
|
57974
|
+
);
|
|
57642
57975
|
for (const label of groupLabels) {
|
|
57643
57976
|
if (label.incomplete) {
|
|
57644
57977
|
groupModifier.incomplete = true;
|
|
@@ -57698,6 +58031,22 @@ var PromQLCstToAstConverter = class {
|
|
|
57698
58031
|
timeValue,
|
|
57699
58032
|
this.createParserFieldsFromToken(timeValueWithColon.symbol, timeValue)
|
|
57700
58033
|
);
|
|
58034
|
+
const opToken = resolutionCtx._op;
|
|
58035
|
+
const rightCtx = resolutionCtx.expression();
|
|
58036
|
+
if (opToken && rightCtx) {
|
|
58037
|
+
const operator = this.toBinaryOperator(opToken.text ?? "");
|
|
58038
|
+
const right = this.fromExpression(rightCtx) ?? PromQLBuilder.unknown(this.getParserFields(rightCtx));
|
|
58039
|
+
resolution = PromQLBuilder.expression.binary(
|
|
58040
|
+
operator,
|
|
58041
|
+
resolution,
|
|
58042
|
+
right,
|
|
58043
|
+
{},
|
|
58044
|
+
this.getParserFields(resolutionCtx)
|
|
58045
|
+
);
|
|
58046
|
+
if (right.incomplete) {
|
|
58047
|
+
resolution.incomplete = true;
|
|
58048
|
+
}
|
|
58049
|
+
}
|
|
57701
58050
|
}
|
|
57702
58051
|
}
|
|
57703
58052
|
}
|
|
@@ -58308,6 +58657,10 @@ var CstToAstConverter = class {
|
|
|
58308
58657
|
if (completionCommandCtx) {
|
|
58309
58658
|
return this.fromCompletionCommand(completionCommandCtx);
|
|
58310
58659
|
}
|
|
58660
|
+
const registeredDomainCommandCtx = ctx.registeredDomainCommand();
|
|
58661
|
+
if (registeredDomainCommandCtx) {
|
|
58662
|
+
return this.fromRegisteredDomainCommand(registeredDomainCommandCtx);
|
|
58663
|
+
}
|
|
58311
58664
|
const sampleCommandCtx = ctx.sampleCommand();
|
|
58312
58665
|
if (sampleCommandCtx) {
|
|
58313
58666
|
return this.fromSampleCommand(sampleCommandCtx);
|
|
@@ -58332,6 +58685,10 @@ var CstToAstConverter = class {
|
|
|
58332
58685
|
if (mmrCommand) {
|
|
58333
58686
|
return this.fromMmrCommand(mmrCommand);
|
|
58334
58687
|
}
|
|
58688
|
+
const uriPartsCommandCtx = ctx.uriPartsCommand();
|
|
58689
|
+
if (uriPartsCommandCtx) {
|
|
58690
|
+
return this.fromUriPartsCommand(uriPartsCommandCtx);
|
|
58691
|
+
}
|
|
58335
58692
|
}
|
|
58336
58693
|
createCommand(name, ctx, partial) {
|
|
58337
58694
|
const parserFields = this.getParserFields(ctx);
|
|
@@ -58990,6 +59347,10 @@ var CstToAstConverter = class {
|
|
|
58990
59347
|
command2.inferenceId = inferenceId;
|
|
58991
59348
|
return command2;
|
|
58992
59349
|
}
|
|
59350
|
+
// -------------------------------------------------------- REGISTERED_DOMAIN
|
|
59351
|
+
fromRegisteredDomainCommand(ctx) {
|
|
59352
|
+
return this.fromQualifiedNameAssignmentCommand("registered_domain", ctx);
|
|
59353
|
+
}
|
|
58993
59354
|
// ------------------------------------------------------------------- SAMPLE
|
|
58994
59355
|
fromSampleCommand(ctx) {
|
|
58995
59356
|
const command2 = this.createCommand("sample", ctx);
|
|
@@ -59506,11 +59867,11 @@ var CstToAstConverter = class {
|
|
|
59506
59867
|
const queryVector = this.fromMmrQueryVectorParam(ctx.mmrQueryVectorParams());
|
|
59507
59868
|
if (queryVector) args.push(queryVector);
|
|
59508
59869
|
const onOption = this.fromMmrOnOption(ctx);
|
|
59509
|
-
args.push(onOption);
|
|
59510
|
-
const diversifyField = onOption
|
|
59870
|
+
if (onOption) args.push(onOption);
|
|
59871
|
+
const diversifyField = onOption?.args[0] ? onOption.args[0].args[0] : void 0;
|
|
59511
59872
|
const limitOption = this.fromMmrLimitOption(ctx);
|
|
59512
|
-
args.push(limitOption);
|
|
59513
|
-
const limit = limitOption.args[0];
|
|
59873
|
+
if (limitOption) args.push(limitOption);
|
|
59874
|
+
const limit = limitOption ? limitOption.args[0] : void 0;
|
|
59514
59875
|
const withOption = this.fromMmrWithOption(ctx.commandNamedParameters());
|
|
59515
59876
|
if (withOption) args.push(withOption);
|
|
59516
59877
|
const namedParameters = withOption ? withOption.args[0] : void 0;
|
|
@@ -59521,7 +59882,9 @@ var CstToAstConverter = class {
|
|
|
59521
59882
|
limit,
|
|
59522
59883
|
namedParameters
|
|
59523
59884
|
});
|
|
59524
|
-
command2.incomplete ||=
|
|
59885
|
+
command2.incomplete ||= queryVector?.incomplete ?? false;
|
|
59886
|
+
command2.incomplete ||= diversifyField?.incomplete ?? false;
|
|
59887
|
+
command2.incomplete ||= limitOption?.incomplete ?? false;
|
|
59525
59888
|
command2.incomplete ||= withOption?.incomplete ?? false;
|
|
59526
59889
|
return command2;
|
|
59527
59890
|
}
|
|
@@ -59540,6 +59903,7 @@ var CstToAstConverter = class {
|
|
|
59540
59903
|
}
|
|
59541
59904
|
fromMmrOnOption(ctx) {
|
|
59542
59905
|
const onToken = ctx.ON();
|
|
59906
|
+
if (!onToken) return;
|
|
59543
59907
|
const diversifyFieldCtx = ctx.qualifiedName();
|
|
59544
59908
|
const diversifyField = this.toColumn(diversifyFieldCtx);
|
|
59545
59909
|
const onOption = this.toOption(onToken.getText().toLowerCase(), diversifyFieldCtx);
|
|
@@ -59550,7 +59914,14 @@ var CstToAstConverter = class {
|
|
|
59550
59914
|
}
|
|
59551
59915
|
fromMmrLimitOption(ctx) {
|
|
59552
59916
|
const limitToken = ctx.MMR_LIMIT();
|
|
59917
|
+
if (!limitToken) return;
|
|
59553
59918
|
const limitValueCtx = ctx.integerValue();
|
|
59919
|
+
if (!limitValueCtx) {
|
|
59920
|
+
const limitOption2 = this.toOption(limitToken.getText().toLowerCase(), ctx, [], true);
|
|
59921
|
+
limitOption2.location.min = limitToken.symbol.start;
|
|
59922
|
+
limitOption2.location.max = limitToken.symbol.stop;
|
|
59923
|
+
return limitOption2;
|
|
59924
|
+
}
|
|
59554
59925
|
const limitOption = this.toOption(limitToken.getText().toLowerCase(), limitValueCtx);
|
|
59555
59926
|
limitOption.args.push(this.fromConstantToArray(limitValueCtx));
|
|
59556
59927
|
limitOption.location.min = limitToken.symbol.start;
|
|
@@ -59558,6 +59929,7 @@ var CstToAstConverter = class {
|
|
|
59558
59929
|
return limitOption;
|
|
59559
59930
|
}
|
|
59560
59931
|
fromMmrWithOption(namedParametersCtx) {
|
|
59932
|
+
if (!namedParametersCtx) return;
|
|
59561
59933
|
const withOption = this.fromCommandNamedParameters(namedParametersCtx);
|
|
59562
59934
|
const mapArg = withOption.args[0];
|
|
59563
59935
|
if (mapArg) {
|
|
@@ -59567,6 +59939,38 @@ var CstToAstConverter = class {
|
|
|
59567
59939
|
return withOption;
|
|
59568
59940
|
}
|
|
59569
59941
|
}
|
|
59942
|
+
// --------------------------------------------------------------- URI_PARTS
|
|
59943
|
+
fromUriPartsCommand(ctx) {
|
|
59944
|
+
return this.fromQualifiedNameAssignmentCommand("uri_parts", ctx);
|
|
59945
|
+
}
|
|
59946
|
+
fromQualifiedNameAssignmentCommand(name, ctx) {
|
|
59947
|
+
const command2 = this.createCommand(name, ctx);
|
|
59948
|
+
const qualifiedNameCtx = ctx.qualifiedName();
|
|
59949
|
+
if (qualifiedNameCtx && ctx.ASSIGN()) {
|
|
59950
|
+
const targetField = this.toColumn(qualifiedNameCtx);
|
|
59951
|
+
command2.targetField = targetField;
|
|
59952
|
+
const expression2 = this.fromPrimaryExpressionStrict(ctx.primaryExpression());
|
|
59953
|
+
command2.expression = expression2;
|
|
59954
|
+
if (expression2.incomplete || expression2.type === "unknown") {
|
|
59955
|
+
command2.incomplete = true;
|
|
59956
|
+
}
|
|
59957
|
+
const assignment = this.toFunction(
|
|
59958
|
+
ctx.ASSIGN().getText(),
|
|
59959
|
+
ctx,
|
|
59960
|
+
void 0,
|
|
59961
|
+
"binary-expression"
|
|
59962
|
+
);
|
|
59963
|
+
assignment.args.push(targetField, expression2);
|
|
59964
|
+
assignment.location = this.extendLocationToArgs(assignment);
|
|
59965
|
+
command2.args.push(assignment);
|
|
59966
|
+
} else if (qualifiedNameCtx) {
|
|
59967
|
+
const targetField = this.toColumn(qualifiedNameCtx);
|
|
59968
|
+
command2.targetField = targetField;
|
|
59969
|
+
command2.incomplete = true;
|
|
59970
|
+
command2.args.push(targetField);
|
|
59971
|
+
}
|
|
59972
|
+
return command2;
|
|
59973
|
+
}
|
|
59570
59974
|
// -------------------------------------------------------------- expressions
|
|
59571
59975
|
toColumnsFromCommand(ctx) {
|
|
59572
59976
|
if (ctx instanceof MetadataContext) {
|
|
@@ -63300,12 +63704,14 @@ var EsqlQuery = class _EsqlQuery {
|
|
|
63300
63704
|
ParameterHole,
|
|
63301
63705
|
ParensExpressionVisitorContext,
|
|
63302
63706
|
Parser,
|
|
63707
|
+
PromQLBasicPrettyPrinter,
|
|
63303
63708
|
PromQLBuilder,
|
|
63304
63709
|
PromQLCstToAstConverter,
|
|
63305
63710
|
PromQLErrorListener,
|
|
63306
63711
|
PromQLParser,
|
|
63307
63712
|
PromqlWalker,
|
|
63308
63713
|
QueryVisitorContext,
|
|
63714
|
+
RegisteredDomainCommandVisitorContext,
|
|
63309
63715
|
RenameCommandVisitorContext,
|
|
63310
63716
|
RerankCommandVisitorContext,
|
|
63311
63717
|
RowCommandVisitorContext,
|
|
@@ -63319,6 +63725,7 @@ var EsqlQuery = class _EsqlQuery {
|
|
|
63319
63725
|
TIME_SPAN_UNITS,
|
|
63320
63726
|
TimeseriesCommandVisitorContext,
|
|
63321
63727
|
UnaryExpressionGroup,
|
|
63728
|
+
UriPartsCommandVisitorContext,
|
|
63322
63729
|
Visitor,
|
|
63323
63730
|
VisitorContext,
|
|
63324
63731
|
Walker,
|
|
@@ -63353,6 +63760,7 @@ var EsqlQuery = class _EsqlQuery {
|
|
|
63353
63760
|
isParamLiteral,
|
|
63354
63761
|
isParametrized,
|
|
63355
63762
|
isParens,
|
|
63763
|
+
isPromqlNode,
|
|
63356
63764
|
isProperNode,
|
|
63357
63765
|
isQuery,
|
|
63358
63766
|
isSource,
|