Skip to content
Permalink
Browse files
docs(samples): Update region tag for create table external hive parti…
…tioning (#1079)

* docs(samples): updates region tag and file name

* docs(samples): updates region tag and file name

* docs(samples): updates class name
  • Loading branch information
steffnay committed Jan 29, 2021
1 parent 2890c80 commit 50bf7831d9a7fe40ae08894d50fd2c8ae974f05a
@@ -16,6 +16,7 @@

package com.example.bigquery;

// [START bigquery_create_table_external_hivepartitioned]
// [START bigquery_set_hivepartitioningoptions]
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryException;
@@ -27,7 +28,7 @@
import com.google.cloud.bigquery.TableInfo;

// Sample to create external table using hive partitioning
public class SetHivePartitioningOptions {
public class CreateTableExternalHivePartitioned {

public static void main(String[] args) {
// TODO(developer): Replace these variables before running the sample.
@@ -36,10 +37,10 @@ public static void main(String[] args) {
String sourceUri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/customlayout/*";
String sourceUriPrefix =
"gs://cloud-samples-data/bigquery/hive-partitioning-samples/customlayout/{pkey:STRING}/";
setHivePartitioningOptions(datasetName, tableName, sourceUriPrefix, sourceUri);
createTableExternalHivePartitioned(datasetName, tableName, sourceUriPrefix, sourceUri);
}

public static void setHivePartitioningOptions(
public static void createTableExternalHivePartitioned(
String datasetName, String tableName, String sourceUriPrefix, String sourceUri) {
try {
// Initialize client that will be used to send requests. This client only needs to be created
@@ -68,3 +69,4 @@ public static void setHivePartitioningOptions(
}
}
// [END bigquery_set_hivepartitioningoptions]
// [END bigquery_create_table_external_hivepartitioned]
@@ -29,7 +29,7 @@
import org.junit.BeforeClass;
import org.junit.Test;

public class SetHivePartitioningOptionsIT {
public class CreateTableExternalHivePartitionedIT {

private static final String ID = UUID.randomUUID().toString().substring(0, 8);
private final Logger log = Logger.getLogger(this.getClass().getName());
@@ -74,11 +74,11 @@ public void tearDown() {
}

@Test
public void testSetHivePartitioningOptions() {
public void testCreateTableExternalHivePartitioned() {
String sourceUri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/customlayout/*";
String sourceUriPrefix =
"gs://cloud-samples-data/bigquery/hive-partitioning-samples/customlayout/{pkey:STRING}/";
SetHivePartitioningOptions.setHivePartitioningOptions(
CreateTableExternalHivePartitioned.createTableExternalHivePartitioned(
BIGQUERY_DATASET_NAME, tableName, sourceUriPrefix, sourceUri);
assertThat(bout.toString()).contains("External table created using hivepartitioningoptions");
}

0 comments on commit 50bf783

Please sign in to comment.