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

docs(samples): rename extract table json to extract table csv #415

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -26,9 +26,9 @@
import com.google.cloud.bigquery.TableId;
import org.threeten.bp.Duration;

public class ExtractTableToJson {
public class ExtractTableToCsv {

public static void runExtractTableToJson() {
public static void runExtractTableToCsv() {
// TODO(developer): Replace these variables before running the sample.
String projectId = "bigquery-public-data";
String datasetName = "samples";
Expand All @@ -41,11 +41,11 @@ public static void runExtractTableToJson() {
// https://googleapis.dev/java/google-cloud-clients/latest/index.html?com/google/cloud/bigquery/package-summary.html

String dataFormat = "CSV";
extractTableToJson(projectId, datasetName, tableName, destinationUri, dataFormat);
extractTableToCsv(projectId, datasetName, tableName, destinationUri, dataFormat);
}

// Exports datasetName:tableName to destinationUri as raw CSV
public static void extractTableToJson(
public static void extractTableToCsv(
String projectId, String datasetName, String tableName, String destinationUri,
String dataFormat) {
try {
Expand All @@ -71,7 +71,8 @@ public static void extractTableToJson(
"BigQuery was unable to extract due to an error: \n" + job.getStatus().getError());
return;
}
System.out.println("Table export successful. Check in GCS bucket for the " + dataFormat + " file.");
System.out.println("Table export successful. Check in GCS bucket for the " +
dataFormat + " file.");
} catch (BigQueryException | InterruptedException e) {
System.out.println("Table extraction job was interrupted. \n" + e.toString());
}
Expand Down
Expand Up @@ -26,7 +26,7 @@
import org.junit.BeforeClass;
import org.junit.Test;

public class ExtractTableToJsonIT {
public class ExtractTableToCsvIT {
private ByteArrayOutputStream bout;
private PrintStream out;

Expand Down Expand Up @@ -64,7 +64,7 @@ public void testExtractTableToJson() {
String dataFormat = "CSV";

// Extract table content to GCS in CSV format
ExtractTableToJson.extractTableToJson(projectId, datasetName, tableName, destinationUri,
ExtractTableToCsv.extractTableToCsv(projectId, datasetName, tableName, destinationUri,
dataFormat);
assertThat(bout.toString())
.contains("Table export successful. Check in GCS bucket for the " + dataFormat + " file.");
Expand Down