Skip to content

Commit

Permalink
docs(samples): rename extract table json to extract table csv (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejdarrow committed Jun 4, 2020
1 parent b3b280c commit c1f21e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
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

0 comments on commit c1f21e6

Please sign in to comment.