-
Notifications
You must be signed in to change notification settings - Fork 84
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
docs(samples): jsonstreamwriter samples #756
docs(samples): jsonstreamwriter samples #756
Conversation
Codecov Report
@@ Coverage Diff @@
## master #756 +/- ##
=========================================
Coverage 80.89% 80.89%
Complexity 992 992
=========================================
Files 74 74
Lines 5333 5333
Branches 412 412
=========================================
Hits 4314 4314
Misses 847 847
Partials 172 172 Continue to review full report at Codecov.
|
please follow Example: googleapis/java-bigquery@37c0632 Please make sure to correct your initial commit. |
0dca7de
to
1d2ae21
Compare
1d2ae21
to
5cffc9c
Compare
I added 'doc(samples)' - What should I use for region_tag and sample in this case? |
samples/snippets/src/main/java/com/example/bigquerystorage/WriteCommittedStream.java
Show resolved
Hide resolved
package com.example.bigquerystorage; | ||
|
||
import com.google.api.core.ApiFuture; | ||
import com.google.cloud.bigquery.*; |
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.
please import only used packages and avoid *
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.
Fixed
.build()) { | ||
|
||
int offsets[] = {0, 1, 2, 3, 4, 5, 5}; | ||
// The last offset is repeated. This will cause an ALREADY_EXISTS error. |
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.
The convention is to place the comment above the statement. More importantly, what is an offset and what does it do? Why are we showing a repeated offset if it causes an error?
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.
Fixed
public class WriteCommittedStream { | ||
|
||
public static Status.Code getStatusCode(StatusRuntimeException e) { | ||
return e.getStatus().getCode(); |
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.
this helper method seems redundant -- we can directly write this one liner in the sample body.
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.
I removed this and simplified the exception handling.
|
||
System.out.println("Appended records successfully."); | ||
|
||
} catch (Exception e) { |
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.
Is there a more specific type of Exception we can catch here?
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.
There are several - Is it better to catch each type explicitly?
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.
Fixed - now I catch a specific type and declare others as thrown
samples/snippets/src/main/java/com/example/bigquerystorage/WritePendingStream.java
Show resolved
Hide resolved
* limitations under the License. | ||
*/ | ||
|
||
package com.example.bigquerystorage; |
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.
One test class per sample class please.
@Test | ||
public void testWriteCommittedStream() throws Exception { | ||
WriteCommittedStream.writeCommittedStream( | ||
GOOGLE_CLOUD_PROJECT, BIGQUERY_DATASET_NAME, BIGQUERY_TABLE_NAME); |
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.
it does not look like we are testing anything here.
we need to use Truth
to assert that we are getting desirable print output. Something like: https://github.com/googleapis/java-bigquery/blob/9945ca699eb7e439da387c40ac338a473dd9cb81/samples/snippets/src/test/java/com/example/bigquery/CopyMultipleTablesIT.java#L77
public void testWriteToDefaultStream() throws Exception { | ||
WriteCommittedStream.writeToDefaultStream( | ||
GOOGLE_CLOUD_PROJECT, BIGQUERY_DATASET_NAME, BIGQUERY_TABLE_NAME); | ||
} |
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.
see above comment and also this should be in a separate test class.
public void testWritePendingStream() throws Exception { | ||
WritePendingStream.writePendingStream( | ||
GOOGLE_CLOUD_PROJECT, BIGQUERY_DATASET_NAME, BIGQUERY_TABLE_NAME); | ||
} |
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.
see above comment and also this should be in a separate test class.
region_tag needs to be created in devrel samples tracker so that it can go on the documentation site. please let me know if you would like me to create them. |
For Java samples general guidelines, PTAL: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/SAMPLE_FORMAT.md |
Also prior to raising a PR, please:
|
Here is the summary of changes. You added 3 region tags.
This comment is generated by snippet-bot.
|
c2072e4
to
936bfb1
Compare
samples/snippets/src/main/java/com/example/bigquerystorage/WriteCommittedStream.java
Outdated
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WriteCommittedStream.java
Outdated
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WritePendingStream.java
Outdated
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WritePendingStream.java
Outdated
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WritePendingStream.java
Outdated
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WritePendingStream.java
Outdated
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java
Outdated
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java
Outdated
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java
Outdated
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WriteCommittedStream.java
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WriteCommittedStream.java
Outdated
Show resolved
Hide resolved
samples/snippets/src/main/java/com/example/bigquerystorage/WritePendingStream.java
Outdated
Show resolved
Hide resolved
Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, one of your required reviews was not approved, or there is a do not merge label. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot. |
Remove the backoff logic to keep the sample code simpler.
- Simplify code, remove duplicate-record example. - Split all snippets and tests into separate classes. - Add comments and javadocs links. - Clean up imports. - Add region tags. - Catch only specific exceptions. - Run linter and fmt-maven-plugin.
…teCommittedStream.java
…tePendingStream.java
…tePendingStream.java
…tePendingStream.java
…teToDefaultStream.java
…teToDefaultStream.java
…teToDefaultStream.java
…teToDefaultStream.java
…tePendingStream.java
…teCommittedStream.java
…teCommittedStream.java
…teCommittedStream.java
…tePendingStream.java
Create temporary dataset and table for sample integration tests
f01023f
to
edd650d
Compare
@yirutang please whitelist the devrel CI testing project
|
🤖 I have created a release \*beep\* \*boop\* --- ### [1.8.4](https://www.github.com/googleapis/java-bigquerystorage/compare/v1.8.3...v1.8.4) (2021-01-14) ### Bug Fixes * default stream integration test failures due to production expected change ([#791](https://www.github.com/googleapis/java-bigquerystorage/issues/791)) ([1c2b5c1](https://www.github.com/googleapis/java-bigquerystorage/commit/1c2b5c1ef478305fe7f3d9f1843750cec18ba9f8)) ### Documentation * **samples:** jsonstreamwriter samples ([#756](https://www.github.com/googleapis/java-bigquerystorage/issues/756)) ([929b2ce](https://www.github.com/googleapis/java-bigquerystorage/commit/929b2cea1951bbe45eea596163f9a7a74d0ab041)) ### Dependencies * update dependency com.google.cloud:google-cloud-bigquery to v1.126.6 ([#794](https://www.github.com/googleapis/java-bigquerystorage/issues/794)) ([8e68546](https://www.github.com/googleapis/java-bigquerystorage/commit/8e68546f1e86553919766f9333ad911ba7da8442)) * update dependency com.google.cloud:google-cloud-shared-dependencies to v0.18.0 ([#795](https://www.github.com/googleapis/java-bigquerystorage/issues/795)) ([86036bb](https://www.github.com/googleapis/java-bigquerystorage/commit/86036bb5caca125b38a64bd63acc5486a87b8e35)) * update protobuf ([#790](https://www.github.com/googleapis/java-bigquerystorage/issues/790)) ([792e925](https://www.github.com/googleapis/java-bigquerystorage/commit/792e925840e99033a1f194b2bfb372dae79d3d0d)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
No description provided.