Skip to content
Permalink
Browse files
docs(samples): rename extract table json to extract table csv (#415)
  • Loading branch information
ejdarrow committed Jun 4, 2020
1 parent b3b280c commit c1f21e6c16df40bb3c71610f9d5b4fb4855b28fb
@@ -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";
@@ -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 {
@@ -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());
}
@@ -26,7 +26,7 @@
import org.junit.BeforeClass;
import org.junit.Test;

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

@@ -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.");

0 comments on commit c1f21e6

Please sign in to comment.