Skip to content

Commit

Permalink
feat: spanner NUMERIC type (#349)
Browse files Browse the repository at this point in the history
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/fa501585-95fa-4c4d-9062-c23b3406d7ec/targets

- [ ] To automatically regenerate this PR, check this box.

PiperOrigin-RevId: 321058159
Source-Link: googleapis/googleapis@59f97e6
  • Loading branch information
yoshi-automation committed Jul 15, 2020
1 parent 6ee83b5 commit 78c3192
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 70 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -17,7 +17,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>8.0.0</version>
<version>8.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Expand Up @@ -148,7 +148,7 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
* </pre>
*
* <code>.google.spanner.v1.TypeCode code = 1;</code>
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The enum numeric value on the wire for code.
*/
Expand All @@ -163,7 +163,7 @@ public int getCodeValue() {
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
* </pre>
*
* <code>.google.spanner.v1.TypeCode code = 1;</code>
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The code.
*/
Expand Down Expand Up @@ -650,7 +650,7 @@ public Builder mergeFrom(
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
* </pre>
*
* <code>.google.spanner.v1.TypeCode code = 1;</code>
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The enum numeric value on the wire for code.
*/
Expand All @@ -665,7 +665,7 @@ public int getCodeValue() {
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
* </pre>
*
* <code>.google.spanner.v1.TypeCode code = 1;</code>
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The enum numeric value on the wire for code to set.
* @return This builder for chaining.
Expand All @@ -683,7 +683,7 @@ public Builder setCodeValue(int value) {
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
* </pre>
*
* <code>.google.spanner.v1.TypeCode code = 1;</code>
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The code.
*/
Expand All @@ -700,7 +700,7 @@ public com.google.spanner.v1.TypeCode getCode() {
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
* </pre>
*
* <code>.google.spanner.v1.TypeCode code = 1;</code>
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @param value The code to set.
* @return This builder for chaining.
Expand All @@ -721,7 +721,7 @@ public Builder setCode(com.google.spanner.v1.TypeCode value) {
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
* </pre>
*
* <code>.google.spanner.v1.TypeCode code = 1;</code>
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return This builder for chaining.
*/
Expand Down
Expand Up @@ -144,6 +144,23 @@ public enum TypeCode implements com.google.protobuf.ProtocolMessageEnum {
* <code>STRUCT = 9;</code>
*/
STRUCT(9),
/**
*
*
* <pre>
* Encoded as `string`, in decimal format or scientific notation format.
* &lt;br&gt;Decimal format:
* &lt;br&gt;`[+-]Digits[.[Digits]]` or
* &lt;br&gt;`[+-][Digits].Digits`
* Scientific notation:
* &lt;br&gt;`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
* &lt;br&gt;`[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
* &lt;br&gt;(ExponentIndicator is `"e"` or `"E"`)
* </pre>
*
* <code>NUMERIC = 10;</code>
*/
NUMERIC(10),
UNRECOGNIZED(-1),
;

Expand Down Expand Up @@ -258,6 +275,23 @@ public enum TypeCode implements com.google.protobuf.ProtocolMessageEnum {
* <code>STRUCT = 9;</code>
*/
public static final int STRUCT_VALUE = 9;
/**
*
*
* <pre>
* Encoded as `string`, in decimal format or scientific notation format.
* &lt;br&gt;Decimal format:
* &lt;br&gt;`[+-]Digits[.[Digits]]` or
* &lt;br&gt;`[+-][Digits].Digits`
* Scientific notation:
* &lt;br&gt;`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
* &lt;br&gt;`[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
* &lt;br&gt;(ExponentIndicator is `"e"` or `"E"`)
* </pre>
*
* <code>NUMERIC = 10;</code>
*/
public static final int NUMERIC_VALUE = 10;

public final int getNumber() {
if (this == UNRECOGNIZED) {
Expand Down Expand Up @@ -303,6 +337,8 @@ public static TypeCode forNumber(int value) {
return ARRAY;
case 9:
return STRUCT;
case 10:
return NUMERIC;
default:
return null;
}
Expand Down
Expand Up @@ -30,7 +30,7 @@ public interface TypeOrBuilder
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
* </pre>
*
* <code>.google.spanner.v1.TypeCode code = 1;</code>
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The enum numeric value on the wire for code.
*/
Expand All @@ -42,7 +42,7 @@ public interface TypeOrBuilder
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
* </pre>
*
* <code>.google.spanner.v1.TypeCode code = 1;</code>
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
*
* @return The code.
*/
Expand Down
Expand Up @@ -49,28 +49,30 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
static {
java.lang.String[] descriptorData = {
"\n\034google/spanner/v1/type.proto\022\021google.s"
+ "panner.v1\032\034google/api/annotations.proto\""
+ "\232\001\n\004Type\022)\n\004code\030\001 \001(\0162\033.google.spanner."
+ "v1.TypeCode\0223\n\022array_element_type\030\002 \001(\0132"
+ "\027.google.spanner.v1.Type\0222\n\013struct_type\030"
+ "\003 \001(\0132\035.google.spanner.v1.StructType\"\177\n\n"
+ "StructType\0223\n\006fields\030\001 \003(\0132#.google.span"
+ "ner.v1.StructType.Field\032<\n\005Field\022\014\n\004name"
+ "\030\001 \001(\t\022%\n\004type\030\002 \001(\0132\027.google.spanner.v1"
+ ".Type*\216\001\n\010TypeCode\022\031\n\025TYPE_CODE_UNSPECIF"
+ "IED\020\000\022\010\n\004BOOL\020\001\022\t\n\005INT64\020\002\022\013\n\007FLOAT64\020\003\022"
+ "\r\n\tTIMESTAMP\020\004\022\010\n\004DATE\020\005\022\n\n\006STRING\020\006\022\t\n\005"
+ "BYTES\020\007\022\t\n\005ARRAY\020\010\022\n\n\006STRUCT\020\tB\257\001\n\025com.g"
+ "oogle.spanner.v1B\tTypeProtoP\001Z8google.go"
+ "lang.org/genproto/googleapis/spanner/v1;"
+ "spanner\252\002\027Google.Cloud.Spanner.V1\312\002\027Goog"
+ "le\\Cloud\\Spanner\\V1\352\002\032Google::Cloud::Spa"
+ "nner::V1b\006proto3"
+ "panner.v1\032\037google/api/field_behavior.pro"
+ "to\032\034google/api/annotations.proto\"\237\001\n\004Typ"
+ "e\022.\n\004code\030\001 \001(\0162\033.google.spanner.v1.Type"
+ "CodeB\003\340A\002\0223\n\022array_element_type\030\002 \001(\0132\027."
+ "google.spanner.v1.Type\0222\n\013struct_type\030\003 "
+ "\001(\0132\035.google.spanner.v1.StructType\"\177\n\nSt"
+ "ructType\0223\n\006fields\030\001 \003(\0132#.google.spanne"
+ "r.v1.StructType.Field\032<\n\005Field\022\014\n\004name\030\001"
+ " \001(\t\022%\n\004type\030\002 \001(\0132\027.google.spanner.v1.T"
+ "ype*\233\001\n\010TypeCode\022\031\n\025TYPE_CODE_UNSPECIFIE"
+ "D\020\000\022\010\n\004BOOL\020\001\022\t\n\005INT64\020\002\022\013\n\007FLOAT64\020\003\022\r\n"
+ "\tTIMESTAMP\020\004\022\010\n\004DATE\020\005\022\n\n\006STRING\020\006\022\t\n\005BY"
+ "TES\020\007\022\t\n\005ARRAY\020\010\022\n\n\006STRUCT\020\t\022\013\n\007NUMERIC\020"
+ "\nB\257\001\n\025com.google.spanner.v1B\tTypeProtoP\001"
+ "Z8google.golang.org/genproto/googleapis/"
+ "spanner/v1;spanner\252\002\027Google.Cloud.Spanne"
+ "r.V1\312\002\027Google\\Cloud\\Spanner\\V1\352\002\032Google:"
+ ":Cloud::Spanner::V1b\006proto3"
};
descriptor =
com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(
descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
com.google.api.FieldBehaviorProto.getDescriptor(),
com.google.api.AnnotationsProto.getDescriptor(),
});
internal_static_google_spanner_v1_Type_descriptor = getDescriptor().getMessageTypes().get(0);
Expand All @@ -96,6 +98,12 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
new java.lang.String[] {
"Name", "Type",
});
com.google.protobuf.ExtensionRegistry registry =
com.google.protobuf.ExtensionRegistry.newInstance();
registry.add(com.google.api.FieldBehaviorProto.fieldBehavior);
com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor(
descriptor, registry);
com.google.api.FieldBehaviorProto.getDescriptor();
com.google.api.AnnotationsProto.getDescriptor();
}

Expand Down
Expand Up @@ -16,6 +16,7 @@ syntax = "proto3";

package google.spanner.v1;

import "google/api/field_behavior.proto";
import "google/api/annotations.proto";

option csharp_namespace = "Google.Cloud.Spanner.V1";
Expand All @@ -26,6 +27,47 @@ option java_package = "com.google.spanner.v1";
option php_namespace = "Google\\Cloud\\Spanner\\V1";
option ruby_package = "Google::Cloud::Spanner::V1";

// `Type` indicates the type of a Cloud Spanner value, as might be stored in a
// table cell or returned from an SQL query.
message Type {
// Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
TypeCode code = 1 [(google.api.field_behavior) = REQUIRED];

// If [code][google.spanner.v1.Type.code] == [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type`
// is the type of the array elements.
Type array_element_type = 2;

// If [code][google.spanner.v1.Type.code] == [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type`
// provides type information for the struct's fields.
StructType struct_type = 3;
}

// `StructType` defines the fields of a [STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
message StructType {
// Message representing a single field of a struct.
message Field {
// The name of the field. For reads, this is the column name. For
// SQL queries, it is the column alias (e.g., `"Word"` in the
// query `"SELECT 'hello' AS Word"`), or the column name (e.g.,
// `"ColName"` in the query `"SELECT ColName FROM Table"`). Some
// columns might have an empty name (e.g., !"SELECT
// UPPER(ColName)"`). Note that a query result can contain
// multiple fields with the same name.
string name = 1;

// The type of the field.
Type type = 2;
}

// The list of fields that make up this struct. Order is
// significant, because values of this struct type are represented as
// lists, where the order of field values matches the order of
// fields in the [StructType][google.spanner.v1.StructType]. In turn, the order of fields
// matches the order of columns in a read request, or the order of
// fields in the `SELECT` clause of a query.
repeated Field fields = 1;
}

// `TypeCode` is used as part of [Type][google.spanner.v1.Type] to
// indicate the type of a Cloud Spanner value.
//
Expand Down Expand Up @@ -75,45 +117,15 @@ enum TypeCode {
// Encoded as `list`, where list element `i` is represented according
// to [struct_type.fields[i]][google.spanner.v1.StructType.fields].
STRUCT = 9;
}

// `Type` indicates the type of a Cloud Spanner value, as might be stored in a
// table cell or returned from an SQL query.
message Type {
// Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
TypeCode code = 1;

// If [code][google.spanner.v1.Type.code] == [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type`
// is the type of the array elements.
Type array_element_type = 2;

// If [code][google.spanner.v1.Type.code] == [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type`
// provides type information for the struct's fields.
StructType struct_type = 3;
}

// `StructType` defines the fields of a [STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
message StructType {
// Message representing a single field of a struct.
message Field {
// The name of the field. For reads, this is the column name. For
// SQL queries, it is the column alias (e.g., `"Word"` in the
// query `"SELECT 'hello' AS Word"`), or the column name (e.g.,
// `"ColName"` in the query `"SELECT ColName FROM Table"`). Some
// columns might have an empty name (e.g., !"SELECT
// UPPER(ColName)"`). Note that a query result can contain
// multiple fields with the same name.
string name = 1;

// The type of the field.
Type type = 2;
}

// The list of fields that make up this struct. Order is
// significant, because values of this struct type are represented as
// lists, where the order of field values matches the order of
// fields in the [StructType][google.spanner.v1.StructType]. In turn, the order of fields
// matches the order of columns in a read request, or the order of
// fields in the `SELECT` clause of a query.
repeated Field fields = 1;
// Encoded as `string`, in decimal format or scientific notation format.
// <br>Decimal format:
// <br>`[+-]Digits[.[Digits]]` or
// <br>`[+-][Digits].Digits`
//
// Scientific notation:
// <br>`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
// <br>`[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
// <br>(ExponentIndicator is `"e"` or `"E"`)
NUMERIC = 10;
}
6 changes: 3 additions & 3 deletions synth.metadata
Expand Up @@ -4,15 +4,15 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/java-spanner.git",
"sha": "fd2485a6cd796be573b1be875f567c9ad74f3434"
"sha": "6ee83b5ce2e1c2a26ca83450f3a6b77f7c327b52"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "c29c4c519667a51c0e2cfddda9c3a66be77bdf38",
"internalRef": "320114059"
"sha": "59f97e6044a1275f83427ab7962a154c00d915b5",
"internalRef": "321058159"
}
},
{
Expand Down

0 comments on commit 78c3192

Please sign in to comment.