Uh oh!
There was an error while loading. Please reload this page.
Dataset.key() docs + proposal for simpler API - #209
Conversation
stephenplusplus
commented
Sep 13, 2014
Can you change the named parameter to Here's an example of how we can document our current structure: But, I'm not a big fan of the variable arity, either. It's not something I've seen too often in js-land, since we have the ease of passing around configuration objects. I'm not sure you'll like this any better, but I propose we instead only allow a single argument to // path stringdataset.key('Company');// path arraydataset.key(['Company',1]);// object specifying namespace and pathdataset.key({namespace: 'MyNS',path: ['Company',1]});So basically, if provide an object: control all components. Provide an array or string, you're providing the path. I think all it takes is seeing an example, reading about the namespace inheritance, and it's pretty straightforward from there. |
ryanseys
commented
Sep 13, 2014
Yeah, I think that'll give us a good compromise. I'll work on making that happen. |
ryanseys
commented
Sep 13, 2014
PTAL. This should change |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
stephenplusplus
commented
Sep 13, 2014
If there isn't something that covers this already, could you add a test on dataset.key to see if it handles strings as expected? |
ryanseys
commented
Sep 13, 2014
Agh! Good call, I found an issue. Question now though, is: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
ryanseys
commented
Sep 13, 2014
PTAL |
stephenplusplus
commented
Sep 13, 2014
My dataset.key() example was I guess foreshadowing our desired support for auto-injecting null. Since we don't have that yet, and even after we do, this would be an invalid key currently. After we auto inject null (if we do) it would be a valid, incomplete key. |
ryanseys
commented
Sep 13, 2014
Yeah, I just realized that. Although our code doesn't do it anywhere, it would create an invalid key. I will get started on auto-injecting nulls if we think that's a good idea? Let me know. |
stephenplusplus
commented
Sep 13, 2014
I think it's safe to do that. We used to take an array and if it wasn't an even number length, we used the first item as the namespace. Back then, it wasn't possible for us to infer an odd length meant a key didn't have an id or if it didn't have a namespace, so we decided to require nulls for ids. Now that we require explicit specification of a namespace, we can safely use the logic above to pluck off the id from the other end. Ps: I'm not sure the above story is true, but I think it makes sense :) |
ryanseys
commented
Sep 13, 2014
That was going to be my approach as well, just if keyPath.length % 2 === 1 ---> inject null |
ryanseys
commented
Sep 13, 2014
Backward compatibility fail: |
ryanseys
commented
Sep 13, 2014
... In theory we could support it if we check if arguments.length > 1 |
stephenplusplus
commented
Sep 13, 2014
Yeah, as long as we bump the major. But either way, semver grants us free reign to do whatever pre-1.0. |
stephenplusplus
commented
Sep 13, 2014
While we are still pre a major release, I vote to rid it instead of supporting it forever. |
stephenplusplus
commented
Sep 13, 2014
Can you remove that line? While it's informative for us, it's probably not relevant to the doc reader. |
ryanseys
commented
Sep 13, 2014
The line above it states that name='Google' so I thought I should clarify. Also in the docs it says:
|
ryanseys
commented
Sep 13, 2014
But I'll remove it. |
stephenplusplus
commented
Sep 13, 2014
I actually like it now. I didn't notice the difference in your example explaining name= vs id=. Makes sense to keep it 👍 |
ryanseys
commented
Sep 13, 2014
So we support: varkey=ds.key('world');// orvarkey=ds.key(['world']);// orvarkey=ds.key({path: ['world']});Should we support: varkey=ds.key({path: 'world'});? |
ryanseys
commented
Sep 13, 2014
I think yes unless there's any objections. |
stephenplusplus
commented
Sep 13, 2014
I do see how if we support a string in one place, we should support it in another. However, I think we can get away with requiring an array there, because an object is the explicit specification format. We should expect them to conform to the schema, where a namespace is a string, and a path is an array. I wanted to allow Just my opinion. |
ryanseys
commented
Sep 13, 2014
Yeah, we should probably be more explicit with the values we accept. I agree with you. We can document it as: varkey=ds.key(kind);// kind is a string e.g. 'Company'// orvarkey=ds.key(path);// path is an array e.g. ['Company'] or ['Company', 123]// orvarkey=ds.key({namespace: namespace,path: path}); |
ryanseys
commented
Sep 13, 2014
So, I actually didn't need to do much in order to support this. It seems there was only a check making sure that we didn't pass in less than two values for the path. I just changed it to make sure we were passing in at least 1 value for the path. Updated the docs and tests to reflect this change. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
* feat: add BigQuery Storage Write API v1 Committer: @yirutang PiperOrigin-RevId: 397350004 Source-Link: googleapis/googleapis@b4da4fd Source-Link: googleapis/googleapis-gen@67bcfcf Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNjdiY2ZjZmEwMGE0MTEzZTk2OGJhYzFhMTBkMGFkMGMxYjdkYzQ1YiJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: fix system tests Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Takashi Matsuo <tmatsuo@google.com>
🤖 I have created a release \*beep\* \*boop\* --- ## [2.7.0](https://www.github.com/googleapis/nodejs-bigquery-storage/compare/v2.6.2...v2.7.0) (2021-09-27) ### Features * add BigQuery Storage Write API v1 ([#209](https://www.github.com/googleapis/nodejs-bigquery-storage/issues/209)) ([e0401d9](https://www.github.com/googleapis/nodejs-bigquery-storage/commit/e0401d96480cd192a2fad8075884d2a8abd417ca)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Source-Author: F. Hinkelmann <franziska.hinkelmann@gmail.com> Source-Date: Tue Jul 21 10:53:20 2020 -0400 Source-Repo: googleapis/synthtool Source-Sha: 99c93fe09f8c1dca09dfc0301c8668e3a70dd796 Source-Link: googleapis/synthtool@99c93fe Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com>
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/0d0efc4e-9ccd-472b-a303-4bbf020fc2e0/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@ba9918c
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/cc99acfa-05b8-434b-9500-2f6faf2eaa02/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@799d8e6
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/cc99acfa-05b8-434b-9500-2f6faf2eaa02/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@799d8e6
* Add KMS to bucket * Using environment variables to load the KMS key Adding example for uploading file with KMS kˆey * Added todo for developer for the defaultKmsKeyName * Generating README and other scaffolding * Running prettier * Fixed typo. Added help text for bucket example. * Adding a .mailmap file

There were no docs at all for Dataset.key() so I added some here. They are not perfect though because the weird param structure used for the function.
Currently the params are something like either:
objectstringarrayor
Issues:
@paramset: what is suggested here)this.namespaceexists or manually provide it, or I can useFunction.applyto apply the array to the function as arguments (yikes!)Proposal (not implemented here):
Just accept an object, specifying path. It's not hard to understand, document and requires only 9 characters extra for the developer to surround their old arguments for this new method:
.key({ path: [ <old arguments> ] })objectfalsestringtrue(usethis.namespaceif not provided)arrayfalse