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): Update region tag for create table external hive partitioning #1079

Merged
merged 3 commits into from Jan 29, 2021
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 @@ -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;
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -68,3 +69,4 @@ public static void setHivePartitioningOptions(
}
}
// [END bigquery_set_hivepartitioningoptions]
// [END bigquery_create_table_external_hivepartitioned]
Expand Up @@ -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());
Expand Down Expand Up @@ -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");
}
Expand Down