-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Put null helpers back #1002
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e295a4f
put null helpers back
candiduslynx 4fa4143
//nolint:unused
candiduslynx 798e1ef
Update plugin/nulls.go
candiduslynx 3108343
upd todo
candiduslynx f5f6209
lint
candiduslynx 68f8557
Merge branch 'main' into feat/allow-null-test-opt
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package plugin | ||
|
||
import ( | ||
"github.com/apache/arrow/go/v13/arrow" | ||
"github.com/apache/arrow/go/v13/arrow/array" | ||
"github.com/apache/arrow/go/v13/arrow/memory" | ||
) | ||
|
||
// TODO(v4): use in v4 | ||
// | ||
// nolint:unused | ||
func stripNullsFromLists(records []arrow.Record) { | ||
for i := range records { | ||
cols := records[i].Columns() | ||
for c, col := range cols { | ||
if col.DataType().ID() != arrow.LIST { | ||
continue | ||
} | ||
|
||
list := col.(*array.List) | ||
bldr := array.NewListBuilder(memory.DefaultAllocator, list.DataType().(*arrow.ListType).Elem()) | ||
for j := 0; j < list.Len(); j++ { | ||
if list.IsNull(j) { | ||
bldr.AppendNull() | ||
continue | ||
} | ||
bldr.Append(true) | ||
vBldr := bldr.ValueBuilder() | ||
from, to := list.ValueOffsets(j) | ||
slc := array.NewSlice(list.ListValues(), from, to) | ||
for k := 0; k < int(to-from); k++ { | ||
if slc.IsNull(k) { | ||
continue | ||
} | ||
err := vBldr.AppendValueFromString(slc.ValueStr(k)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
} | ||
cols[c] = bldr.NewArray() | ||
} | ||
records[i] = array.NewRecord(records[i].Schema(), cols, records[i].NumRows()) | ||
} | ||
} | ||
|
||
type AllowNullFunc func(arrow.DataType) bool | ||
|
||
// TODO(v4): use in v4 | ||
// | ||
// nolint:unused | ||
func (f AllowNullFunc) replaceNullsByEmpty(records []arrow.Record) { | ||
if f == nil { | ||
return | ||
} | ||
for i := range records { | ||
cols := records[i].Columns() | ||
for c, col := range records[i].Columns() { | ||
if col.NullN() == 0 || f(col.DataType()) { | ||
continue | ||
} | ||
|
||
builder := array.NewBuilder(memory.DefaultAllocator, records[i].Column(c).DataType()) | ||
for j := 0; j < col.Len(); j++ { | ||
if col.IsNull(j) { | ||
builder.AppendEmptyValue() | ||
continue | ||
} | ||
|
||
if err := builder.AppendValueFromString(col.ValueStr(j)); err != nil { | ||
panic(err) | ||
} | ||
} | ||
cols[c] = builder.NewArray() | ||
} | ||
records[i] = array.NewRecord(records[i].Schema(), cols, records[i].NumRows()) | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we adding unused code? Will there be a follow-up where it gets used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I was just migrating CH when I noticed this missing.
I can comment out the relevant section in CH tests, but it will still be required once we bring the vast testing back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can leave this here as a reminder, but can we rather add it back when it's needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯