) value;
}
+ /**
+ * Returns this field's value as a {@link org.threeten.extra.PeriodDuration}. This method should
+ * be used if the corresponding field has {@link StandardSQLTypeName#INTERVAL} type, or if it is a
+ * legal canonical format "[sign]Y-M [sign]D [sign]H:M:S[.F]", e.g. "123-7 -19 0:24:12.000006" or
+ * ISO 8601.
+ *
+ * @throws ClassCastException if the field is not a primitive type
+ * @throws NullPointerException if {@link #isNull()} returns {@code true}
+ * @throws IllegalArgumentException if the field cannot be converted to a legal interval
+ */
+ @SuppressWarnings("unchecked")
+ public PeriodDuration getPeriodDuration() {
+ checkNotNull(value);
+ try {
+ // Try parsing from ISO 8601
+ return PeriodDuration.parse(getStringValue());
+ } catch (DateTimeParseException dateTimeParseException) {
+ // Try parsing from canonical interval format
+ return parseCanonicalInterval(getStringValue());
+ }
+ }
+
/**
* Returns this field's value as a {@link FieldValueList} instance. This method should only be
* used if the corresponding field has {@link LegacySQLTypeName#RECORD} type (i.e. {@link
@@ -325,4 +353,63 @@ static FieldValue fromPb(Object cellPb, Field recordSchema) {
}
throw new IllegalArgumentException("Unexpected table cell format");
}
+
+ /**
+ * Parse interval in canonical format and create instance of {@code PeriodDuration}.
+ *
+ * The parameter {@code interval} should be an interval in the canonical format: "[sign]Y-M
+ * [sign]D [sign]H:M:S[.F]". More details
+ * here
+ *
+ * @throws IllegalArgumentException if the {@code interval} is not a valid interval
+ */
+ static PeriodDuration parseCanonicalInterval(String interval) throws IllegalArgumentException {
+ // Pattern is [sign]Y-M [sign]D [sign]H:M:S[.F]
+ Pattern pattern =
+ Pattern.compile(
+ "(?[+-])?(?\\d+)-(?\\d+) (?[-|+])?(?\\d+) (?[-|+])?(?\\d+):(?\\d+):(?\\d+)(\\.(?\\d+))?");
+ Matcher matcher = pattern.matcher(interval);
+ if (!matcher.find()) {
+ throw new IllegalArgumentException();
+ }
+ String sign1 = matcher.group("sign1");
+ String year = matcher.group("year");
+ String month = matcher.group("month");
+ String sign2 = matcher.group("sign2");
+ String day = matcher.group("day");
+ String sign3 = matcher.group("sign3");
+ String hours = matcher.group("hours");
+ String minutes = matcher.group("minutes");
+ String seconds = matcher.group("seconds");
+ String fraction = matcher.group("fraction");
+
+ int yearInt = Integer.parseInt(year);
+ int monthInt = Integer.parseInt(month);
+ if (Objects.equals(sign1, "-")) {
+ yearInt *= -1;
+ monthInt *= -1;
+ }
+
+ int dayInt = Integer.parseInt(day);
+ if (Objects.equals(sign2, "-")) {
+ dayInt *= -1;
+ }
+ if (sign3 == null) {
+ sign3 = "";
+ }
+
+ String durationString =
+ sign3
+ + "PT"
+ + hours
+ + "H"
+ + minutes
+ + "M"
+ + seconds
+ + (fraction == null ? "" : "." + fraction)
+ + "S";
+
+ return PeriodDuration.of(Period.of(yearInt, monthInt, dayInt), Duration.parse(durationString));
+ }
}
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/IndexUnusedReason.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/IndexUnusedReason.java
index 06a88b068..bb4f0c3c3 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/IndexUnusedReason.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/IndexUnusedReason.java
@@ -16,7 +16,6 @@
package com.google.cloud.bigquery;
-import com.google.api.services.bigquery.model.TableReference;
import com.google.auto.value.AutoValue;
import java.io.Serializable;
import javax.annotation.Nullable;
@@ -52,9 +51,9 @@ public abstract static class Builder {
/**
* Specifies the base table involved in the reason that no search index was used.
*
- * @param tableReference tableReference or {@code null} for none
+ * @param baseTable baseTable or {@code null} for none
*/
- public abstract Builder setBaseTable(TableReference tableReference);
+ public abstract Builder setBaseTableId(TableId baseTable);
/** Creates a @code IndexUnusedReason} object. */
public abstract IndexUnusedReason build();
@@ -96,7 +95,7 @@ public static Builder newBuilder() {
* @return value or {@code null} for none
*/
@Nullable
- public abstract TableReference getBaseTable();
+ public abstract TableId getBaseTableId();
com.google.api.services.bigquery.model.IndexUnusedReason toPb() {
com.google.api.services.bigquery.model.IndexUnusedReason indexUnusedReason =
@@ -110,8 +109,8 @@ com.google.api.services.bigquery.model.IndexUnusedReason toPb() {
if (getMessage() != null) {
indexUnusedReason.setMessage(indexUnusedReason.getMessage());
}
- if (getBaseTable() != null) {
- indexUnusedReason.setBaseTable(indexUnusedReason.getBaseTable());
+ if (getBaseTableId() != null) {
+ indexUnusedReason.setBaseTable(getBaseTableId().toPb());
}
return indexUnusedReason;
}
@@ -129,7 +128,7 @@ static IndexUnusedReason fromPb(
builder.setMessage(indexUnusedReason.getMessage());
}
if (indexUnusedReason.getBaseTable() != null) {
- builder.setBaseTable(indexUnusedReason.getBaseTable());
+ builder.setBaseTableId(TableId.fromPb(indexUnusedReason.getBaseTable()));
}
return builder.build();
}
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/SearchStats.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/SearchStats.java
index 73b812383..237b83ca7 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/SearchStats.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/SearchStats.java
@@ -68,7 +68,7 @@ SearchStatistics toPb() {
searchStatistics.setIndexUsageMode(getIndexUsageMode());
}
if (getIndexUnusedReasons() != null) {
- searchStatistics.setIndexUnusedReason(
+ searchStatistics.setIndexUnusedReasons(
getIndexUnusedReasons().stream()
.map(IndexUnusedReason::toPb)
.collect(Collectors.toList()));
@@ -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()));
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetInfoTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetInfoTest.java
index 453701e3a..c91cbc2f3 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetInfoTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetInfoTest.java
@@ -58,6 +58,12 @@ public class DatasetInfoTest {
private static final DatasetId DATASET_ID_COMPLETE = DatasetId.of("project", "dataset");
private static final EncryptionConfiguration DATASET_ENCRYPTION_CONFIGURATION =
EncryptionConfiguration.newBuilder().setKmsKeyName("KMS_KEY_1").build();
+
+ private static final ExternalDatasetReference EXTERNAL_DATASET_REFERENCE =
+ ExternalDatasetReference.newBuilder()
+ .setExternalSource("source")
+ .setConnection("connection")
+ .build();
private static final DatasetInfo DATASET_INFO =
DatasetInfo.newBuilder(DATASET_ID)
.setAcl(ACCESS_RULES)
@@ -82,6 +88,8 @@ public class DatasetInfoTest {
.build();
private static final DatasetInfo DATASET_INFO_COMPLETE_WITH_IAM_MEMBER =
DATASET_INFO.toBuilder().setAcl(ACCESS_RULES_IAM_MEMBER).build();
+ private static final DatasetInfo DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE =
+ DATASET_INFO.toBuilder().setExternalDatasetReference(EXTERNAL_DATASET_REFERENCE).build();
@Test
public void testToBuilder() {
@@ -108,6 +116,28 @@ public void testToBuilderIncomplete() {
assertEquals(datasetInfo, datasetInfo.toBuilder().build());
}
+ @Test
+ public void testToBuilderWithExternalDatasetReference() {
+ compareDatasets(
+ DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE,
+ DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE.toBuilder().build());
+
+ ExternalDatasetReference externalDatasetReference =
+ ExternalDatasetReference.newBuilder()
+ .setExternalSource("source2")
+ .setConnection("connection2")
+ .build();
+ DatasetInfo datasetInfo =
+ DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE
+ .toBuilder()
+ .setExternalDatasetReference(externalDatasetReference)
+ .build();
+ assertEquals(externalDatasetReference, datasetInfo.getExternalDatasetReference());
+ datasetInfo =
+ datasetInfo.toBuilder().setExternalDatasetReference(EXTERNAL_DATASET_REFERENCE).build();
+ compareDatasets(DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE, datasetInfo);
+ }
+
@Test
public void testBuilder() {
assertNull(DATASET_INFO.getDatasetId().getProject());
@@ -137,6 +167,9 @@ public void testBuilder() {
assertEquals(LOCATION, DATASET_INFO_COMPLETE.getLocation());
assertEquals(SELF_LINK, DATASET_INFO_COMPLETE.getSelfLink());
assertEquals(LABELS, DATASET_INFO_COMPLETE.getLabels());
+ assertEquals(
+ EXTERNAL_DATASET_REFERENCE,
+ DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE.getExternalDatasetReference());
}
@Test
@@ -156,6 +189,7 @@ public void testOf() {
assertNull(datasetInfo.getDefaultEncryptionConfiguration());
assertNull(datasetInfo.getDefaultPartitionExpirationMs());
assertTrue(datasetInfo.getLabels().isEmpty());
+ assertNull(datasetInfo.getExternalDatasetReference());
datasetInfo = DatasetInfo.of(DATASET_ID);
assertEquals(DATASET_ID, datasetInfo.getDatasetId());
@@ -172,11 +206,15 @@ public void testOf() {
assertNull(datasetInfo.getDefaultEncryptionConfiguration());
assertNull(datasetInfo.getDefaultPartitionExpirationMs());
assertTrue(datasetInfo.getLabels().isEmpty());
+ assertNull(datasetInfo.getExternalDatasetReference());
}
@Test
public void testToPbAndFromPb() {
compareDatasets(DATASET_INFO_COMPLETE, DatasetInfo.fromPb(DATASET_INFO_COMPLETE.toPb()));
+ compareDatasets(
+ DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE,
+ DatasetInfo.fromPb(DATASET_INFO_COMPLETE_WITH_EXTERNAL_DATASET_REFERENCE.toPb()));
DatasetInfo datasetInfo = DatasetInfo.newBuilder("project", "dataset").build();
compareDatasets(datasetInfo, DatasetInfo.fromPb(datasetInfo.toPb()));
}
@@ -204,5 +242,6 @@ private void compareDatasets(DatasetInfo expected, DatasetInfo value) {
expected.getDefaultEncryptionConfiguration(), value.getDefaultEncryptionConfiguration());
assertEquals(
expected.getDefaultPartitionExpirationMs(), value.getDefaultPartitionExpirationMs());
+ assertEquals(expected.getExternalDatasetReference(), value.getExternalDatasetReference());
}
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetTest.java
index d1c97a694..b244cf260 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/DatasetTest.java
@@ -83,6 +83,11 @@ public class DatasetTest {
TableInfo.newBuilder(
TableId.of(NEW_PROJECT_ID, "dataset", "table3"), EXTERNAL_TABLE_DEFINITION)
.build();
+ private static final ExternalDatasetReference EXTERNAL_DATASET_REFERENCE =
+ ExternalDatasetReference.newBuilder()
+ .setExternalSource("source")
+ .setConnection("connection")
+ .build();
@Rule public MockitoRule rule;
@@ -319,6 +324,31 @@ public void testToAndFromPb() {
compareDataset(expectedDataset, Dataset.fromPb(bigquery, expectedDataset.toPb()));
}
+ @Test
+ public void testExternalDatasetReference() {
+ Dataset datasetWithExternalDatasetReference =
+ new Dataset.Builder(bigquery, DATASET_ID)
+ .setAcl(ACCESS_RULES)
+ .setCreationTime(CREATION_TIME)
+ .setDefaultTableLifetime(DEFAULT_TABLE_EXPIRATION)
+ .setDescription(DESCRIPTION)
+ .setEtag(ETAG)
+ .setFriendlyName(FRIENDLY_NAME)
+ .setGeneratedId(GENERATED_ID)
+ .setLastModified(LAST_MODIFIED)
+ .setLocation(LOCATION)
+ .setSelfLink(SELF_LINK)
+ .setLabels(LABELS)
+ .setExternalDatasetReference(EXTERNAL_DATASET_REFERENCE)
+ .build();
+ assertEquals(
+ EXTERNAL_DATASET_REFERENCE,
+ datasetWithExternalDatasetReference.getExternalDatasetReference());
+ compareDataset(
+ datasetWithExternalDatasetReference,
+ datasetWithExternalDatasetReference.toBuilder().build());
+ }
+
private void compareDataset(Dataset expected, Dataset value) {
assertEquals(expected, value);
compareDatasetInfo(expected, value);
@@ -338,5 +368,6 @@ private void compareDatasetInfo(DatasetInfo expected, DatasetInfo value) {
assertEquals(expected.getCreationTime(), value.getCreationTime());
assertEquals(expected.getDefaultTableLifetime(), value.getDefaultTableLifetime());
assertEquals(expected.getLastModified(), value.getLastModified());
+ assertEquals(expected.getExternalDatasetReference(), value.getExternalDatasetReference());
}
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalDatasetReferenceTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalDatasetReferenceTest.java
new file mode 100644
index 000000000..6d241948b
--- /dev/null
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/ExternalDatasetReferenceTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.bigquery;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class ExternalDatasetReferenceTest {
+ private static final String EXTERNAL_SOURCE = "test_source";
+ private static final String CONNECTION = "test_connection";
+ private static final ExternalDatasetReference EXTERNAL_DATASET_REFERENCE =
+ ExternalDatasetReference.newBuilder()
+ .setExternalSource(EXTERNAL_SOURCE)
+ .setConnection(CONNECTION)
+ .build();
+
+ @Test
+ public void testToBuilder() {
+ compareExternalDatasetReference(
+ EXTERNAL_DATASET_REFERENCE, EXTERNAL_DATASET_REFERENCE.toBuilder().build());
+ ExternalDatasetReference externalDatasetReference =
+ EXTERNAL_DATASET_REFERENCE.toBuilder().setExternalSource("test_source2").build();
+ assertEquals("test_source2", externalDatasetReference.getExternalSource());
+ }
+
+ @Test
+ public void testBuilder() {
+ assertEquals(EXTERNAL_SOURCE, EXTERNAL_DATASET_REFERENCE.getExternalSource());
+ assertEquals(CONNECTION, EXTERNAL_DATASET_REFERENCE.getConnection());
+ ExternalDatasetReference externalDatasetReference =
+ ExternalDatasetReference.newBuilder()
+ .setExternalSource(EXTERNAL_SOURCE)
+ .setConnection(CONNECTION)
+ .build();
+ assertEquals(EXTERNAL_DATASET_REFERENCE, externalDatasetReference);
+ }
+
+ @Test
+ public void testToAndFromPb() {
+ ExternalDatasetReference externalDatasetReference =
+ EXTERNAL_DATASET_REFERENCE.toBuilder().build();
+ assertTrue(
+ ExternalDatasetReference.fromPb(externalDatasetReference.toPb())
+ instanceof ExternalDatasetReference);
+ compareExternalDatasetReference(
+ externalDatasetReference, ExternalDatasetReference.fromPb(externalDatasetReference.toPb()));
+ }
+
+ private void compareExternalDatasetReference(
+ ExternalDatasetReference expected, ExternalDatasetReference value) {
+ assertEquals(expected.getExternalSource(), value.getExternalSource());
+ assertEquals(expected.getConnection(), value.getConnection());
+ }
+}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueTest.java
index e4ec47b47..90cb69061 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueTest.java
@@ -27,8 +27,13 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.io.BaseEncoding;
import java.math.BigDecimal;
+import java.time.Duration;
+import java.time.Period;
+import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Map.Entry;
import org.junit.Test;
+import org.threeten.extra.PeriodDuration;
public class FieldValueTest {
@@ -43,6 +48,10 @@ public class FieldValueTest {
ImmutableMap.of("v", "123456789.123456789");
private static final Map STRING_FIELD = ImmutableMap.of("v", "string");
private static final Map TIMESTAMP_FIELD = ImmutableMap.of("v", "42");
+ private static final Map INTERVAL_FIELD_1 =
+ ImmutableMap.of("v", "P3Y2M1DT12H34M56.789S");
+ private static final Map INTERVAL_FIELD_2 =
+ ImmutableMap.of("v", "3-2 1 12:34:56.789");
private static final Map BYTES_FIELD = ImmutableMap.of("v", BYTES_BASE64);
private static final Map NULL_FIELD =
ImmutableMap.of("v", Data.nullOf(String.class));
@@ -74,6 +83,17 @@ public void testFromPb() {
value = FieldValue.fromPb(TIMESTAMP_FIELD);
assertEquals(FieldValue.Attribute.PRIMITIVE, value.getAttribute());
assertEquals(42000000, value.getTimestampValue());
+ value = FieldValue.fromPb(INTERVAL_FIELD_1);
+ assertEquals(FieldValue.Attribute.PRIMITIVE, value.getAttribute());
+ PeriodDuration periodDuration =
+ PeriodDuration.of(Period.of(3, 2, 1), Duration.parse("PT12H34M56.789S"));
+ assertEquals(periodDuration, value.getPeriodDuration());
+ assertEquals("P3Y2M1DT12H34M56.789S", value.getStringValue());
+ value = FieldValue.fromPb(INTERVAL_FIELD_2);
+ assertEquals(FieldValue.Attribute.PRIMITIVE, value.getAttribute());
+ periodDuration = PeriodDuration.of(Period.of(3, 2, 1), Duration.parse("PT12H34M56.789S"));
+ assertEquals(periodDuration, value.getPeriodDuration());
+ assertEquals("3-2 1 12:34:56.789", value.getStringValue());
value = FieldValue.fromPb(BYTES_FIELD);
assertEquals(FieldValue.Attribute.PRIMITIVE, value.getAttribute());
assertArrayEquals(BYTES, value.getBytesValue());
@@ -146,4 +166,22 @@ public void testEquals() {
assertEquals(recordValue, FieldValue.fromPb(RECORD_FIELD));
assertEquals(recordValue.hashCode(), FieldValue.fromPb(RECORD_FIELD).hashCode());
}
+
+ @Test
+ public void testParseCanonicalInterval() {
+ Map intervalToPeriodDuration = new LinkedHashMap<>();
+ intervalToPeriodDuration.put(
+ "125-7 -19 -0:24:12.001", PeriodDuration.parse("P125Y7M-19DT0H-24M-12.001S"));
+ intervalToPeriodDuration.put("-15-6 23 23:14:05", PeriodDuration.parse("P-15Y-6M23DT23H14M5S"));
+ intervalToPeriodDuration.put(
+ "06-01 06 01:01:00.123456", PeriodDuration.parse("P6Y1M6DT1H1M0.123456S"));
+ intervalToPeriodDuration.put("-0-0 -0 -0:0:0", PeriodDuration.parse("P0Y0M0DT0H0M0S"));
+ intervalToPeriodDuration.put(
+ "-99999-99999 9999 999:999:999.999999999",
+ PeriodDuration.parse("P-99999Y-99999M9999DT999H999M999.999999999S"));
+ for (Entry entry : intervalToPeriodDuration.entrySet()) {
+ assertEquals(FieldValue.parseCanonicalInterval(entry.getKey()), entry.getValue());
+ System.out.println(FieldValue.parseCanonicalInterval(entry.getKey()));
+ }
+ }
}
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java
index 8c5742e57..cf180f9a3 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java
@@ -1228,8 +1228,11 @@ public void testIntervalType() throws InterruptedException {
.build();
TableResult result = bigquery.query(queryJobConfiguration);
assertNotNull(result.getJobId());
+ PeriodDuration periodDuration =
+ PeriodDuration.of(Period.of(125, 7, -19), java.time.Duration.parse("PT24M12.000006S"));
for (FieldValueList values : result.iterateAll()) {
assertEquals("125-7 -19 0:24:12.000006", values.get(0).getValue());
+ assertEquals(periodDuration, values.get(0).getPeriodDuration());
}
} finally {
assertTrue(bigquery.delete(tableId));
@@ -5090,7 +5093,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 "
@@ -5109,6 +5112,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);
}
diff --git a/pom.xml b/pom.xml
index 0dbceabc2..c7af98af7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.google.cloud
google-cloud-bigquery-parent
pom
- 2.31.0
+ 2.31.3-SNAPSHOT
BigQuery Parent
https://github.com/googleapis/java-bigquery
@@ -54,8 +54,8 @@
UTF-8
github
google-cloud-bigquery-parent
- v2-rev20230520-2.0.0
- 3.13.1
+ v2-rev20230812-2.0.0
+ 3.15.0
12.0.1