feat: adapt package to convert TableSchema to ProtoDescriptor#326
feat: adapt package to convert TableSchema to ProtoDescriptor#326alvarowolfx merged 18 commits intogoogleapis:mainfrom
Conversation
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
feywind
left a comment
There was a problem hiding this comment.
Cool, sorry for leaving so many comments :D but hopefully there's something useful in there. I don't see anything worth holding it back, but I'd definitely check out the behaviour on the circular package dependencies that Seth mentioned.
| const root = Root.fromJSON(namespace); | ||
| const SampleData = root.lookupType('SampleData'); | ||
|
|
||
| /** |
There was a problem hiding this comment.
Should these go closer to the snippet open tag so it's more visible to users copying and pasting?
| } | ||
| // [END bigquerystorage_write_pending_complexschema] | ||
| appendRowsProto2(); | ||
| } |
There was a problem hiding this comment.
As a user I kind of love the comprehensive nature of this sample, but I also worry that it's really long. I wonder if we want to have more than one for smaller aspects of the process. (Not really a comment on your stuff so much as thinking out loud in regards to snippet tags...)
| if (field.typeName) { | ||
| type = field.typeName; | ||
| } else { | ||
| type = fieldTypeLabelMap[field.type].replace('TYPE_', '').toLowerCase(); |
There was a problem hiding this comment.
I was reminded the other day, in case it matters, that replace(string, string) will only replace the first occurrence. You'd need to use /TYPE_/g to get all of them. (not sure if that applies here)
| return useProto3 | ||
| ? bqModeToFieldLabelMapProto3[mode] | ||
| : bqModeToFieldLabelMapProto2[mode]; | ||
| } |
There was a problem hiding this comment.
Overall comments, it might be good to go back and put in some jsdoc/tsdoc comments describing what the functions do. Or at least some basic non-doc comments. I'd also consider thinking about breaking this up into multiple files if you can, because it's sort of long.
|
|
||
| const {Root} = protobuf; | ||
|
|
||
| describe('Adapt Protos', () => { |
There was a problem hiding this comment.
If you're interested, I recently discovered a package snap-shot-it that lets you just record the output of a test, and then it will compare against the saved one. Not super essential though.
|
Warning: This pull request is touching the following templated files:
|
This sub package goal is to allow users to convert BigQuery Schema/Table Schema to protobuf Descriptors and then convert plain JSON objects to protobuf, making it easier to use with the Storage Write API and not depending on protofiles for sending data.
Example: