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

feat: implement support for more well-known-types #10

Merged
merged 1 commit into from Jan 2, 2021
Merged

feat: implement support for more well-known-types #10

merged 1 commit into from Jan 2, 2021

Conversation

odsod
Copy link
Member

@odsod odsod commented Jan 2, 2021

  • google.protobuf.Struct (mapped to a JSON STRING)
  • google.type.TimeOfDay (mapped to TIME)
  • google.type.Date (mapped to DATE)
  • google.type.LatLng (mapped to GEOGRAPHY)

The reason for using GEOGRAPHY as default for LatLng is because of the
clustering opportunities for tables that store locations as GEOGRAPHY.

Future SchemaOptions may override to store LatLng as a record instead.

Integration tested against public BigQuery datasets. The intention is to
identify datasets that exercise the features of this library, then
perform a load/marshal/unmarshal sequence and validate that the original
result is preserved.

- google.protobuf.Struct (mapped to a JSON STRING)
- google.type.TimeOfDay (mapped to TIME)
- google.type.Date (mapped to DATE)
- google.type.LatLng (mapped to GEOGRAPHY)

The reason for using GEOGRAPHY as default for LatLng is because of the
clustering opportunities for tables that store locations as GEOGRAPHY.

Future SchemaOptions may override to store LatLng as a record instead.

Integration tested against public BigQuery datasets. The intention is to
identify datasets that exercise the features of this library, then
perform a load/marshal/unmarshal sequence and validate that the original
result is preserved.
@alethenorio
Copy link

Why not map proto struct to a BigQuery struct as well (I think they call it a record in Go)?

@odsod
Copy link
Member Author

odsod commented Jan 2, 2021

@alethenorio google.protobuf.Struct is an untyped struct without a schema - can't be mapped 1:1 with a BigQuery RECORD.

@alethenorio
Copy link

Ah I see, it's just a map. 👍

@@ -17,65 +17,111 @@ import (
)

func Test_Integration_PublicDataSets(t *testing.T) {
t.Parallel()

Choose a reason for hiding this comment

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

I generally take it as a convention to not use parallelization in tests. It makes things more complicated than they need to be.

See https://speakerdeck.com/mitchellh/advanced-testing-with-go?slide=67

Do we really need it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Each instance of the test takes ~5s to run depending on connection time to BigQuery - some datasets seem to be rate limited.

The latest version of GolangCI-Lint comes with a linter for t.Parallel(). Do you think we should disable it? I think it's good that it makes tests run faster, and that it enforces to not share resources between tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

From the docs I understand the linter will enforce bad usage of t.Parallel so I see no reason to disable it.

I think we can make educated uses of t.Parallel and this sounds like one of them given the nature of the integration tests, just need to be careful, specially in integration tests as sharing of resources (such as a database) is more prone to happen.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good to me!

Copy link

@alethenorio alethenorio left a comment

Choose a reason for hiding this comment

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

Very nice work. Keep it up

@odsod
Copy link
Member Author

odsod commented Jan 2, 2021

@alethenorio Thanks! 🙌

@odsod odsod merged commit 1f5f423 into master Jan 2, 2021
@odsod odsod deleted the wkt2 branch January 2, 2021 13:12
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.

None yet

2 participants