Skip to content

Commit ffdfde0

Browse files
TylerHelmuthsigilioso
authored andcommitted
[pkg/ottl] Fix issue with named parameter spacing (open-telemetry#28511)
**Description:** Fixes an issue with the grammar where named parameters had to have a space after the `=`. **Link to tracking Issue:** Closes open-telemetry#27638 **Testing:** Added a new unit test
1 parent b3dfe8f commit ffdfde0

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: pkg/ottl
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Fix bug where named parameters needed a space after the equal sign (`=`).
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [28511]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

pkg/ottl/grammar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,14 +434,14 @@ func buildLexer() *lexer.StatefulDefinition {
434434
{Name: `Float`, Pattern: `[-+]?\d*\.\d+([eE][-+]?\d+)?`},
435435
{Name: `Int`, Pattern: `[-+]?\d+`},
436436
{Name: `String`, Pattern: `"(\\"|[^"])*"`},
437-
{Name: `Equal`, Pattern: `=[^=]`},
438437
{Name: `OpNot`, Pattern: `\b(not)\b`},
439438
{Name: `OpOr`, Pattern: `\b(or)\b`},
440439
{Name: `OpAnd`, Pattern: `\b(and)\b`},
441440
{Name: `OpComparison`, Pattern: `==|!=|>=|<=|>|<`},
442441
{Name: `OpAddSub`, Pattern: `\+|\-`},
443442
{Name: `OpMultDiv`, Pattern: `\/|\*`},
444443
{Name: `Boolean`, Pattern: `\b(true|false)\b`},
444+
{Name: `Equal`, Pattern: `=`},
445445
{Name: `LParen`, Pattern: `\(`},
446446
{Name: `RParen`, Pattern: `\)`},
447447
{Name: `Punct`, Pattern: `[,.\[\]]`},

pkg/ottl/parser_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,24 @@ func Test_parse(t *testing.T) {
10591059
},
10601060
},
10611061
},
1062+
{
1063+
name: "editor with named arg",
1064+
statement: `set(name="foo")`,
1065+
expected: &parsedStatement{
1066+
Editor: editor{
1067+
Function: "set",
1068+
Arguments: []argument{
1069+
{
1070+
Name: "name",
1071+
Value: value{
1072+
String: ottltest.Strp("foo"),
1073+
},
1074+
},
1075+
},
1076+
},
1077+
WhereClause: nil,
1078+
},
1079+
},
10621080
}
10631081

10641082
for _, tt := range tests {

0 commit comments

Comments
 (0)