Skip to content

Commit

Permalink
feat: Support For Proto Column in Spanner (#1829)
Browse files Browse the repository at this point in the history
* feat: Generated Proto Changes

Changes need to be reverted.

* feat: Implementation for Proto Message & Enum

-Adding Logic for Serialization & Deserialization
-New Type Codes and utilities

* feat: Proto static files and typings and generated descriptors

* sample: Adding DML, DQL, DML, table insert & read samples.

* style: Lint

* test: Adding unit tests

* refactor: minor refactoring

* refactor: minor refactoring

* test: Adding integration tests

* docs: Adding docs

* test: Adding sample Integration Tests

* refactor: Minor refactoring and updating comments/docs.

* test: Making test fixes

* refactor: Minor refactoring and lint fixes

* refactor: Minor refactoring and lint fixes

* Updating docs and minor changes.

* test: fixing test

* refactor: minor changes

* refactor: minor refactoring

* docs: Updating docs & comments
  • Loading branch information
gauravpurohit06 committed Aug 7, 2023
1 parent 7f6d4cc commit 1051c66
Show file tree
Hide file tree
Showing 32 changed files with 3,095 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ build/
docs/
protos/
samples/generated/
samples/resource/
test/data/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"ycsb": "node ./benchmark/ycsb.js run -P ./benchmark/workloada -p table=usertable -p cloudspanner.instance=ycsb-instance -p operationcount=100 -p cloudspanner.database=ycsb",
"fix": "gts fix",
"clean": "gts clean",
"compile": "tsc -p . && cp -r protos build",
"compile": "tsc -p . && cp -r protos build && cp -r test/data build/test",
"prepare": "npm run compile-protos && npm run compile",
"pretest": "npm run compile",
"presystem-test": "npm run compile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,26 @@ message CreateDatabaseRequest {

// Optional. The dialect of the Cloud Spanner Database.
DatabaseDialect database_dialect = 5 [(google.api.field_behavior) = OPTIONAL];

// Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in
// 'extra_statements' above.
// Contains a protobuf-serialized
// [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto).
// To generate it, [install](https://grpc.io/docs/protoc-installation/) and
// run `protoc` with --include_imports and --descriptor_set_out. For example,
// to generate for moon/shot/app.proto, run
// """
// $protoc --proto_path=/app_path --proto_path=/lib_path \
// --include_imports \
// --descriptor_set_out=descriptors.data \
// moon/shot/app.proto
// """
// For more details, see protobuffer [self
// description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
// (--
// TODO(b/236424835) remove visibility check before launch.
// --)
bytes proto_descriptors = 6 [(google.api.field_behavior) = OPTIONAL];
}

// Metadata type for the operation returned by
Expand Down Expand Up @@ -585,6 +605,26 @@ message UpdateDatabaseDdlRequest {
// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] returns
// `ALREADY_EXISTS`.
string operation_id = 3;

// Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in
// 'extra_statements' above.
// Contains a protobuf-serialized
// [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto).
// To generate it, [install](https://grpc.io/docs/protoc-installation/) and
// run `protoc` with --include_imports and --descriptor_set_out. For example,
// to generate for moon/shot/app.proto, run
// """
// $protoc --proto_path=/app_path --proto_path=/lib_path \
// --include_imports \
// --descriptor_set_out=descriptors.data \
// moon/shot/app.proto
// """
// For more details, see protobuffer [self
// description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
// (--
// TODO(b/236424835) remove visibility check before launch.
// --)
bytes proto_descriptors = 4 [(google.api.field_behavior) = OPTIONAL];
}

// Metadata type for the operation returned by
Expand Down Expand Up @@ -649,6 +689,16 @@ message GetDatabaseDdlResponse {
// A list of formatted DDL statements defining the schema of the database
// specified in the request.
repeated string statements = 1;

// Proto descriptors stored in the database.
// Contains a protobuf-serialized
// [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto).
// For more details, see protobuffer [self
// description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
// (--
// TODO(b/236424835) remove visibility check before launch.
// --)
bytes proto_descriptors = 2;
}

// The request for
Expand Down
12 changes: 12 additions & 0 deletions protos/google/spanner/v1/type.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ message Type {
// typically is not needed to process the content of a value (it doesn't
// affect serialization) and clients can ignore it on the read path.
TypeAnnotationCode type_annotation = 4;

// If [code][] == [PROTO][TypeCode.PROTO] or [code][] ==
// [ENUM][TypeCode.ENUM], then `proto_type_fqn` is the fully qualified name of
// the proto type representing the proto/enum definition.
string proto_type_fqn = 5;
}

// `StructType` defines the fields of a [STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
Expand Down Expand Up @@ -145,6 +150,13 @@ enum TypeCode {
// preserved.
// - JSON array elements will have their order preserved.
JSON = 11;

// Encoded as a base64-encoded `string`, as described in RFC 4648,
// section 4.
PROTO = 13;

// Encoded as `string`, in decimal format.
ENUM = 14;
}

// `TypeAnnotationCode` is used as a part of [Type][google.spanner.v1.Type] to
Expand Down
28 changes: 27 additions & 1 deletion protos/protos.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1051c66

Please sign in to comment.