Skip to content

Commit

Permalink
Merge pull request redpanda-data#2330 from benthosdev/mihaitodor-fix-…
Browse files Browse the repository at this point in the history
…bloblang-zip-panic

Fix panic when calling `zip()` in Bloblang
  • Loading branch information
Jeffail authored Jan 26, 2024
2 parents 2d5c912 + 0754b99 commit 88d4fcf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ All notable changes to this project will be documented in this file.
- The `javascript` processor now handles module imports correctly.
- Bloblang `if` statements now provide explicit errors when query expressions resolve to non-boolean values.

### Fixed

- The `zip` Bloblang method no longer fails when executed without arguments.

### Changed

- The `parse_parquet` Bloblang function, `parquet_decode`, `parquet_encode` processors and the `parquet` input have all been upgraded to the latest version of the underlying Parquet library. Since this underlying library is experimental it is likely that behaviour changes will result. One significant change is that encoding numerical values that are larger than the column type (`float64` into `FLOAT`, `int64` into `INT32`, etc) will no longer be automatically converted.
Expand Down
5 changes: 5 additions & 0 deletions internal/impl/pure/bloblang_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ If a key within a nested path does not exist then it is ignored.`).
),
func(args *bloblang.ParsedParams) (bloblang.Method, error) {
sizeError := fmt.Errorf("can't zip different length array values")
argError := fmt.Errorf("zip requires at least one argument")

argAnys := args.AsSlice()
argSlices := make([][]any, len(argAnys))
for i, a := range argAnys {
Expand All @@ -125,6 +127,9 @@ If a key within a nested path does not exist then it is ignored.`).
}

return bloblang.ArrayMethod(func(i []any) (any, error) {
if len(argSlices) == 0 {
return nil, argError
}
if len(i) != len(argSlices[0]) {
return nil, sizeError
}
Expand Down

0 comments on commit 88d4fcf

Please sign in to comment.