|
|
|
@ -134,43 +134,45 @@ func (es Expressions) String() (s string) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (node *AggregateExpr) String() string { |
|
|
|
|
aggrString := fmt.Sprintf("%s(", node.Op) |
|
|
|
|
if node.Op.isAggregatorWithParam() { |
|
|
|
|
aggrString += fmt.Sprintf("%s, ", node.Param) |
|
|
|
|
} |
|
|
|
|
aggrString += fmt.Sprintf("%s)", node.Expr) |
|
|
|
|
aggrString := node.Op.String() |
|
|
|
|
|
|
|
|
|
if node.Without { |
|
|
|
|
aggrString = fmt.Sprintf("%s WITHOUT (%s)", aggrString, strings.Join(node.Grouping, ", ")) |
|
|
|
|
aggrString += fmt.Sprintf(" without(%s) ", strings.Join(node.Grouping, ", ")) |
|
|
|
|
} else { |
|
|
|
|
if len(node.Grouping) > 0 { |
|
|
|
|
aggrString = fmt.Sprintf("%s BY (%s)", aggrString, strings.Join(node.Grouping, ", ")) |
|
|
|
|
aggrString += fmt.Sprintf(" by(%s) ", strings.Join(node.Grouping, ", ")) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
aggrString += "(" |
|
|
|
|
if node.Op.isAggregatorWithParam() { |
|
|
|
|
aggrString += fmt.Sprintf("%s, ", node.Param) |
|
|
|
|
} |
|
|
|
|
aggrString += fmt.Sprintf("%s)", node.Expr) |
|
|
|
|
|
|
|
|
|
return aggrString |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (node *BinaryExpr) String() string { |
|
|
|
|
returnBool := "" |
|
|
|
|
if node.ReturnBool { |
|
|
|
|
returnBool = " BOOL" |
|
|
|
|
returnBool = " bool" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
matching := "" |
|
|
|
|
vm := node.VectorMatching |
|
|
|
|
if vm != nil && (len(vm.MatchingLabels) > 0 || vm.On) { |
|
|
|
|
if vm.On { |
|
|
|
|
matching = fmt.Sprintf(" ON(%s)", strings.Join(vm.MatchingLabels, ", ")) |
|
|
|
|
matching = fmt.Sprintf(" on(%s)", strings.Join(vm.MatchingLabels, ", ")) |
|
|
|
|
} else { |
|
|
|
|
matching = fmt.Sprintf(" IGNORING(%s)", strings.Join(vm.MatchingLabels, ", ")) |
|
|
|
|
matching = fmt.Sprintf(" ignoring(%s)", strings.Join(vm.MatchingLabels, ", ")) |
|
|
|
|
} |
|
|
|
|
if vm.Card == CardManyToOne || vm.Card == CardOneToMany { |
|
|
|
|
matching += " GROUP_" |
|
|
|
|
matching += " group_" |
|
|
|
|
if vm.Card == CardManyToOne { |
|
|
|
|
matching += "LEFT" |
|
|
|
|
matching += "left" |
|
|
|
|
} else { |
|
|
|
|
matching += "RIGHT" |
|
|
|
|
matching += "right" |
|
|
|
|
} |
|
|
|
|
matching += fmt.Sprintf("(%s)", strings.Join(vm.Include, ", ")) |
|
|
|
|
} |
|
|
|
@ -189,7 +191,7 @@ func (node *MatrixSelector) String() string {
|
|
|
|
|
} |
|
|
|
|
offset := "" |
|
|
|
|
if node.Offset != time.Duration(0) { |
|
|
|
|
offset = fmt.Sprintf(" OFFSET %s", model.Duration(node.Offset)) |
|
|
|
|
offset = fmt.Sprintf(" offset %s", model.Duration(node.Offset)) |
|
|
|
|
} |
|
|
|
|
return fmt.Sprintf("%s[%s]%s", vecSelector.String(), model.Duration(node.Range), offset) |
|
|
|
|
} |
|
|
|
@ -221,7 +223,7 @@ func (node *VectorSelector) String() string {
|
|
|
|
|
} |
|
|
|
|
offset := "" |
|
|
|
|
if node.Offset != time.Duration(0) { |
|
|
|
|
offset = fmt.Sprintf(" OFFSET %s", model.Duration(node.Offset)) |
|
|
|
|
offset = fmt.Sprintf(" offset %s", model.Duration(node.Offset)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if len(labelStrings) == 0 { |
|
|
|
|