GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(bigtable): add view_parameters support to BoundStatement by ad548 · Pull Request #13673 · googleapis/google-cloud-java

feat(bigtable): add view_parameters support to BoundStatement #13673

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.

Sign up for GitHub

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

Merged
mutianf merged 14 commits into googleapis:main from ad548:feat-view-parameters
Jul 22, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat(bigtable): add view_parameters support to BoundStatement #13673

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
198cc70
feat: Add view_parameters support in BoundStatement and Test Proxy
ad548 Jul 9, 2026
79b16eb
style: apply google-java-format to BoundStatement and BoundStatementTest
ad548 Jul 17, 2026
1a170fc
refactor(bigtable): add setStringViewParameter(s) to BoundStatement.B…
ad548 Jul 17, 2026
c4c9e92
refactor(bigtable): address PR comments on view parameters API
ad548 Jul 17, 2026
7f20c89
refactor(bigtable): simplify setStringViewParameters to delegate to s…
ad548 Jul 20, 2026
6d10dc2
docs(bigtable): add VIEW_PARAMETERS function calls comment to Javadoc…
ad548 Jul 20, 2026
391c330
test(bigtable): add BoundStatementDeserializerTest to test-proxy module
ad548 Jul 20, 2026
8710442
fix(bigtable): add proto-google-cloud-bigtable-v2 dependency to test-…
ad548 Jul 20, 2026
328eb36
fix(bigtable): update copyright header year in BoundStatementDeserial…
ad548 Jul 20, 2026
2d15072
fix(bigtable): remove test-proxy from reactor modules to fix dependen…
ad548 Jul 20, 2026
f051e2e
Merge branch 'main' into feat-view-parameters
ad548 Jul 22, 2026
786c0d8
refactor(bigtable): remove setViewParameters map overload from BoundS…
ad548 Jul 22, 2026
6565a3c
Merge remote-tracking branch 'fork/feat-view-parameters' into synthes…
ad548 Jul 22, 2026
ef58062
Merge branch 'main' into feat-view-parameters
ad548 Jul 22, 2026
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

32 changes: 28 additions & 4 deletions 32 ...d-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/BoundStatement.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,29 @@
* paramName, Type value) for the appropriate type. For example:
*
* <pre>{@code
* BoundStatementt boundStatement = preparedStatement.bind()
* BoundStatement boundStatement = preparedStatement.bind()
* .setBytesParam("qualifier", ByteString.copyFromUtf8("test"))
* .setBytesParam("key", ByteString.copyFromUtf8("testKey"))
* .build();
* }</pre>
*
* <p>View parameters can also be specified on the statement using {@link
* Builder#setStringViewParameter(String, String)}. This provides the runtime values returned by the
* VIEW_PARAMETERS() function calls.
*/
public class BoundStatement {

private final PreparedStatementImpl preparedStatement;
private final Map<String, Value> params;
private final Map<String, Value> viewParameters;

private BoundStatement(PreparedStatementImpl preparedStatement, Map<String, Value> params) {
private BoundStatement(
PreparedStatementImpl preparedStatement,
Map<String, Value> params,
Map<String, Value> viewParameters) {
this.preparedStatement = preparedStatement;
this.params = params;
this.viewParameters = viewParameters;
}

/**
Expand All @@ -78,6 +87,7 @@ public static class Builder {
private final PreparedStatementImpl preparedStatement;
private final Map<String, SqlType<?>> paramTypes;
private final Map<String, Value> params;
private final Map<String, Value> viewParameters;

/**
* Creates a builder from a {@link PreparedStatement}
Expand All @@ -90,6 +100,7 @@ public Builder(PreparedStatementImpl preparedStatement, Map<String, SqlType<?>>
this.preparedStatement = preparedStatement;
this.paramTypes = paramTypes;
this.params = new HashMap<>();
this.viewParameters = new HashMap<>();
}

/** Builds a {@link BoundStatement} from the builder */
Expand All @@ -101,7 +112,19 @@ public BoundStatement build() {
"Attempting to build BoundStatement without binding parameter: " + paramName);
}
}
return new BoundStatement(preparedStatement, ImmutableMap.copyOf(params));
return new BoundStatement(
preparedStatement, ImmutableMap.copyOf(params), ImmutableMap.copyOf(viewParameters));
}

/**
* Sets a view parameter with the name {@code paramName} and the String typed value {@code
* value}. This map provides the runtime values returned by the VIEW_PARAMETERS() function
* calls.
*/
public Builder setStringViewParameter(String paramName, @Nullable String value) {
Preconditions.checkNotNull(paramName, "paramName cannot be null");
viewParameters.put(paramName, stringParamOf(value));
return this;
}

/**
Expand Down Expand Up @@ -372,7 +395,8 @@ public ExecuteQueryRequest toProto(
requestContext.getProjectId(), requestContext.getInstanceId()))
.setAppProfileId(requestContext.getAppProfileId())
.setPreparedQuery(preparedQuery)
.putAllParams(params);
.putAllParams(params)
.putAllViewParameters(viewParameters);

if (resumeToken != null) {
requestBuilder.setResumeToken(resumeToken);
Expand Down
46 changes: 46 additions & 0 deletions 46 ...gtable/src/test/java/com/google/cloud/bigtable/data/v2/models/sql/BoundStatementTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -869,4 +869,50 @@ public void builderValidatesAllParamsAreSet() {
assertThat(e.getMessage())
.contains("Attempting to build BoundStatement without binding parameter: bytesParam");
}

@Test
public void statementWithStringViewParameters() {
Value stringVal = Value.newBuilder().setType(stringType()).setStringValue("alice").build();
Value locationVal = Value.newBuilder().setType(stringType()).setStringValue("us-east1").build();

BoundStatement s =
boundStatementBuilder()
.setStringViewParameter("user_id", "alice")
.setStringViewParameter("location", "us-east1")
.build();

assertThat(s.toProto(EXPECTED_PREPARED_QUERY, REQUEST_CONTEXT, NO_RESUME_TOKEN))
.isEqualTo(
ExecuteQueryRequest.newBuilder()
.setPreparedQuery(EXPECTED_PREPARED_QUERY)
.setInstanceName(EXPECTED_INSTANCE_NAME)
.setAppProfileId(EXPECTED_APP_PROFILE)
.putViewParameters("user_id", stringVal)
.putViewParameters("location", locationVal)
.build());
}

@Test
public void statementWithNullStringViewParameter() {
Value nullStringVal = Value.newBuilder().setType(stringType()).build();

BoundStatement s =
boundStatementBuilder().setStringViewParameter("user_id", (String) null).build();

assertThat(s.toProto(EXPECTED_PREPARED_QUERY, REQUEST_CONTEXT, NO_RESUME_TOKEN))
.isEqualTo(
ExecuteQueryRequest.newBuilder()
.setPreparedQuery(EXPECTED_PREPARED_QUERY)
.setInstanceName(EXPECTED_INSTANCE_NAME)
.setAppProfileId(EXPECTED_APP_PROFILE)
.putViewParameters("user_id", nullStringVal)
.build());
}

@Test
public void setStringViewParameterNullChecks() {
BoundStatement.Builder builder = boundStatementBuilder();

assertThrows(NullPointerException.class, () -> builder.setStringViewParameter(null, "alice"));
}
}
15 changes: 15 additions & 0 deletions 15 java-bigtable/test-proxy/pom.xml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
19 changes: 18 additions & 1 deletion 19 ...t-proxy/src/main/java/com/google/cloud/bigtable/testproxy/BoundStatementDeserializer.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class BoundStatementDeserializer {

static BoundStatement toBoundStatement(
public static BoundStatement toBoundStatement(
PreparedStatement preparedStatement, ExecuteQueryRequest request) {
BoundStatement.Builder boundStatementBuilder = preparedStatement.bind();
for (Map.Entry<String, Value> paramEntry : request.getRequest().getParamsMap().entrySet()) {
Expand Down Expand Up @@ -128,6 +128,23 @@ static BoundStatement toBoundStatement(
throw new IllegalArgumentException("Unexpected query param type in param: " + value);
}
}
for (Map.Entry<String, Value> entry : request.getRequest().getViewParametersMap().entrySet()) {
String name = entry.getKey();
Value value = entry.getValue();
switch (value.getType().getKindCase()) {
case STRING_TYPE:
if (value.getKindCase().equals(KindCase.KIND_NOT_SET)) {
Comment thread

@mutianf mutianf Jul 22, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? The kindcase of null string is still string? https://github.com/googleapis/google-cloud-java/blob/main/java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/BoundStatement.java#L213

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ad548 ad548 Jul 22, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following the query parameters pattern here https://github.com/ad548/google-cloud-java/blob/f051e2e08aa1306b10c5914fa90cfe34bf2e2920/java-bigtable/test-proxy/src/main/java/com/google/cloud/bigtable/testproxy/BoundStatementDeserializer.java#L50. There is two kindcase - value.getType().getKindCase() and value.getKindCase(). For view_parameters we definitely only care about the first. So yea null string with value.getType().getKindCase() string should be ok.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
boundStatementBuilder.setStringViewParameter(name, null);
} else if (value.getKindCase().equals(KindCase.STRING_VALUE)) {
boundStatementBuilder.setStringViewParameter(name, value.getStringValue());
} else {
throw new IllegalArgumentException("Malformed string value: " + value);
}
break;
default:
throw new IllegalArgumentException("Unexpected view parameter type in param: " + value);
}
}
return boundStatementBuilder.build();
}

Expand Down
125 changes: 125 additions & 0 deletions 125 ...oxy/src/test/java/com/google/cloud/bigtable/testproxy/BoundStatementDeserializerTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright 2026 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
*
* https://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.bigtable.testproxy;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.google.bigtable.v2.ExecuteQueryRequest;
import com.google.bigtable.v2.Type;
import com.google.bigtable.v2.Value;
import com.google.cloud.bigtable.data.v2.models.sql.BoundStatement;
import com.google.cloud.bigtable.data.v2.models.sql.PreparedStatement;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class BoundStatementDeserializerTest {

@Test
public void testDeserializeStringViewParameter() {
PreparedStatement preparedStatement = mock(PreparedStatement.class);
BoundStatement.Builder builder = mock(BoundStatement.Builder.class);
when(preparedStatement.bind()).thenReturn(builder);
when(builder.setStringViewParameter(anyString(), nullable(String.class))).thenReturn(builder);

Value stringVal =
Value.newBuilder()
.setType(Type.newBuilder().setStringType(Type.String.getDefaultInstance()))
.setStringValue("alice")
.build();
com.google.cloud.bigtable.testproxy.ExecuteQueryRequest request =
com.google.cloud.bigtable.testproxy.ExecuteQueryRequest.newBuilder()
.setRequest(ExecuteQueryRequest.newBuilder().putViewParameters("user_id", stringVal))
.build();

BoundStatementDeserializer.toBoundStatement(preparedStatement, request);
verify(builder).setStringViewParameter("user_id", "alice");
}

@Test
public void testDeserializeNullStringViewParameter() {
PreparedStatement preparedStatement = mock(PreparedStatement.class);
BoundStatement.Builder builder = mock(BoundStatement.Builder.class);
when(preparedStatement.bind()).thenReturn(builder);
when(builder.setStringViewParameter(anyString(), nullable(String.class))).thenReturn(builder);

Value nullStringVal =
Value.newBuilder()
.setType(Type.newBuilder().setStringType(Type.String.getDefaultInstance()))
.build();
com.google.cloud.bigtable.testproxy.ExecuteQueryRequest request =
com.google.cloud.bigtable.testproxy.ExecuteQueryRequest.newBuilder()
.setRequest(
ExecuteQueryRequest.newBuilder().putViewParameters("user_id", nullStringVal))
.build();

BoundStatementDeserializer.toBoundStatement(preparedStatement, request);
verify(builder).setStringViewParameter("user_id", null);
}

@Test
public void testDeserializeInvalidTypeViewParameterThrows() {
PreparedStatement preparedStatement = mock(PreparedStatement.class);
BoundStatement.Builder builder = mock(BoundStatement.Builder.class);
when(preparedStatement.bind()).thenReturn(builder);

Value intVal =
Value.newBuilder()
.setType(Type.newBuilder().setInt64Type(Type.Int64.getDefaultInstance()))
.setIntValue(123)
.build();
com.google.cloud.bigtable.testproxy.ExecuteQueryRequest request =
com.google.cloud.bigtable.testproxy.ExecuteQueryRequest.newBuilder()
.setRequest(ExecuteQueryRequest.newBuilder().putViewParameters("user_id", intVal))
.build();

IllegalArgumentException e =
assertThrows(
IllegalArgumentException.class,
() -> BoundStatementDeserializer.toBoundStatement(preparedStatement, request));
assertThat(e.getMessage()).contains("Unexpected view parameter type in param");
}

@Test
public void testDeserializeMalformedStringViewParameterThrows() {
PreparedStatement preparedStatement = mock(PreparedStatement.class);
BoundStatement.Builder builder = mock(BoundStatement.Builder.class);
when(preparedStatement.bind()).thenReturn(builder);

Value malformedVal =
Value.newBuilder()
.setType(Type.newBuilder().setStringType(Type.String.getDefaultInstance()))
.setIntValue(123)
.build();
com.google.cloud.bigtable.testproxy.ExecuteQueryRequest request =
com.google.cloud.bigtable.testproxy.ExecuteQueryRequest.newBuilder()
.setRequest(ExecuteQueryRequest.newBuilder().putViewParameters("user_id", malformedVal))
.build();

IllegalArgumentException e =
assertThrows(
IllegalArgumentException.class,
() -> BoundStatementDeserializer.toBoundStatement(preparedStatement, request));
assertThat(e.getMessage()).contains("Malformed string value");
}
}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.