Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,6 @@ class ITBigQueryTest {
private static final TableId TABLE_ID = TableId.of(DATASET, "testing_table");
private static final TableId TABLE_ID_DDL = TableId.of(DATASET, "ddl_testing_table");
private static final TableId TABLE_ID_FASTQUERY = TableId.of(DATASET, "fastquery_testing_table");
private static final TableId TABLE_ID_FASTQUERY_UK =
TableId.of(UK_DATASET, "fastquery_testing_table");
private static final TableId TABLE_ID_LARGE = TableId.of(DATASET, "large_data_testing_table");
private static final TableId TABLE_ID_FASTQUERY_BQ_RESULTSET =
TableId.of(DATASET, "fastquery_testing_bq_resultset");
Expand Down Expand Up @@ -3503,8 +3501,13 @@ void testLosslessTimestamp() throws InterruptedException {
void testQuery() throws InterruptedException {
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
QueryJobConfiguration config =
QueryJobConfiguration.newBuilder(query).setDefaultDataset(DatasetId.of(DATASET)).build();
QueryJobConfiguration.newBuilder(query)
.setUseQueryCache(false)
.setDefaultDataset(DatasetId.of(DATASET))
.build();
Job job = bigquery.create(JobInfo.of(JobId.of(), config));
job = job.waitFor();
assertNotNull(job);

TableResult result = job.getQueryResults();
assertNotNull(result.getJobId());
Expand All @@ -3527,6 +3530,7 @@ void testQuery() throws InterruptedException {
}
assertEquals(2, rowCount);

// Query Plan will exist for a completed job
Job job2 = bigquery.getJob(job.getJobId());
JobStatistics.QueryStatistics statistics = job2.getStatistics();
assertNotNull(statistics.getQueryPlan());
Expand Down Expand Up @@ -4663,6 +4667,7 @@ void testProjectIDFastSQLQueryWithJobId() throws InterruptedException {

@Test
void testLocationFastSQLQueryWithJobId() throws InterruptedException {
TableId tableIdFastQueryUk = TableId.of(UK_DATASET, "fastquery_testing_table");
DatasetInfo infoUK =
DatasetInfo.newBuilder(UK_DATASET)
.setDescription(DESCRIPTION)
Expand All @@ -4672,11 +4677,11 @@ void testLocationFastSQLQueryWithJobId() throws InterruptedException {
bigquery.create(infoUK);

TableDefinition tableDefinition = StandardTableDefinition.of(SIMPLE_SCHEMA);
TableInfo tableInfo = TableInfo.newBuilder(TABLE_ID_FASTQUERY_UK, tableDefinition).build();
TableInfo tableInfo = TableInfo.newBuilder(tableIdFastQueryUk, tableDefinition).build();
bigquery.create(tableInfo);

String insert =
"INSERT " + UK_DATASET + "." + TABLE_ID_FASTQUERY_UK.getTable() + " VALUES('Anna');";
"INSERT " + UK_DATASET + "." + tableIdFastQueryUk.getTable() + " VALUES('Anna');";

QueryJobConfiguration config =
QueryJobConfiguration.newBuilder(insert)
Expand All @@ -4685,10 +4690,12 @@ void testLocationFastSQLQueryWithJobId() throws InterruptedException {
TableResult result = bigquery.query(config);
assertNotNull(result.getJobId());
assertEquals(SIMPLE_SCHEMA, result.getSchema());
assertEquals(1, result.getTotalRows());
assertNull(result.getNextPage());
assertNull(result.getNextPageToken());
assertFalse(result.hasNextPage());
// Use `getNumDmlAffectedRows()` for DML operations
Job queryJob = bigquery.getJob(result.getJobId());
queryJob = queryJob.waitFor();
JobStatistics.QueryStatistics statistics = queryJob.getStatistics();
assertEquals(1L, statistics.getNumDmlAffectedRows().longValue());

// Verify correctness of table content
for (FieldValueList row : result.getValues()) {
FieldValue stringCell = row.get(0);
Expand All @@ -4698,7 +4705,7 @@ void testLocationFastSQLQueryWithJobId() throws InterruptedException {
// With incorrect location in jobid
// The job will be created with the specified(incorrect) location
// hence failing the operation
String query = "SELECT StringField FROM " + TABLE_ID_FASTQUERY_UK.getTable();
String query = "SELECT StringField FROM " + tableIdFastQueryUk.getTable();
JobId jobIdWithLocation = JobId.newBuilder().setLocation("us-west1").build();
QueryJobConfiguration configSelect =
QueryJobConfiguration.newBuilder(query).setDefaultDataset(DatasetId.of(UK_DATASET)).build();
Expand Down Expand Up @@ -5726,8 +5733,10 @@ void testListJobsWithCreationBounding() {

@Test
void testCreateAndGetJob() throws InterruptedException, TimeoutException {
String sourceTableName = "test_create_and_get_job_source_table";
String destinationTableName = "test_create_and_get_job_destination_table";
String sourceTableName =
"test_create_and_get_job_source_table" + UUID.randomUUID().toString().substring(0, 8);
String destinationTableName =
"test_create_and_get_job_destination_table" + UUID.randomUUID().toString().substring(0, 8);
TableId sourceTable = TableId.of(DATASET, sourceTableName);
StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
TableInfo tableInfo = TableInfo.of(sourceTable, tableDefinition);
Expand Down Expand Up @@ -5784,8 +5793,12 @@ void testCreateJobAndWaitForWithRetryOptions() throws InterruptedException, Time

@Test
void testCreateAndGetJobWithSelectedFields() throws InterruptedException, TimeoutException {
String sourceTableName = "test_create_and_get_job_with_selected_fields_source_table";
String destinationTableName = "test_create_and_get_job_with_selected_fields_destination_table";
String sourceTableName =
"test_create_and_get_job_with_selected_fields_source_table"
+ UUID.randomUUID().toString().substring(0, 8);
String destinationTableName =
"test_create_and_get_job_with_selected_fields_destination_table"
+ UUID.randomUUID().toString().substring(0, 8);
TableId sourceTable = TableId.of(DATASET, sourceTableName);
StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
TableInfo tableInfo = TableInfo.of(sourceTable, tableDefinition);
Expand Down Expand Up @@ -5832,8 +5845,10 @@ void testCreateAndGetJobWithSelectedFields() throws InterruptedException, Timeou

@Test
void testCopyJob() throws InterruptedException, TimeoutException {
String sourceTableName = "test_copy_job_source_table";
String destinationTableName = "test_copy_job_destination_table";
String sourceTableName =
"test_copy_job_source_table" + UUID.randomUUID().toString().substring(0, 8);
String destinationTableName =
"test_copy_job_destination_table" + UUID.randomUUID().toString().substring(0, 8);
TableId sourceTable = TableId.of(DATASET, sourceTableName);
StandardTableDefinition tableDefinition = StandardTableDefinition.of(TABLE_SCHEMA);
TableInfo tableInfo = TableInfo.of(sourceTable, tableDefinition);
Expand Down Expand Up @@ -5864,8 +5879,10 @@ void testCopyJob() throws InterruptedException, TimeoutException {

@Test
void testCopyJobStatistics() throws InterruptedException, TimeoutException {
String sourceTableName = "test_copy_job_statistics_source_table";
String destinationTableName = "test_copy_job_statistics_destination_table";
String sourceTableName =
"test_copy_job_statistics_source_table" + UUID.randomUUID().toString().substring(0, 8);
String destinationTableName =
"test_copy_job_statistics_destination_table" + UUID.randomUUID().toString().substring(0, 8);

QueryJobConfiguration createTable =
QueryJobConfiguration.newBuilder(
Expand Down Expand Up @@ -6006,7 +6023,7 @@ void testCopyJobWithLabelsAndExpTime() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
public void testQueryJob() throws InterruptedException, TimeoutException {
String tableName = "test_query_job_table";
String tableName = "test_query_job_table" + UUID.randomUUID().toString().substring(0, 8);
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
TableId destinationTable = TableId.of(DATASET, tableName);
QueryJobConfiguration configuration =
Expand Down Expand Up @@ -6052,7 +6069,8 @@ public void testQueryJob() throws InterruptedException, TimeoutException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
void testQueryJobWithConnectionProperties() throws InterruptedException {
String tableName = "test_query_job_table_connection_properties";
String tableName =
"test_query_job_table_connection_properties" + UUID.randomUUID().toString().substring(0, 8);
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
TableId destinationTable = TableId.of(DATASET, tableName);
QueryJobConfiguration configuration =
Expand All @@ -6072,7 +6090,7 @@ void testQueryJobWithConnectionProperties() throws InterruptedException {
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
void testQueryJobWithLabels() throws InterruptedException, TimeoutException {
String tableName = "test_query_job_table";
String tableName = "test_query_job_table" + UUID.randomUUID().toString().substring(0, 8);
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
Map<String, String> labels = ImmutableMap.of("test-job-name", "test-query-job");
TableId destinationTable = TableId.of(DATASET, tableName);
Expand All @@ -6095,11 +6113,9 @@ void testQueryJobWithLabels() throws InterruptedException, TimeoutException {

@Test
void testQueryJobWithSearchReturnsSearchStatisticsUnused() throws InterruptedException {
String tableName = "test_query_job_table";
String tableName = "test_query_job_table" + UUID.randomUUID().toString().substring(0, 8);
String query =
"SELECT * FROM "
+ TABLE_ID.getTable()
+ " WHERE search(StringField, \"stringValue\")";
"SELECT * FROM " + TABLE_ID.getTable() + " WHERE search(StringField, \"stringValue\")";
TableId destinationTable = TableId.of(DATASET, tableName);
try {
QueryJobConfiguration configuration =
Expand All @@ -6125,7 +6141,8 @@ void testQueryJobWithSearchReturnsSearchStatisticsUnused() throws InterruptedExc
/* TODO(prasmish): replicate the entire test case for executeSelect */
@Test
void testQueryJobWithRangePartitioning() throws InterruptedException {
String tableName = "test_query_job_table_rangepartitioning";
String tableName =
"test_query_job_table_rangepartitioning" + UUID.randomUUID().toString().substring(0, 8);
String query =
"SELECT IntegerField, TimestampField, StringField, BooleanField FROM "
+ TABLE_ID.getTable();
Expand All @@ -6150,7 +6167,8 @@ void testQueryJobWithRangePartitioning() throws InterruptedException {

@Test
void testLoadJobWithRangePartitioning() throws InterruptedException {
String tableName = "test_load_job_table_rangepartitioning";
String tableName =
"test_load_job_table_rangepartitioning" + UUID.randomUUID().toString().substring(0, 8);
TableId destinationTable = TableId.of(DATASET, tableName);
try {
LoadJobConfiguration configuration =
Expand All @@ -6174,7 +6192,9 @@ void testLoadJobWithRangePartitioning() throws InterruptedException {

@Test
void testLoadJobWithDecimalTargetTypes() throws InterruptedException {
String tableName = "test_load_job_table_parquet_decimalTargetTypes";
String tableName =
"test_load_job_table_parquet_decimalTargetTypes"
+ UUID.randomUUID().toString().substring(0, 8);
TableId destinationTable = TableId.of(DATASET, tableName);
String sourceUri = "gs://" + CLOUD_SAMPLES_DATA + "/bigquery/numeric/numeric_38_12.parquet";
try {
Expand Down Expand Up @@ -6202,7 +6222,9 @@ void testLoadJobWithDecimalTargetTypes() throws InterruptedException {

@Test
void testExternalTableWithDecimalTargetTypes() throws InterruptedException {
String tableName = "test_create_external_table_parquet_decimalTargetTypes";
String tableName =
"test_create_external_table_parquet_decimalTargetTypes"
+ UUID.randomUUID().toString().substring(0, 8);
TableId destinationTable = TableId.of(DATASET, tableName);
String sourceUri = "gs://" + CLOUD_SAMPLES_DATA + "/bigquery/numeric/numeric_38_12.parquet";
ExternalTableDefinition externalTableDefinition =
Expand All @@ -6222,7 +6244,7 @@ void testExternalTableWithDecimalTargetTypes() throws InterruptedException {

@Test
void testQueryJobWithDryRun() throws InterruptedException, TimeoutException {
String tableName = "test_query_job_table";
String tableName = "test_query_job_table" + UUID.randomUUID().toString().substring(0, 8);
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
TableId destinationTable = TableId.of(DATASET, tableName);
QueryJobConfiguration configuration =
Expand All @@ -6240,7 +6262,7 @@ void testQueryJobWithDryRun() throws InterruptedException, TimeoutException {

@Test
void testExtractJob() throws InterruptedException, TimeoutException {
String tableName = "test_export_job_table";
String tableName = "test_export_job_table" + UUID.randomUUID().toString().substring(0, 8);
TableId destinationTable = TableId.of(DATASET, tableName);
Map<String, String> labels = ImmutableMap.of("test-job-name", "test-load-extract-job");
LoadJobConfiguration configuration =
Expand Down Expand Up @@ -6317,7 +6339,7 @@ void testExtractJobWithModel() throws InterruptedException {

@Test
void testExtractJobWithLabels() throws InterruptedException, TimeoutException {
String tableName = "test_export_job_table_label";
String tableName = "test_export_job_table_label" + UUID.randomUUID().toString().substring(0, 8);
Map<String, String> labels = ImmutableMap.of("test_job_name", "test_export_job");
TableId destinationTable = TableId.of(DATASET, tableName);
LoadJobConfiguration configuration =
Expand All @@ -6343,7 +6365,8 @@ void testExtractJobWithLabels() throws InterruptedException, TimeoutException {

@Test
void testCancelJob() throws InterruptedException, TimeoutException {
String destinationTableName = "test_cancel_query_job_table";
String destinationTableName =
"test_cancel_query_job_table" + UUID.randomUUID().toString().substring(0, 8);
String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
TableId destinationTable = TableId.of(DATASET, destinationTableName);
QueryJobConfiguration configuration =
Expand Down Expand Up @@ -6625,7 +6648,9 @@ void testWriteChannelPreserveAsciiControlCharacters()

@Test
void testLoadJobPreserveAsciiControlCharacters() throws InterruptedException {
String destinationTableName = "test_load_job_preserve_ascii_control_characters";
String destinationTableName =
"test_load_job_preserve_ascii_control_characters"
+ UUID.randomUUID().toString().substring(0, 8);
TableId destinationTable = TableId.of(DATASET, destinationTableName);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void testConnectionClose() throws SQLException {
while (rs.next()) {
++cnt;
if (cnt == 50000) { // interrupt at 50K
assertTrue(connection.close());
break;
}
}
assertTrue(LIMIT_RECS > cnt);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
Loading