-
Notifications
You must be signed in to change notification settings - Fork 547
feat(oracledb)!: Update to SDK V3 Arrow native #11115
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
Merged
kodiakhq
merged 14 commits into
cloudquery:main
from
erezrokah:fix/update_oracledb_source_sdk_v3
Jun 21, 2023
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1627a22
feat(oracle)!: Update to SDK V3 Arrow native
erezrokah 57ce13f
style: Fix linting
erezrokah 2485802
chore: Fix typo
erezrokah 85f1f30
fix: Clean up types
erezrokah 9c7d6ba
refactor: Remove redundant isValid call
erezrokah ad77943
fix: Add missing types to transformer, simplify timestamp
erezrokah dfa70d2
refactor: Pre-alloc results
erezrokah bf9e576
fix: Add missing fixed size binary type
erezrokah 09a1930
test: null values
erezrokah 9a02777
style: Fix linting
erezrokah ac2c9a8
refactor: Use continue in loop
erezrokah b4b45c7
refactor: Use arrow.TypeEqual
erezrokah f9d13fa
fix: Update plugin-pb-go
erezrokah 2516e69
Merge branch 'main' into fix/update_oracledb_source_sdk_v3
erezrokah 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,137 +1,82 @@ | ||
| package client | ||
|
|
||
| import ( | ||
| "github.com/cloudquery/plugin-sdk/v2/schema" | ||
| "github.com/apache/arrow/go/v13/arrow" | ||
| "github.com/apache/arrow/go/v13/arrow/array" | ||
| "github.com/cloudquery/plugin-sdk/v3/types" | ||
| ) | ||
|
|
||
| // this is used for tests | ||
| type Transformer struct{} | ||
|
|
||
| func (*Transformer) TransformBool(v *schema.Bool) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
| return v.Bool | ||
| } | ||
|
|
||
| func (*Transformer) TransformBytea(v *schema.Bytea) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
| return v.Bytes | ||
| } | ||
|
|
||
| func (*Transformer) TransformFloat8(v *schema.Float8) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
| return v.Float | ||
| } | ||
|
|
||
| func (*Transformer) TransformInt8(v *schema.Int8) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
| return v.Int | ||
| } | ||
|
|
||
| func (*Transformer) TransformTimestamptz(v *schema.Timestamptz) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
| return v.Time | ||
| } | ||
|
|
||
| func (*Transformer) TransformJSON(v *schema.JSON) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
|
|
||
| return string(v.Bytes) | ||
| } | ||
|
|
||
| func (*Transformer) TransformUUID(v *schema.UUID) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
| // We need a slice instead of a fixed sized array | ||
| bytes := make([]byte, 16) | ||
| copy(bytes, v.Bytes[:]) | ||
| return bytes | ||
| } | ||
|
|
||
| func (*Transformer) TransformUUIDArray(v *schema.UUIDArray) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
|
|
||
| return v.String() | ||
| } | ||
|
|
||
| func (*Transformer) TransformInt8Array(v *schema.Int8Array) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
|
|
||
| return v.String() | ||
| } | ||
|
|
||
| func (*Transformer) TransformCIDR(v *schema.CIDR) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
| return v.String() | ||
| } | ||
|
|
||
| func (*Transformer) TransformInet(v *schema.Inet) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
| return v.String() | ||
| } | ||
|
|
||
| func (*Transformer) TransformMacaddr(v *schema.Macaddr) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
| return v.String() | ||
| } | ||
|
|
||
| func (*Transformer) TransformText(v *schema.Text) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
| return v.Str | ||
| } | ||
|
|
||
| func (*Transformer) TransformCIDRArray(v *schema.CIDRArray) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
|
|
||
| return v.String() | ||
| } | ||
|
|
||
| func (*Transformer) TransformInetArray(v *schema.InetArray) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
|
|
||
| return v.String() | ||
| } | ||
|
|
||
| func (*Transformer) TransformMacaddrArray(v *schema.MacaddrArray) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
|
|
||
| return v.String() | ||
| } | ||
|
|
||
| func (*Transformer) TransformTextArray(v *schema.TextArray) any { | ||
| if v.Status != schema.Present { | ||
| return nil | ||
| } | ||
|
|
||
| return v.String() | ||
| func GetValue(arr arrow.Array, i int) (any, error) { | ||
| if arr.IsNull(i) { | ||
| return nil, nil | ||
| } | ||
| switch a := arr.(type) { | ||
| case *array.Boolean: | ||
| return a.Value(i), nil | ||
| case *array.Int8: | ||
| return a.Value(i), nil | ||
| case *array.Int16: | ||
| return a.Value(i), nil | ||
| case *array.Int32: | ||
| return a.Value(i), nil | ||
| case *array.Int64: | ||
| return a.Value(i), nil | ||
| case *array.Uint8: | ||
| return a.Value(i), nil | ||
| case *array.Uint16: | ||
| return a.Value(i), nil | ||
| case *array.Uint32: | ||
| return a.Value(i), nil | ||
| case *array.Uint64: | ||
| return a.Value(i), nil | ||
| case *array.Float16: | ||
| return a.Value(i), nil | ||
| case *array.Float32: | ||
| return a.Value(i), nil | ||
| case *array.Float64: | ||
| return a.Value(i), nil | ||
| case *array.String: | ||
erezrokah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return a.Value(i), nil | ||
| case *array.LargeString: | ||
| return a.Value(i), nil | ||
| case *array.Binary: | ||
| return a.Value(i), nil | ||
| case *array.LargeBinary: | ||
| return a.Value(i), nil | ||
| case *array.FixedSizeBinary: | ||
| return a.Value(i), nil | ||
| case *array.Timestamp: | ||
| toTime, err := a.DataType().(*arrow.TimestampType).GetToTimeFunc() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return toTime(a.Value(i)), nil | ||
| case *types.UUIDArray: | ||
| bUUID, err := a.Value(i).MarshalBinary() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return bUUID, nil | ||
| default: | ||
| return a.ValueStr(i), nil | ||
| } | ||
| } | ||
|
|
||
| // used in the tests to insert the arrow.Record | ||
| func TransformRecord(record arrow.Record) ([][]any, error) { | ||
| numRows := record.NumRows() | ||
| res := make([][]any, numRows) | ||
| var err error | ||
| for i := int64(0); i < numRows; i++ { | ||
| numCols := record.NumCols() | ||
| row := make([]any, numCols) | ||
| for j := 0; int64(j) < numCols; j++ { | ||
| row[j], err = GetValue(record.Column(j), int(i)) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| } | ||
| res[i] = row | ||
| } | ||
| return res, nil | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.