Skip to content

Commit 1dd5a24

Browse files
committed
fix: switch [][]byte split support to []byte
1 parent 6dee545 commit 1dd5a24

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

pkg/ottl/expression.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (g exprGetter[K]) Get(ctx context.Context, tCtx K) (any, error) {
135135
if err != nil {
136136
return nil, err
137137
}
138-
case [][]byte:
138+
case []byte:
139139
result, err = getElementByIndex(r, k.Int)
140140
if err != nil {
141141
return nil, err

pkg/ottl/expression_test.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ func basicSliceFloat() (ExprFunc[any], error) {
9999
}, nil
100100
}
101101

102-
func basicSliceBytes() (ExprFunc[any], error) {
102+
func basicSliceByte() (ExprFunc[any], error) {
103103
return func(_ context.Context, _ any) (any, error) {
104104
return []any{
105-
[][]byte{
106-
[]byte("pass"),
105+
[]byte{
106+
byte('p'),
107107
},
108108
}, nil
109109
}, nil
@@ -314,7 +314,6 @@ func Test_newGetter(t *testing.T) {
314314
Function: "SliceBool",
315315
Keys: []key{
316316
{
317-
// note for review: not sure if this is correct
318317
Int: ottltest.Intp(0),
319318
},
320319
{
@@ -334,7 +333,6 @@ func Test_newGetter(t *testing.T) {
334333
Function: "SliceInteger",
335334
Keys: []key{
336335
{
337-
// note for review: not sure if this is correct
338336
Int: ottltest.Intp(0),
339337
},
340338
{
@@ -354,7 +352,6 @@ func Test_newGetter(t *testing.T) {
354352
Function: "SliceFloat",
355353
Keys: []key{
356354
{
357-
// note for review: not sure if this is correct
358355
Int: ottltest.Intp(0),
359356
},
360357
{
@@ -367,14 +364,13 @@ func Test_newGetter(t *testing.T) {
367364
want: 1.0,
368365
},
369366
{
370-
name: "function call nested SliceBytes",
367+
name: "function call nested SliceByte",
371368
val: value{
372369
Literal: &mathExprLiteral{
373370
Converter: &converter{
374-
Function: "SliceBytes",
371+
Function: "SliceByte",
375372
Keys: []key{
376373
{
377-
// note for review: not sure if this is correct
378374
Int: ottltest.Intp(0),
379375
},
380376
{
@@ -384,7 +380,7 @@ func Test_newGetter(t *testing.T) {
384380
},
385381
},
386382
},
387-
want: []byte("pass"),
383+
want: byte('p'),
388384
},
389385
{
390386
name: "enum",
@@ -685,7 +681,7 @@ func Test_newGetter(t *testing.T) {
685681
createFactory("SliceBool", &struct{}{}, basicSliceBool),
686682
createFactory("SliceInteger", &struct{}{}, basicSliceInteger),
687683
createFactory("SliceFloat", &struct{}{}, basicSliceFloat),
688-
createFactory("SliceBytes", &struct{}{}, basicSliceBytes),
684+
createFactory("SliceByte", &struct{}{}, basicSliceByte),
689685
)
690686

691687
p, _ := NewParser[any](

0 commit comments

Comments
 (0)