@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.mjs
CHANGED
|
@@ -24255,6 +24255,301 @@ var LeafPrinter = {
|
|
|
24255
24255
|
}
|
|
24256
24256
|
};
|
|
24257
24257
|
|
|
24258
|
+
// src/embedded_languages/promql/pretty_print/helpers.ts
|
|
24259
|
+
var promqlBinaryPrecedenceGroup = (node) => {
|
|
24260
|
+
if (node.type !== "binary-expression") {
|
|
24261
|
+
return 0 /* none */;
|
|
24262
|
+
}
|
|
24263
|
+
switch (node.name) {
|
|
24264
|
+
case "^":
|
|
24265
|
+
return 6 /* power */;
|
|
24266
|
+
case "*":
|
|
24267
|
+
case "/":
|
|
24268
|
+
case "%":
|
|
24269
|
+
return 5 /* multiplicative */;
|
|
24270
|
+
case "+":
|
|
24271
|
+
case "-":
|
|
24272
|
+
return 4 /* additive */;
|
|
24273
|
+
case "==":
|
|
24274
|
+
case "!=":
|
|
24275
|
+
case "<":
|
|
24276
|
+
case "<=":
|
|
24277
|
+
case ">":
|
|
24278
|
+
case ">=":
|
|
24279
|
+
return 3 /* comparison */;
|
|
24280
|
+
case "and":
|
|
24281
|
+
case "unless":
|
|
24282
|
+
return 2 /* andUnless */;
|
|
24283
|
+
case "or":
|
|
24284
|
+
return 1 /* or */;
|
|
24285
|
+
default:
|
|
24286
|
+
return 0 /* none */;
|
|
24287
|
+
}
|
|
24288
|
+
};
|
|
24289
|
+
var isPromQLRightAssociative = (op) => op === "^";
|
|
24290
|
+
|
|
24291
|
+
// src/embedded_languages/promql/pretty_print/basic_pretty_printer.ts
|
|
24292
|
+
var PromQLBasicPrettyPrinter = class _PromQLBasicPrettyPrinter {
|
|
24293
|
+
/**
|
|
24294
|
+
* Print any PromQL AST node.
|
|
24295
|
+
*/
|
|
24296
|
+
static print = (node, opts) => {
|
|
24297
|
+
const printer = new _PromQLBasicPrettyPrinter(opts);
|
|
24298
|
+
return printer.print(node);
|
|
24299
|
+
};
|
|
24300
|
+
/**
|
|
24301
|
+
* Print a PromQL query expression.
|
|
24302
|
+
*/
|
|
24303
|
+
static query = (query2, opts) => {
|
|
24304
|
+
const printer = new _PromQLBasicPrettyPrinter(opts);
|
|
24305
|
+
return printer.printQuery(query2);
|
|
24306
|
+
};
|
|
24307
|
+
/**
|
|
24308
|
+
* Print a PromQL expression.
|
|
24309
|
+
*/
|
|
24310
|
+
static expression = (expr, opts) => {
|
|
24311
|
+
const printer = new _PromQLBasicPrettyPrinter(opts);
|
|
24312
|
+
return printer.printExpression(expr);
|
|
24313
|
+
};
|
|
24314
|
+
opts;
|
|
24315
|
+
constructor(opts = {}) {
|
|
24316
|
+
this.opts = {
|
|
24317
|
+
lowercaseFunctions: opts.lowercaseFunctions ?? false,
|
|
24318
|
+
lowercaseKeywords: opts.lowercaseKeywords ?? false,
|
|
24319
|
+
lowercaseOperators: opts.lowercaseOperators ?? false
|
|
24320
|
+
};
|
|
24321
|
+
}
|
|
24322
|
+
print(node) {
|
|
24323
|
+
if (node.type === "query") {
|
|
24324
|
+
return this.printQuery(node);
|
|
24325
|
+
}
|
|
24326
|
+
return this.printExpression(node);
|
|
24327
|
+
}
|
|
24328
|
+
printQuery(query2) {
|
|
24329
|
+
if (!query2.expression) {
|
|
24330
|
+
return "";
|
|
24331
|
+
}
|
|
24332
|
+
return this.printExpression(query2.expression);
|
|
24333
|
+
}
|
|
24334
|
+
printExpression(expr) {
|
|
24335
|
+
if (!expr) {
|
|
24336
|
+
return "";
|
|
24337
|
+
}
|
|
24338
|
+
switch (expr.type) {
|
|
24339
|
+
case "function":
|
|
24340
|
+
return this.printFunction(expr);
|
|
24341
|
+
case "selector":
|
|
24342
|
+
return this.printSelector(expr);
|
|
24343
|
+
case "binary-expression":
|
|
24344
|
+
return this.printBinaryExpression(expr);
|
|
24345
|
+
case "unary-expression":
|
|
24346
|
+
return this.printUnaryExpression(expr);
|
|
24347
|
+
case "subquery":
|
|
24348
|
+
return this.printSubquery(expr);
|
|
24349
|
+
case "parens":
|
|
24350
|
+
return this.printParens(expr);
|
|
24351
|
+
case "literal":
|
|
24352
|
+
return this.printLiteral(expr);
|
|
24353
|
+
case "identifier":
|
|
24354
|
+
return this.printIdentifier(expr);
|
|
24355
|
+
case "unknown":
|
|
24356
|
+
return "<unknown>";
|
|
24357
|
+
default:
|
|
24358
|
+
return "";
|
|
24359
|
+
}
|
|
24360
|
+
}
|
|
24361
|
+
printFunction(node) {
|
|
24362
|
+
const name = this.opts.lowercaseFunctions ? node.name.toLowerCase() : node.name;
|
|
24363
|
+
const args = node.args.map((arg) => this.printExpression(arg)).join(", ");
|
|
24364
|
+
const grouping = node.grouping ? this.printGrouping(node.grouping) : "";
|
|
24365
|
+
if (grouping && node.groupingPosition === "before") {
|
|
24366
|
+
return `${name} ${grouping} (${args})`;
|
|
24367
|
+
} else if (grouping) {
|
|
24368
|
+
return `${name}(${args}) ${grouping}`;
|
|
24369
|
+
} else {
|
|
24370
|
+
return `${name}(${args})`;
|
|
24371
|
+
}
|
|
24372
|
+
}
|
|
24373
|
+
printGrouping(node) {
|
|
24374
|
+
const keyword = this.opts.lowercaseKeywords ? node.name.toLowerCase() : node.name;
|
|
24375
|
+
const labels = node.args.map((l) => this.printLabelName(l)).join(", ");
|
|
24376
|
+
return `${keyword} (${labels})`;
|
|
24377
|
+
}
|
|
24378
|
+
printSelector(node) {
|
|
24379
|
+
let result = "";
|
|
24380
|
+
if (node.metric) {
|
|
24381
|
+
result += this.printIdentifier(node.metric);
|
|
24382
|
+
}
|
|
24383
|
+
if (node.labelMap) {
|
|
24384
|
+
result += this.printLabelMap(node.labelMap);
|
|
24385
|
+
}
|
|
24386
|
+
if (node.duration) {
|
|
24387
|
+
result += `[${this.printExpression(node.duration)}]`;
|
|
24388
|
+
}
|
|
24389
|
+
if (node.evaluation) {
|
|
24390
|
+
result += this.printEvaluation(node.evaluation);
|
|
24391
|
+
}
|
|
24392
|
+
return result;
|
|
24393
|
+
}
|
|
24394
|
+
printLabelMap(node) {
|
|
24395
|
+
const labels = node.args.map((l) => this.printLabel(l)).join(", ");
|
|
24396
|
+
return `{${labels}}`;
|
|
24397
|
+
}
|
|
24398
|
+
printLabel(node) {
|
|
24399
|
+
const labelName = this.printLabelName(node.labelName);
|
|
24400
|
+
const value = node.value ? this.printLiteral(node.value) : "";
|
|
24401
|
+
return `${labelName}${node.operator}${value}`;
|
|
24402
|
+
}
|
|
24403
|
+
printLabelName(node) {
|
|
24404
|
+
switch (node.type) {
|
|
24405
|
+
case "identifier":
|
|
24406
|
+
return this.printIdentifier(node);
|
|
24407
|
+
case "literal":
|
|
24408
|
+
return this.printLiteral(node);
|
|
24409
|
+
default:
|
|
24410
|
+
return "";
|
|
24411
|
+
}
|
|
24412
|
+
}
|
|
24413
|
+
printEvaluation(node) {
|
|
24414
|
+
let result = "";
|
|
24415
|
+
if (node.offset) {
|
|
24416
|
+
result += ` ${this.printOffset(node.offset)}`;
|
|
24417
|
+
}
|
|
24418
|
+
if (node.at) {
|
|
24419
|
+
result += ` ${this.printAt(node.at)}`;
|
|
24420
|
+
}
|
|
24421
|
+
return result;
|
|
24422
|
+
}
|
|
24423
|
+
printOffset(node) {
|
|
24424
|
+
const keyword = "offset";
|
|
24425
|
+
const sign = node.negative ? "- " : "";
|
|
24426
|
+
const duration = this.printExpression(node.duration);
|
|
24427
|
+
return `${keyword} ${sign}${duration}`;
|
|
24428
|
+
}
|
|
24429
|
+
printAt(node) {
|
|
24430
|
+
const sign = node.negative ? "- " : "";
|
|
24431
|
+
if (typeof node.value === "string") {
|
|
24432
|
+
return `@ ${sign}${node.value}`;
|
|
24433
|
+
}
|
|
24434
|
+
return `@ ${sign}${this.printLiteral(node.value)}`;
|
|
24435
|
+
}
|
|
24436
|
+
printBinaryExpression(node) {
|
|
24437
|
+
const group = promqlBinaryPrecedenceGroup(node);
|
|
24438
|
+
const leftGroup = promqlBinaryPrecedenceGroup(node.left);
|
|
24439
|
+
const rightGroup = promqlBinaryPrecedenceGroup(node.right);
|
|
24440
|
+
const operator = this.formatOperator(node.name);
|
|
24441
|
+
const isRightAssociative = isPromQLRightAssociative(node.name);
|
|
24442
|
+
let left = this.printExpression(node.left);
|
|
24443
|
+
let right = this.printExpression(node.right);
|
|
24444
|
+
if (leftGroup !== 0 /* none */ && (leftGroup < group || leftGroup === group && isRightAssociative)) {
|
|
24445
|
+
left = `(${left})`;
|
|
24446
|
+
}
|
|
24447
|
+
if (rightGroup !== 0 /* none */ && (rightGroup < group || rightGroup === group && !isRightAssociative)) {
|
|
24448
|
+
right = `(${right})`;
|
|
24449
|
+
}
|
|
24450
|
+
let modifiers = "";
|
|
24451
|
+
if (node.bool) {
|
|
24452
|
+
const boolKeyword = "bool";
|
|
24453
|
+
modifiers += ` ${boolKeyword}`;
|
|
24454
|
+
}
|
|
24455
|
+
if (node.modifier) {
|
|
24456
|
+
modifiers += ` ${this.printModifier(node.modifier)}`;
|
|
24457
|
+
}
|
|
24458
|
+
return `${left} ${operator}${modifiers} ${right}`;
|
|
24459
|
+
}
|
|
24460
|
+
printModifier(node) {
|
|
24461
|
+
const keyword = this.opts.lowercaseKeywords ? node.name.toLowerCase() : node.name;
|
|
24462
|
+
const labels = node.labels.map((l) => this.printLabelName(l)).join(", ");
|
|
24463
|
+
let result = `${keyword}(${labels})`;
|
|
24464
|
+
if (node.groupModifier) {
|
|
24465
|
+
result += ` ${this.printGroupModifier(node.groupModifier)}`;
|
|
24466
|
+
}
|
|
24467
|
+
return result;
|
|
24468
|
+
}
|
|
24469
|
+
printGroupModifier(node) {
|
|
24470
|
+
const keyword = this.opts.lowercaseKeywords ? node.name.toLowerCase() : node.name;
|
|
24471
|
+
const labels = node.labels.map((l) => this.printLabelName(l)).join(", ");
|
|
24472
|
+
if (labels) {
|
|
24473
|
+
return `${keyword}(${labels})`;
|
|
24474
|
+
}
|
|
24475
|
+
return keyword;
|
|
24476
|
+
}
|
|
24477
|
+
formatOperator(op) {
|
|
24478
|
+
if (op === "and" || op === "or" || op === "unless") {
|
|
24479
|
+
return this.opts.lowercaseOperators ? op.toLowerCase() : op;
|
|
24480
|
+
}
|
|
24481
|
+
return op;
|
|
24482
|
+
}
|
|
24483
|
+
printUnaryExpression(node) {
|
|
24484
|
+
const arg = this.printExpression(node.arg);
|
|
24485
|
+
return `${node.name}${arg}`;
|
|
24486
|
+
}
|
|
24487
|
+
printSubquery(node) {
|
|
24488
|
+
const expr = this.printExpression(node.expr);
|
|
24489
|
+
const range = this.printExpression(node.range);
|
|
24490
|
+
const resolution = node.resolution ? this.printExpression(node.resolution) : "";
|
|
24491
|
+
let result = `${expr}[${range}:${resolution}]`;
|
|
24492
|
+
if (node.evaluation) {
|
|
24493
|
+
result += this.printEvaluation(node.evaluation);
|
|
24494
|
+
}
|
|
24495
|
+
return result;
|
|
24496
|
+
}
|
|
24497
|
+
printParens(node) {
|
|
24498
|
+
const child = this.printExpression(node.child);
|
|
24499
|
+
return `(${child})`;
|
|
24500
|
+
}
|
|
24501
|
+
printLiteral(node) {
|
|
24502
|
+
switch (node.literalType) {
|
|
24503
|
+
case "integer":
|
|
24504
|
+
return this.printIntegerLiteral(node);
|
|
24505
|
+
case "decimal":
|
|
24506
|
+
return this.printDecimalLiteral(node);
|
|
24507
|
+
case "hexadecimal":
|
|
24508
|
+
return this.printHexLiteral(node);
|
|
24509
|
+
case "string":
|
|
24510
|
+
return this.printStringLiteral(node);
|
|
24511
|
+
case "time":
|
|
24512
|
+
return this.printTimeLiteral(node);
|
|
24513
|
+
default:
|
|
24514
|
+
return String(node.value);
|
|
24515
|
+
}
|
|
24516
|
+
}
|
|
24517
|
+
printIntegerLiteral(node) {
|
|
24518
|
+
return String(node.value);
|
|
24519
|
+
}
|
|
24520
|
+
printDecimalLiteral(node) {
|
|
24521
|
+
const value = node.value;
|
|
24522
|
+
if (Number.isNaN(value)) {
|
|
24523
|
+
return "NaN";
|
|
24524
|
+
}
|
|
24525
|
+
if (!Number.isFinite(value)) {
|
|
24526
|
+
return value > 0 ? "Inf" : "-Inf";
|
|
24527
|
+
}
|
|
24528
|
+
const str2 = String(value);
|
|
24529
|
+
if (!str2.includes(".") && !str2.includes("e") && !str2.includes("E")) {
|
|
24530
|
+
return str2 + ".0";
|
|
24531
|
+
}
|
|
24532
|
+
return str2;
|
|
24533
|
+
}
|
|
24534
|
+
printHexLiteral(node) {
|
|
24535
|
+
return "0x" + node.value.toString(16);
|
|
24536
|
+
}
|
|
24537
|
+
printStringLiteral(node) {
|
|
24538
|
+
const { value, valueUnquoted } = node;
|
|
24539
|
+
if (value !== valueUnquoted) {
|
|
24540
|
+
return value;
|
|
24541
|
+
}
|
|
24542
|
+
const escaped = valueUnquoted.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
|
|
24543
|
+
return `"${escaped}"`;
|
|
24544
|
+
}
|
|
24545
|
+
printTimeLiteral(node) {
|
|
24546
|
+
return node.value;
|
|
24547
|
+
}
|
|
24548
|
+
printIdentifier(node) {
|
|
24549
|
+
return node.name;
|
|
24550
|
+
}
|
|
24551
|
+
};
|
|
24552
|
+
|
|
24258
24553
|
// src/ast/grouping.ts
|
|
24259
24554
|
var BinaryExpressionGroup = /* @__PURE__ */ ((BinaryExpressionGroup2) => {
|
|
24260
24555
|
BinaryExpressionGroup2[BinaryExpressionGroup2["none"] = 0] = "none";
|
|
@@ -24601,12 +24896,16 @@ var ForkCommandVisitorContext = class extends CommandVisitorContext {
|
|
|
24601
24896
|
};
|
|
24602
24897
|
var CompletionCommandVisitorContext = class extends CommandVisitorContext {
|
|
24603
24898
|
};
|
|
24899
|
+
var RegisteredDomainCommandVisitorContext = class extends CommandVisitorContext {
|
|
24900
|
+
};
|
|
24604
24901
|
var SampleCommandVisitorContext = class extends CommandVisitorContext {
|
|
24605
24902
|
};
|
|
24606
24903
|
var FuseCommandVisitorContext = class extends CommandVisitorContext {
|
|
24607
24904
|
};
|
|
24608
24905
|
var MmrCommandVisitorContext = class extends CommandVisitorContext {
|
|
24609
24906
|
};
|
|
24907
|
+
var UriPartsCommandVisitorContext = class extends CommandVisitorContext {
|
|
24908
|
+
};
|
|
24610
24909
|
var ExpressionVisitorContext = class extends VisitorContext {
|
|
24611
24910
|
};
|
|
24612
24911
|
var ColumnExpressionVisitorContext = class extends VisitorContext {
|
|
@@ -24834,6 +25133,14 @@ var GlobalVisitorContext = class {
|
|
|
24834
25133
|
input
|
|
24835
25134
|
);
|
|
24836
25135
|
}
|
|
25136
|
+
case "registered_domain": {
|
|
25137
|
+
if (!this.methods.visitRegisteredDomainCommand) break;
|
|
25138
|
+
return this.visitRegisteredDomainCommand(
|
|
25139
|
+
parent,
|
|
25140
|
+
commandNode,
|
|
25141
|
+
input
|
|
25142
|
+
);
|
|
25143
|
+
}
|
|
24837
25144
|
case "sample": {
|
|
24838
25145
|
if (!this.methods.visitSampleCommand) break;
|
|
24839
25146
|
return this.visitSampleCommand(parent, commandNode, input);
|
|
@@ -24846,6 +25153,14 @@ var GlobalVisitorContext = class {
|
|
|
24846
25153
|
if (!this.methods.visitMmrCommand) break;
|
|
24847
25154
|
return this.visitMmrCommand(parent, commandNode, input);
|
|
24848
25155
|
}
|
|
25156
|
+
case "uri_parts": {
|
|
25157
|
+
if (!this.methods.visitUriPartsCommand) break;
|
|
25158
|
+
return this.visitUriPartsCommand(
|
|
25159
|
+
parent,
|
|
25160
|
+
commandNode,
|
|
25161
|
+
input
|
|
25162
|
+
);
|
|
25163
|
+
}
|
|
24849
25164
|
}
|
|
24850
25165
|
return this.visitCommandGeneric(parent, commandNode, input);
|
|
24851
25166
|
}
|
|
@@ -24956,6 +25271,10 @@ var GlobalVisitorContext = class {
|
|
|
24956
25271
|
const context = new CompletionCommandVisitorContext(this, node, parent);
|
|
24957
25272
|
return this.visitWithSpecificContext("visitCompletionCommand", context, input);
|
|
24958
25273
|
}
|
|
25274
|
+
visitRegisteredDomainCommand(parent, node, input) {
|
|
25275
|
+
const context = new RegisteredDomainCommandVisitorContext(this, node, parent);
|
|
25276
|
+
return this.visitWithSpecificContext("visitRegisteredDomainCommand", context, input);
|
|
25277
|
+
}
|
|
24959
25278
|
visitSampleCommand(parent, node, input) {
|
|
24960
25279
|
const context = new ForkCommandVisitorContext(this, node, parent);
|
|
24961
25280
|
return this.visitWithSpecificContext("visitSampleCommand", context, input);
|
|
@@ -24968,6 +25287,10 @@ var GlobalVisitorContext = class {
|
|
|
24968
25287
|
const context = new MmrCommandVisitorContext(this, node, parent);
|
|
24969
25288
|
return this.visitWithSpecificContext("visitMmrCommand", context, input);
|
|
24970
25289
|
}
|
|
25290
|
+
visitUriPartsCommand(parent, node, input) {
|
|
25291
|
+
const context = new UriPartsCommandVisitorContext(this, node, parent);
|
|
25292
|
+
return this.visitWithSpecificContext("visitUriPartsCommand", context, input);
|
|
25293
|
+
}
|
|
24971
25294
|
// #endregion
|
|
24972
25295
|
// #region Expression visiting -------------------------------------------------------
|
|
24973
25296
|
visitExpressionGeneric(parent, node, input) {
|
|
@@ -25489,9 +25812,12 @@ var BasicPrettyPrinter = class _BasicPrettyPrinter {
|
|
|
25489
25812
|
if (ctx.node.type === "unknown") {
|
|
25490
25813
|
return this.decorateWithComments(ctx.node, ctx.node.text || "<UNKNOWN>");
|
|
25491
25814
|
}
|
|
25815
|
+
if (isPromqlNode(ctx.node)) {
|
|
25816
|
+
const text = PromQLBasicPrettyPrinter.print(ctx.node);
|
|
25817
|
+
return this.decorateWithComments(ctx.node, text || "<UNKNOWN>");
|
|
25818
|
+
}
|
|
25492
25819
|
if (ctx.node.text) {
|
|
25493
|
-
|
|
25494
|
-
text = text.replace(/<EOF>/g, "").trim();
|
|
25820
|
+
const text = ctx.node.text.replace(/<EOF>/g, "").trim();
|
|
25495
25821
|
return this.decorateWithComments(ctx.node, text || "<UNKNOWN>");
|
|
25496
25822
|
}
|
|
25497
25823
|
return "<EXPRESSION>";
|
|
@@ -26072,6 +26398,9 @@ var WrappingPrettyPrinter = class _WrappingPrettyPrinter {
|
|
|
26072
26398
|
return { txt, indented };
|
|
26073
26399
|
}
|
|
26074
26400
|
visitor = new Visitor().on("visitExpression", (ctx, inp) => {
|
|
26401
|
+
if (isPromqlNode(ctx.node)) {
|
|
26402
|
+
return { txt: PromQLBasicPrettyPrinter.print(ctx.node) };
|
|
26403
|
+
}
|
|
26075
26404
|
let text = ctx.node.text ?? "<EXPRESSION>";
|
|
26076
26405
|
if (text) {
|
|
26077
26406
|
text = text.replace(/<EOF>/g, "").trim();
|
|
@@ -57521,11 +57850,11 @@ var PromQLCstToAstConverter = class {
|
|
|
57521
57850
|
const joiningKind = joiningToken.text?.toLowerCase() === "group_left" ? "group_left" : "group_right";
|
|
57522
57851
|
const groupLabelsCtx = ctx._groupLabels;
|
|
57523
57852
|
const groupLabels = groupLabelsCtx ? this.fromLabelList(groupLabelsCtx) : [];
|
|
57524
|
-
groupModifier = PromQLBuilder.groupModifier(
|
|
57525
|
-
|
|
57526
|
-
|
|
57527
|
-
|
|
57528
|
-
|
|
57853
|
+
groupModifier = PromQLBuilder.groupModifier(
|
|
57854
|
+
joiningKind,
|
|
57855
|
+
groupLabels,
|
|
57856
|
+
this.createParserFieldsFromToken(joiningToken, joiningToken.text ?? "")
|
|
57857
|
+
);
|
|
57529
57858
|
for (const label of groupLabels) {
|
|
57530
57859
|
if (label.incomplete) {
|
|
57531
57860
|
groupModifier.incomplete = true;
|
|
@@ -57585,6 +57914,22 @@ var PromQLCstToAstConverter = class {
|
|
|
57585
57914
|
timeValue,
|
|
57586
57915
|
this.createParserFieldsFromToken(timeValueWithColon.symbol, timeValue)
|
|
57587
57916
|
);
|
|
57917
|
+
const opToken = resolutionCtx._op;
|
|
57918
|
+
const rightCtx = resolutionCtx.expression();
|
|
57919
|
+
if (opToken && rightCtx) {
|
|
57920
|
+
const operator = this.toBinaryOperator(opToken.text ?? "");
|
|
57921
|
+
const right = this.fromExpression(rightCtx) ?? PromQLBuilder.unknown(this.getParserFields(rightCtx));
|
|
57922
|
+
resolution = PromQLBuilder.expression.binary(
|
|
57923
|
+
operator,
|
|
57924
|
+
resolution,
|
|
57925
|
+
right,
|
|
57926
|
+
{},
|
|
57927
|
+
this.getParserFields(resolutionCtx)
|
|
57928
|
+
);
|
|
57929
|
+
if (right.incomplete) {
|
|
57930
|
+
resolution.incomplete = true;
|
|
57931
|
+
}
|
|
57932
|
+
}
|
|
57588
57933
|
}
|
|
57589
57934
|
}
|
|
57590
57935
|
}
|
|
@@ -58195,6 +58540,10 @@ var CstToAstConverter = class {
|
|
|
58195
58540
|
if (completionCommandCtx) {
|
|
58196
58541
|
return this.fromCompletionCommand(completionCommandCtx);
|
|
58197
58542
|
}
|
|
58543
|
+
const registeredDomainCommandCtx = ctx.registeredDomainCommand();
|
|
58544
|
+
if (registeredDomainCommandCtx) {
|
|
58545
|
+
return this.fromRegisteredDomainCommand(registeredDomainCommandCtx);
|
|
58546
|
+
}
|
|
58198
58547
|
const sampleCommandCtx = ctx.sampleCommand();
|
|
58199
58548
|
if (sampleCommandCtx) {
|
|
58200
58549
|
return this.fromSampleCommand(sampleCommandCtx);
|
|
@@ -58219,6 +58568,10 @@ var CstToAstConverter = class {
|
|
|
58219
58568
|
if (mmrCommand) {
|
|
58220
58569
|
return this.fromMmrCommand(mmrCommand);
|
|
58221
58570
|
}
|
|
58571
|
+
const uriPartsCommandCtx = ctx.uriPartsCommand();
|
|
58572
|
+
if (uriPartsCommandCtx) {
|
|
58573
|
+
return this.fromUriPartsCommand(uriPartsCommandCtx);
|
|
58574
|
+
}
|
|
58222
58575
|
}
|
|
58223
58576
|
createCommand(name, ctx, partial) {
|
|
58224
58577
|
const parserFields = this.getParserFields(ctx);
|
|
@@ -58877,6 +59230,10 @@ var CstToAstConverter = class {
|
|
|
58877
59230
|
command2.inferenceId = inferenceId;
|
|
58878
59231
|
return command2;
|
|
58879
59232
|
}
|
|
59233
|
+
// -------------------------------------------------------- REGISTERED_DOMAIN
|
|
59234
|
+
fromRegisteredDomainCommand(ctx) {
|
|
59235
|
+
return this.fromQualifiedNameAssignmentCommand("registered_domain", ctx);
|
|
59236
|
+
}
|
|
58880
59237
|
// ------------------------------------------------------------------- SAMPLE
|
|
58881
59238
|
fromSampleCommand(ctx) {
|
|
58882
59239
|
const command2 = this.createCommand("sample", ctx);
|
|
@@ -59393,11 +59750,11 @@ var CstToAstConverter = class {
|
|
|
59393
59750
|
const queryVector = this.fromMmrQueryVectorParam(ctx.mmrQueryVectorParams());
|
|
59394
59751
|
if (queryVector) args.push(queryVector);
|
|
59395
59752
|
const onOption = this.fromMmrOnOption(ctx);
|
|
59396
|
-
args.push(onOption);
|
|
59397
|
-
const diversifyField = onOption
|
|
59753
|
+
if (onOption) args.push(onOption);
|
|
59754
|
+
const diversifyField = onOption?.args[0] ? onOption.args[0].args[0] : void 0;
|
|
59398
59755
|
const limitOption = this.fromMmrLimitOption(ctx);
|
|
59399
|
-
args.push(limitOption);
|
|
59400
|
-
const limit = limitOption.args[0];
|
|
59756
|
+
if (limitOption) args.push(limitOption);
|
|
59757
|
+
const limit = limitOption ? limitOption.args[0] : void 0;
|
|
59401
59758
|
const withOption = this.fromMmrWithOption(ctx.commandNamedParameters());
|
|
59402
59759
|
if (withOption) args.push(withOption);
|
|
59403
59760
|
const namedParameters = withOption ? withOption.args[0] : void 0;
|
|
@@ -59408,7 +59765,9 @@ var CstToAstConverter = class {
|
|
|
59408
59765
|
limit,
|
|
59409
59766
|
namedParameters
|
|
59410
59767
|
});
|
|
59411
|
-
command2.incomplete ||=
|
|
59768
|
+
command2.incomplete ||= queryVector?.incomplete ?? false;
|
|
59769
|
+
command2.incomplete ||= diversifyField?.incomplete ?? false;
|
|
59770
|
+
command2.incomplete ||= limitOption?.incomplete ?? false;
|
|
59412
59771
|
command2.incomplete ||= withOption?.incomplete ?? false;
|
|
59413
59772
|
return command2;
|
|
59414
59773
|
}
|
|
@@ -59427,6 +59786,7 @@ var CstToAstConverter = class {
|
|
|
59427
59786
|
}
|
|
59428
59787
|
fromMmrOnOption(ctx) {
|
|
59429
59788
|
const onToken = ctx.ON();
|
|
59789
|
+
if (!onToken) return;
|
|
59430
59790
|
const diversifyFieldCtx = ctx.qualifiedName();
|
|
59431
59791
|
const diversifyField = this.toColumn(diversifyFieldCtx);
|
|
59432
59792
|
const onOption = this.toOption(onToken.getText().toLowerCase(), diversifyFieldCtx);
|
|
@@ -59437,7 +59797,14 @@ var CstToAstConverter = class {
|
|
|
59437
59797
|
}
|
|
59438
59798
|
fromMmrLimitOption(ctx) {
|
|
59439
59799
|
const limitToken = ctx.MMR_LIMIT();
|
|
59800
|
+
if (!limitToken) return;
|
|
59440
59801
|
const limitValueCtx = ctx.integerValue();
|
|
59802
|
+
if (!limitValueCtx) {
|
|
59803
|
+
const limitOption2 = this.toOption(limitToken.getText().toLowerCase(), ctx, [], true);
|
|
59804
|
+
limitOption2.location.min = limitToken.symbol.start;
|
|
59805
|
+
limitOption2.location.max = limitToken.symbol.stop;
|
|
59806
|
+
return limitOption2;
|
|
59807
|
+
}
|
|
59441
59808
|
const limitOption = this.toOption(limitToken.getText().toLowerCase(), limitValueCtx);
|
|
59442
59809
|
limitOption.args.push(this.fromConstantToArray(limitValueCtx));
|
|
59443
59810
|
limitOption.location.min = limitToken.symbol.start;
|
|
@@ -59445,6 +59812,7 @@ var CstToAstConverter = class {
|
|
|
59445
59812
|
return limitOption;
|
|
59446
59813
|
}
|
|
59447
59814
|
fromMmrWithOption(namedParametersCtx) {
|
|
59815
|
+
if (!namedParametersCtx) return;
|
|
59448
59816
|
const withOption = this.fromCommandNamedParameters(namedParametersCtx);
|
|
59449
59817
|
const mapArg = withOption.args[0];
|
|
59450
59818
|
if (mapArg) {
|
|
@@ -59454,6 +59822,38 @@ var CstToAstConverter = class {
|
|
|
59454
59822
|
return withOption;
|
|
59455
59823
|
}
|
|
59456
59824
|
}
|
|
59825
|
+
// --------------------------------------------------------------- URI_PARTS
|
|
59826
|
+
fromUriPartsCommand(ctx) {
|
|
59827
|
+
return this.fromQualifiedNameAssignmentCommand("uri_parts", ctx);
|
|
59828
|
+
}
|
|
59829
|
+
fromQualifiedNameAssignmentCommand(name, ctx) {
|
|
59830
|
+
const command2 = this.createCommand(name, ctx);
|
|
59831
|
+
const qualifiedNameCtx = ctx.qualifiedName();
|
|
59832
|
+
if (qualifiedNameCtx && ctx.ASSIGN()) {
|
|
59833
|
+
const targetField = this.toColumn(qualifiedNameCtx);
|
|
59834
|
+
command2.targetField = targetField;
|
|
59835
|
+
const expression2 = this.fromPrimaryExpressionStrict(ctx.primaryExpression());
|
|
59836
|
+
command2.expression = expression2;
|
|
59837
|
+
if (expression2.incomplete || expression2.type === "unknown") {
|
|
59838
|
+
command2.incomplete = true;
|
|
59839
|
+
}
|
|
59840
|
+
const assignment = this.toFunction(
|
|
59841
|
+
ctx.ASSIGN().getText(),
|
|
59842
|
+
ctx,
|
|
59843
|
+
void 0,
|
|
59844
|
+
"binary-expression"
|
|
59845
|
+
);
|
|
59846
|
+
assignment.args.push(targetField, expression2);
|
|
59847
|
+
assignment.location = this.extendLocationToArgs(assignment);
|
|
59848
|
+
command2.args.push(assignment);
|
|
59849
|
+
} else if (qualifiedNameCtx) {
|
|
59850
|
+
const targetField = this.toColumn(qualifiedNameCtx);
|
|
59851
|
+
command2.targetField = targetField;
|
|
59852
|
+
command2.incomplete = true;
|
|
59853
|
+
command2.args.push(targetField);
|
|
59854
|
+
}
|
|
59855
|
+
return command2;
|
|
59856
|
+
}
|
|
59457
59857
|
// -------------------------------------------------------------- expressions
|
|
59458
59858
|
toColumnsFromCommand(ctx) {
|
|
59459
59859
|
if (ctx instanceof MetadataContext) {
|
|
@@ -63186,12 +63586,14 @@ export {
|
|
|
63186
63586
|
ParameterHole,
|
|
63187
63587
|
ParensExpressionVisitorContext,
|
|
63188
63588
|
Parser4 as Parser,
|
|
63589
|
+
PromQLBasicPrettyPrinter,
|
|
63189
63590
|
PromQLBuilder,
|
|
63190
63591
|
PromQLCstToAstConverter,
|
|
63191
63592
|
PromQLErrorListener,
|
|
63192
63593
|
PromQLParser,
|
|
63193
63594
|
PromqlWalker,
|
|
63194
63595
|
QueryVisitorContext,
|
|
63596
|
+
RegisteredDomainCommandVisitorContext,
|
|
63195
63597
|
RenameCommandVisitorContext,
|
|
63196
63598
|
RerankCommandVisitorContext,
|
|
63197
63599
|
RowCommandVisitorContext,
|
|
@@ -63205,6 +63607,7 @@ export {
|
|
|
63205
63607
|
TIME_SPAN_UNITS,
|
|
63206
63608
|
TimeseriesCommandVisitorContext,
|
|
63207
63609
|
UnaryExpressionGroup,
|
|
63610
|
+
UriPartsCommandVisitorContext,
|
|
63208
63611
|
Visitor,
|
|
63209
63612
|
VisitorContext,
|
|
63210
63613
|
Walker,
|
|
@@ -63239,6 +63642,7 @@ export {
|
|
|
63239
63642
|
isParamLiteral,
|
|
63240
63643
|
isParametrized,
|
|
63241
63644
|
isParens,
|
|
63645
|
+
isPromqlNode,
|
|
63242
63646
|
isProperNode,
|
|
63243
63647
|
isQuery,
|
|
63244
63648
|
isSource,
|