Skip to content
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.

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

feat: add support for Proto Columns DDL #2277

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b95f577
feat: add code changes and tests for Proto columns DDL support
harshachinta Jan 27, 2023
1653916
feat: add auto generated code
harshachinta Jan 30, 2023
88cb28d
feat: code changes and tests for Proto columns DDL support
harshachinta Feb 1, 2023
75a23de
feat: add descriptors file
harshachinta Feb 1, 2023
f738af6
feat: code refactoring
harshachinta Feb 8, 2023
a1b5ab0
feat: Integration tests and code refactoring
harshachinta Feb 11, 2023
678e8ee
feat: code refactoring
harshachinta Feb 12, 2023
e85e350
feat: unit tests and clirr differences
harshachinta Feb 12, 2023
bb04177
feat: lint changes
harshachinta Feb 13, 2023
f4c7c96
feat: code refactor
harshachinta Feb 13, 2023
80526b5
feat: code refactoring
harshachinta Feb 13, 2023
88fa533
feat: code refactoring
harshachinta Feb 13, 2023
d33f816
feat: code refactoring
harshachinta Feb 14, 2023
fb0293a
feat: add java docs to new methods
harshachinta Feb 14, 2023
c45143c
feat: lint formatting
harshachinta Feb 14, 2023
7c6472d
feat: lint formatting changes
harshachinta Feb 14, 2023
50b8666
feat: lint formatting
harshachinta Feb 14, 2023
72af9f3
feat: lint formatting
harshachinta Feb 14, 2023
e355e4a
feat: test exception cases
harshachinta Feb 15, 2023
eb938bc
feat: code refactoring
harshachinta Feb 27, 2023
f762e39
feat: add java docs and refactoring
harshachinta Feb 27, 2023
30be84a
feat: add java docs
harshachinta Feb 28, 2023
70acee6
feat: java docs refactor
harshachinta Mar 15, 2023
51a4031
feat: remove overload method setProtoDescriptors that accepts file pa…
harshachinta Mar 15, 2023
bfae4ad
feat: remove updateDdl method overload to update proto descriptor
harshachinta Mar 15, 2023
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
Next Next commit
feat: add code changes and tests for Proto columns DDL support
  • Loading branch information
harshachinta committed Jan 27, 2023
commit b95f57765975456a9590b1c595416e65632e94ae
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ If you are using Maven without BOM, add this to your dependencies:
If you are using Gradle 5.x or later, add this to your dependencies:

```Groovy
implementation platform('com.google.cloud:libraries-bom:26.2.0')
implementation platform('com.google.cloud:libraries-bom:26.3.0')

implementation 'com.google.cloud:google-cloud-spanner'
```
Expand Down Expand Up @@ -261,6 +261,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-spanner/tree/
| Create Backup With Encryption Key | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateBackupWithEncryptionKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateBackupWithEncryptionKey.java) |
| Create Database With Default Leader Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithDefaultLeaderSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithDefaultLeaderSample.java) |
| Create Database With Encryption Key | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java) |
| Create Database With Proto Descriptor | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithProtoDescriptor.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithProtoDescriptor.java) |
| Create Database With Version Retention Period Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithVersionRetentionPeriodSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithVersionRetentionPeriodSample.java) |
| Create Instance Config Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateInstanceConfigSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateInstanceConfigSample.java) |
| Create Instance Example | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateInstanceExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateInstanceExample.java) |
Expand Down Expand Up @@ -290,12 +291,14 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-spanner/tree/
| Pg Spanner Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/PgSpannerSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/PgSpannerSample.java) |
| Pg Update Using Dml Returning Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/PgUpdateUsingDmlReturningSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/PgUpdateUsingDmlReturningSample.java) |
| Query Information Schema Database Options Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/QueryInformationSchemaDatabaseOptionsSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/QueryInformationSchemaDatabaseOptionsSample.java) |
| Query Proto Column Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/QueryProtoColumnSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/QueryProtoColumnSample.java) |
| Query With Json Parameter Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/QueryWithJsonParameterSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/QueryWithJsonParameterSample.java) |
| Query With Jsonb Parameter Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/QueryWithJsonbParameterSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/QueryWithJsonbParameterSample.java) |
| Query With Numeric Parameter Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/QueryWithNumericParameterSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/QueryWithNumericParameterSample.java) |
| Quickstart Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/QuickstartSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/QuickstartSample.java) |
| Read Data With Database Role | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/ReadDataWithDatabaseRole.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/ReadDataWithDatabaseRole.java) |
| Restore Backup With Encryption Key | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java) |
| Singer Proto | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/SingerProto.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/SingerProto.java) |
| Spanner Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/SpannerSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/SpannerSample.java) |
| Statement Timeout Example | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/StatementTimeoutExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/StatementTimeoutExample.java) |
| Tag Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/TagSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/TagSample.java) |
Expand All @@ -305,6 +308,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-spanner/tree/
| Update Json Data Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/UpdateJsonDataSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/UpdateJsonDataSample.java) |
| Update Jsonb Data Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/UpdateJsonbDataSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/UpdateJsonbDataSample.java) |
| Update Numeric Data Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/UpdateNumericDataSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/UpdateNumericDataSample.java) |
| Update Proto Column Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/UpdateProtoColumnSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/UpdateProtoColumnSample.java) |
| Update Using Dml Returning Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/UpdateUsingDmlReturningSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/UpdateUsingDmlReturningSample.java) |


Expand Down
5 changes: 3 additions & 2 deletions google-cloud-spanner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
<opencensus.version>0.31.1</opencensus.version>
<graalvm.version>22.3.0</graalvm.version>
<spanner.testenv.config.class>com.google.cloud.spanner.GceTestEnvConfig</spanner.testenv.config.class>
<spanner.testenv.instance>projects/gcloud-devel/instances/spanner-testing-east1</spanner.testenv.instance>
<spanner.gce.config.project_id>gcloud-devel</spanner.gce.config.project_id>
<spanner.testenv.instance>projects/span-cloud-testing/instances/harsha-test-gcloud</spanner.testenv.instance>
<spanner.gce.config.project_id>span-cloud-testing</spanner.gce.config.project_id>
<spanner.gce.config.server_url>https://staging-wrenchworks.sandbox.googleapis.com</spanner.gce.config.server_url>
<spanner.testenv.kms_key.name>projects/gcloud-devel/locations/us-east1/keyRings/cmek-test-key-ring/cryptoKeys/cmek-test-key</spanner.testenv.kms_key.name>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.cloud.spanner.encryption.CustomerManagedEncryption;
import com.google.common.base.Preconditions;
import com.google.longrunning.Operation;
import com.google.protobuf.ByteString;
import com.google.spanner.admin.database.v1.CreateBackupMetadata;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata;

Expand Down Expand Up @@ -88,6 +89,11 @@ public OperationFuture<Void, UpdateDatabaseDdlMetadata> updateDdl(
return dbClient.updateDatabaseDdl(instance(), database(), statements, operationId);
}

public OperationFuture<Void, UpdateDatabaseDdlMetadata> updateDdl(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I didn't notice this during the last review, but this seems a little strange. It is a method in the Database class and takes a Database instance as an argument. Why does it not just operate on this database?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason it cannot operate on this database is because a user cannot set ProtoDescriptor directly to Database Class as setProtoDescriptors method belongs to Database.Builder. Below is a small example to illustrate this,

Database database = client.getDatabase(INSTANCE_ID, DB_ID);

// If a user wants to update the ProtoDescriptor field then, 
// the below line cannot be written as setProtoDescriptors method does not belong to Database class.
database.setProtoDescriptors("descriptors.pb"); 

// This does not update proto descriptor in the database because the field was not updated.
database.updateDdl(Collections.singletonList("DROP TABLE Singer"), null); 

So a new Database instance has to be passed to update the ProtoDescriptor field. However, I agree that this is incorrect and confusing at same time.

Another Approach
@olavloite Please validate if below is more meaningful to do.

Expose a new method toBuilder() in Database.java that return a Builder of that Database instance. This allows users to setProtoDescriptor by calling the builder.
The change in Database.java is

public class Database extends DatabaseInfo {
  public Builder toBuilder() {
      return new Builder(this);
    }


  public OperationFuture<Void, UpdateDatabaseDdlMetadata> updateDdl(
      Iterable<String> statements, String operationId) throws SpannerException {
     // The updateDatabaseDdl is called with 'this' as argument instead of instance(), database()
    return dbClient.updateDatabaseDdl(this, statements, operationId);
  }
}

The user can use it like below

Database database = client.getDatabase(INSTANCE_ID, DB_ID);
// The below database instance has the updated ProtoDescriptor field
database = database.toBuilder().setProtoDescriptors("descriptors.pb").build();
// Update works fine
database.updateDdl(Collections.singletonList("DROP TABLE Singer"), null);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmmm.... If the protoDescriptors field is not something that is actually part of the Database class and thereby also not stored with the database, and is only needed for the update method, then we need to add it as an argument to the method afte rall. Other approaches would be non-idiomatic Java.

So the signature of the method would then become Database#updateDatabaseDdl(Iterable<String> statements, String protoDescriptors, String operationId). Another option would be to create a DatabaseUpdateOptions class that contains all possible update options, the first one being protoDescriptors (that would make it more easily reusable for additional options in the future).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you @olavloite. Creating a new DatabaseUpdateOptions class that can update options will help us reuse in future. I will take this effort as part of the next PR. I will tag this comment in the other PR later to understand the need of that change.

Iterable<String> statements, String operationId, byte[] protoDescriptors) throws SpannerException {
return dbClient.updateDatabaseDdl(instance(), database(), statements, operationId, protoDescriptors);
}

/** Drops this database. */
public void drop() throws SpannerException {
dbClient.dropDatabase(instance(), database());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import com.google.cloud.Timestamp;
import com.google.cloud.spanner.Options.ListOption;
import com.google.longrunning.Operation;
import com.google.protobuf.ByteString;
import com.google.spanner.admin.database.v1.CopyBackupMetadata;
import com.google.spanner.admin.database.v1.CreateBackupMetadata;
import com.google.spanner.admin.database.v1.CreateDatabaseMetadata;
import com.google.spanner.admin.database.v1.CreateDatabaseRequest;
import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse;
import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata;
import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata;
import java.util.List;
Expand Down Expand Up @@ -383,7 +385,7 @@ OperationFuture<Database, RestoreDatabaseMetadata> restoreDatabase(Restore resto
* <p>If an operation already exists with the given operation id, the operation will be resumed
* and the returned future will complete when the original operation finishes. See more
* information in {@link com.google.cloud.spanner.spi.v1.GapicSpannerRpc#updateDatabaseDdl(String,
* Iterable, String)}
* Iterable, String, ByteString)}
*
* <p>Example to update the database DDL.
*
Expand All @@ -407,6 +409,14 @@ OperationFuture<Void, UpdateDatabaseDdlMetadata> updateDatabaseDdl(
@Nullable String operationId)
throws SpannerException;

OperationFuture<Void, UpdateDatabaseDdlMetadata> updateDatabaseDdl(
String instanceId,
String databaseId,
Iterable<String> statements,
@Nullable String operationId,
@Nullable byte[] protoDescriptors)
throws SpannerException;

/**
* Drops a Cloud Spanner database.
*
Expand Down Expand Up @@ -434,6 +444,8 @@ OperationFuture<Void, UpdateDatabaseDdlMetadata> updateDatabaseDdl(
*/
List<String> getDatabaseDdl(String instanceId, String databaseId);

GetDatabaseDdlResponse getDatabaseDdlWithProtoDescriptors(String instanceId, String databaseId);

/**
* Returns the list of Cloud Spanner database in the given instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.common.base.Preconditions;
import com.google.iam.v1.GetPolicyOptions;
import com.google.longrunning.Operation;
import com.google.protobuf.ByteString;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import com.google.spanner.admin.database.v1.*;
Expand Down Expand Up @@ -415,17 +416,25 @@ public Database getDatabase(String instanceId, String databaseId) throws Spanner
return Database.fromProto(rpc.getDatabase(dbName), DatabaseAdminClientImpl.this);
}

@Override
public OperationFuture<Void, UpdateDatabaseDdlMetadata> updateDatabaseDdl(String instanceId,
String databaseId, Iterable<String> statements, @Nullable String operationId)
throws SpannerException {
return updateDatabaseDdl(instanceId, databaseId, statements, operationId, null);
}

@Override
public OperationFuture<Void, UpdateDatabaseDdlMetadata> updateDatabaseDdl(
final String instanceId,
final String databaseId,
final Iterable<String> statements,
@Nullable String operationId)
@Nullable String operationId,
@Nullable byte[] protoDescriptors)
throws SpannerException {
final String dbName = getDatabaseName(instanceId, databaseId);
final String opId = operationId != null ? operationId : randomOperationId();
OperationFuture<Empty, UpdateDatabaseDdlMetadata> rawOperationFuture =
rpc.updateDatabaseDdl(dbName, statements, opId);
rpc.updateDatabaseDdl(dbName, statements, opId, ByteString.copyFrom(protoDescriptors));
return new OperationFutureImpl<>(
rawOperationFuture.getPollingFuture(),
rawOperationFuture.getInitialFuture(),
Expand All @@ -447,6 +456,11 @@ public void dropDatabase(String instanceId, String databaseId) throws SpannerExc

@Override
public List<String> getDatabaseDdl(String instanceId, String databaseId) {
return getDatabaseDdlWithProtoDescriptors(instanceId, databaseId).getStatementsList();
}

@Override
public GetDatabaseDdlResponse getDatabaseDdlWithProtoDescriptors(String instanceId, String databaseId) {
String dbName = getDatabaseName(instanceId, databaseId);
return rpc.getDatabaseDdl(dbName);
}
Expand Down
Loading