Skip to content

Commit 8c4f847

Browse files
committed
Merge branch 'main' into PR #3942 to update
2 parents 5d21d88 + cbd5d23 commit 8c4f847

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7181,8 +7181,12 @@ public void testStatelessQueries() throws InterruptedException {
71817181
// Stateless query should have no job id.
71827182
bigQuery.getOptions().setDefaultJobCreationMode(JobCreationMode.JOB_CREATION_OPTIONAL);
71837183
TableResult tableResult = executeSimpleQuery(bigQuery);
7184-
assertNotNull(tableResult.getQueryId());
7185-
assertNull(tableResult.getJobId());
7184+
// Use XOR: We accept EITHER a QueryId (fast path) OR a JobId (slow fallback), but not both.
7185+
// Ideally Stateless query will return queryId but in some cases it would return jobId instead
7186+
// of queryId based on the query complexity or other factors (job timeout configs).
7187+
assertTrue(
7188+
"Exactly one of jobId or queryId should be non-null",
7189+
(tableResult.getJobId() != null) ^ (tableResult.getQueryId() != null));
71867190

71877191
// Job creation takes over, no query id is created.
71887192
bigQuery.getOptions().setDefaultJobCreationMode(JobCreationMode.JOB_CREATION_REQUIRED);
@@ -7220,8 +7224,14 @@ public void testTableResultJobIdAndQueryId() throws InterruptedException {
72207224
String query = "SELECT 1 as one";
72217225
QueryJobConfiguration configStateless = QueryJobConfiguration.newBuilder(query).build();
72227226
TableResult result = bigQuery.query(configStateless);
7223-
assertNull(result.getJobId());
7224-
assertNotNull(result.getQueryId());
7227+
// A stateless query should result in either a queryId (stateless success) or a jobId (fallback
7228+
// to a job).
7229+
// Exactly one of them should be non-null.
7230+
// Ideally Stateless query will return queryId but in some cases it would return jobId instead
7231+
// of queryId based on the query complexity or other factors (job timeout configs).
7232+
assertTrue(
7233+
"Exactly one of jobId or queryId should be non-null",
7234+
(result.getJobId() != null) ^ (result.getQueryId() != null));
72257235

72267236
// Test scenario 2 by failing stateless check by setting job timeout.
72277237
QueryJobConfiguration configQueryWithJob =

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@
172172
<ignoredUnusedDeclaredDependency>io.netty:netty-common</ignoredUnusedDeclaredDependency>
173173
<ignoredUnusedDeclaredDependency>org.apache.arrow:arrow-memory-netty</ignoredUnusedDeclaredDependency>
174174
<ignoredUnusedDeclaredDependency>com.google.api:gax</ignoredUnusedDeclaredDependency>
175+
<!-- maven-dependency-plugin cannot detect the runtime usage of junit-jupiter-engine for executing JUnit 5+ tests. -->
176+
<ignoredUnusedDeclaredDependency>org.junit.jupiter:junit-jupiter-engine</ignoredUnusedDeclaredDependency>
175177
</ignoredUnusedDeclaredDependencies>
176178
</configuration>
177179
</plugin>

0 commit comments

Comments
 (0)