forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apacheGH-36318: [Go] only decode lengths for the number of existing v…
…alues, not for all nvalues. (apache#36322) ### Rationale for this change Fixes issue 36318. DeltaLengthBinaryArray Encoding fails to handle null values. ### What changes are included in this PR? Instead of decoding lengths for "all" values (even the undefined ones), we only decode the lengths for the actually set values. The Go Version of arrow was unable to read parquet files it produced itself if the mentioned encoding was used but the values contain nulls. ### Are these changes tested? Tests are included. ### Are there any user-facing changes? No. **This PR contains a "Critical Fix".** * Closes: apache#36318 Authored-by: Justin Heesemann <jheesemann@argo.ai> Signed-off-by: Matt Topol <zotthewizard@gmail.com>
- Loading branch information
1 parent
71ce494
commit 93d7a2c
Showing
4 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package encoding | ||
|
||
import ( | ||
"fmt" | ||
"github.com/apache/arrow/go/v13/arrow/memory" | ||
"github.com/apache/arrow/go/v13/parquet" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestDeltaByteArrayDecoder_SetData(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
nvalues int | ||
data []byte | ||
wantErr assert.ErrorAssertionFunc | ||
}{ | ||
{ | ||
name: "null only page", | ||
nvalues: 126609, | ||
data: []byte{128, 1, 4, 0, 0}, | ||
wantErr: assert.NoError, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
d := NewDecoder(parquet.Types.ByteArray, parquet.Encodings.DeltaLengthByteArray, nil, memory.DefaultAllocator) | ||
t.Run(tt.name, func(t *testing.T) { | ||
tt.wantErr(t, d.SetData(tt.nvalues, tt.data), fmt.Sprintf("SetData(%v, %v)", tt.nvalues, tt.data)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters