Skip to content
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
merged 8 commits into from
Jun 13, 2024

Conversation

nathan-artie
Copy link
Contributor

@nathan-artie nathan-artie commented Jun 13, 2024

Breaking out some parts of the Storage Write API PR I'm working out.

@nathan-artie nathan-artie marked this pull request as draft June 13, 2024 06:24
@nathan-artie nathan-artie requested a review from Tang8330 June 13, 2024 06:27
// Structs from relational and Mongo are different.
// 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) {
Copy link
Contributor Author

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.

@nathan-artie nathan-artie marked this pull request as ready for review June 13, 2024 06:32
ProjectID string `yaml:"projectID"`
Location string `yaml:"location"`
BatchSize int `yaml:"batchSize"`
UseStorageWriteAPI bool `yaml:"__useStorageWriteAPI"` // Not officially supported yet.
Copy link
Contributor Author

@nathan-artie nathan-artie Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For config settings that are not intended for production use I think it's nice to prefix them with "__" to indicate that the are not officially supported, that way we can get rid of them without breaking backwards compatibility and having to bump the minor version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Contributor

@Tang8330 Tang8330 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm% c


stringValue := string(bytes)
if strings.Contains(stringValue, constants.ToastUnavailableValuePlaceholder) {
slog.Error("encoded JSON value contains the toast unavailable value placeholder")
Copy link
Contributor

Choose a reason for hiding this comment

The 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

@nathan-artie nathan-artie merged commit 585c9d6 into master Jun 13, 2024
1 check passed
@nathan-artie nathan-artie deleted the nv/bigquery-storage-write-api-scaffolding branch June 13, 2024 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants