-
Notifications
You must be signed in to change notification settings - Fork 30
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
[bigquery] Add scaffolding for the Storage Write API #720
Merged
nathan-artie
merged 8 commits into
master
from
nv/bigquery-storage-write-api-scaffolding
Jun 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a28c02d
[bigquery] Add scaffolding for the Storage Write API
nathan-artie b5c9fec
Space
nathan-artie 6b505bd
Add test
nathan-artie 351aa0e
Add log
nathan-artie 0f825c9
Change error
nathan-artie 4826202
Fix return
nathan-artie e446373
Test
nathan-artie a43498e
Merge branch 'master' into nv/bigquery-storage-write-api-scaffolding
nathan-artie 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 |
---|---|---|
|
@@ -96,16 +96,21 @@ func castColVal(colVal any, colKind columns.Column, additionalDateFmts []string) | |
// MongoDB will return the native objects back such as `map[string]any{"hello": "world"}` | ||
// Relational will return a string representation of the struct such as `{"hello": "world"}` | ||
func EncodeStructToJSONString(value any) (string, error) { | ||
if colValString, isOk := value.(string); isOk { | ||
if strings.Contains(colValString, constants.ToastUnavailableValuePlaceholder) { | ||
if stringValue, isOk := value.(string); isOk { | ||
if strings.Contains(stringValue, constants.ToastUnavailableValuePlaceholder) { | ||
return fmt.Sprintf(`{"key":"%s"}`, constants.ToastUnavailableValuePlaceholder), nil | ||
} | ||
return colValString, nil | ||
return stringValue, nil | ||
} | ||
|
||
colValBytes, err := json.Marshal(value) | ||
bytes, err := json.Marshal(value) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to marshal colVal: %w", err) | ||
} | ||
return string(colValBytes), nil | ||
|
||
stringValue := string(bytes) | ||
if strings.Contains(stringValue, constants.ToastUnavailableValuePlaceholder) { | ||
slog.Error("encoded JSON value contains the toast unavailable value placeholder") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should return this too return fmt.Sprintf(`{"key":"%s"}`, constants.ToastUnavailableValuePlaceholder), nil |
||
} | ||
return stringValue, nil | ||
} |
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.
Will need this for the Storage Write API.