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

Added a snippet to show how to read a newline-delimited-json file and store it in a Table #2974

Merged
merged 8 commits into from
Mar 12, 2018

Conversation

happyhuman
Copy link

No description provided.

@happyhuman happyhuman requested a review from pongad as a code owner February 28, 2018 18:48
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 28, 2018
.build();
// Table field definition
ArrayList<Field> fields = new ArrayList<>();
for (String fieldName: fieldNames) {

This comment was marked as spam.

This comment was marked as spam.

fields.add(Field.of(fieldName, LegacySQLTypeName.STRING));
}
// Table schema definition
Schema schema = Schema.of(fields.toArray(new Field[fields.size()]));

This comment was marked as spam.

This comment was marked as spam.

@pongad pongad requested a review from tswast March 1, 2018 03:24
Schema schema = Schema.of(fields.toArray(new Field[fields.size()]));
// Create the table
StandardTableDefinition tableDefinition = StandardTableDefinition.of(schema);
bigquery.create(TableInfo.of(tableId, tableDefinition));

This comment was marked as spam.

This comment was marked as spam.

// [TARGET writer(WriteChannelConfiguration)]
// [VARIABLE "my_dataset_name"]
// [VARIABLE "my_table_name"]
// [VARIABLE "my_source_uri")]

This comment was marked as spam.

This comment was marked as spam.

// [VARIABLE "my_dataset_name"]
// [VARIABLE "my_table_name"]
// [VARIABLE "my_source_uri")]
// [VARIABLE "field_names")]

This comment was marked as spam.

This comment was marked as spam.

@happyhuman
Copy link
Author

After talking to Tim, I made some changes. Can you please review the changes? Thanks.

Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Sample LGTM, thanks.

@tswast
Copy link
Contributor

tswast commented Mar 6, 2018

Sorry I forgot about this earlier, but there's also a Python script to run which will ensure this sample gets included in the Javadocs for the library. The script is at https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/utilities/add_snippets_to_file.py

@@ -524,6 +524,19 @@ public int hashCode() {
* }
* } </pre>
*
* <p>Example of creating a dataset.

This comment was marked as spam.

* String query =
* "SELECT distinct(corpus) FROM `bigquery-public-data.samples.shakespeare` where word_count > ?";
* <pre> {@code
* String query = "SELECT distinct(corpus) FROM `bigquery-public-data.samples.shakespeare` where;

This comment was marked as spam.

Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Thanks!

Let's clean up some of the Javadoc strings in BigQuery.java manually and call this one done. I don't know what went wrong with the script.

@pongad pongad merged commit 848245e into master Mar 12, 2018
@pongad pongad deleted the bq_remote_file_import branch March 12, 2018 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants