Skip to content

Commit

Permalink
fix: SearchStats IndexUnusedReasons null bug
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan0102 committed Aug 17, 2023
1 parent eb250a8 commit f079289
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Expand Up @@ -68,7 +68,7 @@ SearchStatistics toPb() {
searchStatistics.setIndexUsageMode(getIndexUsageMode());
}
if (getIndexUnusedReasons() != null) {
searchStatistics.setIndexUnusedReason(
searchStatistics.setIndexUnusedReasons(
getIndexUnusedReasons().stream()
.map(IndexUnusedReason::toPb)
.collect(Collectors.toList()));
Expand All @@ -81,9 +81,9 @@ static SearchStats fromPb(SearchStatistics searchStatistics) {
if (searchStatistics.getIndexUsageMode() != null) {
builder.setIndexUsageMode(searchStatistics.getIndexUsageMode());
}
if (searchStatistics.getIndexUnusedReason() != null) {
if (searchStatistics.getIndexUnusedReasons() != null) {
builder.setIndexUnusedReasons(
searchStatistics.getIndexUnusedReason().stream()
searchStatistics.getIndexUnusedReasons().stream()
.map(IndexUnusedReason::fromPb)
.collect(Collectors.toList()));
}
Expand Down
Expand Up @@ -5090,7 +5090,7 @@ public void testQueryJobWithLabels() throws InterruptedException, TimeoutExcepti
}

@Test
public void testQueryJobWithSearchReturnsSearchStatistics() throws InterruptedException {
public void testQueryJobWithSearchReturnsSearchStatisticsUnused() throws InterruptedException {
String tableName = "test_query_job_table";
String query =
"SELECT * FROM "
Expand All @@ -5109,6 +5109,10 @@ public void testQueryJobWithSearchReturnsSearchStatistics() throws InterruptedEx
JobStatistics.QueryStatistics stats = remoteJob.getStatistics();
assertNotNull(stats.getSearchStats());
assertEquals(stats.getSearchStats().getIndexUsageMode(), "UNUSED");
assertNotNull(stats.getSearchStats().getIndexUnusedReasons());
assertNotNull(
stats.getSearchStats().getIndexUnusedReasons().get(0).getCode(),
"INDEX_CONFIG_NOT_AVAILABLE");
} finally {
bigquery.delete(destinationTable);
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -54,7 +54,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<github.global.server>github</github.global.server>
<site.installationModule>google-cloud-bigquery-parent</site.installationModule>
<google-api-services-bigquery.version>v2-rev20230520-2.0.0</google-api-services-bigquery.version>
<google-api-services-bigquery.version>v2-rev20230805-2.0.0</google-api-services-bigquery.version>
<google.cloud.shared-dependencies.version>3.13.1</google.cloud.shared-dependencies.version>
<arrow.version>12.0.1</arrow.version>
</properties>
Expand Down

0 comments on commit f079289

Please sign in to comment.