Skip to content

Commit 91b31ed

Browse files
feat: Spanner NUMERIC type
PiperOrigin-RevId: 321058159 Source-Author: Google APIs <noreply@google.com> Source-Date: Mon Jul 13 16:33:42 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: 59f97e6044a1275f83427ab7962a154c00d915b5 Source-Link: googleapis/googleapis@59f97e6
1 parent f89cd04 commit 91b31ed

File tree

6 files changed

+125
-69
lines changed

6 files changed

+125
-69
lines changed

proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Type.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
148148
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
149149
* </pre>
150150
*
151-
* <code>.google.spanner.v1.TypeCode code = 1;</code>
151+
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
152152
*
153153
* @return The enum numeric value on the wire for code.
154154
*/
@@ -163,7 +163,7 @@ public int getCodeValue() {
163163
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
164164
* </pre>
165165
*
166-
* <code>.google.spanner.v1.TypeCode code = 1;</code>
166+
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
167167
*
168168
* @return The code.
169169
*/
@@ -650,7 +650,7 @@ public Builder mergeFrom(
650650
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
651651
* </pre>
652652
*
653-
* <code>.google.spanner.v1.TypeCode code = 1;</code>
653+
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
654654
*
655655
* @return The enum numeric value on the wire for code.
656656
*/
@@ -665,7 +665,7 @@ public int getCodeValue() {
665665
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
666666
* </pre>
667667
*
668-
* <code>.google.spanner.v1.TypeCode code = 1;</code>
668+
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
669669
*
670670
* @param value The enum numeric value on the wire for code to set.
671671
* @return This builder for chaining.
@@ -683,7 +683,7 @@ public Builder setCodeValue(int value) {
683683
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
684684
* </pre>
685685
*
686-
* <code>.google.spanner.v1.TypeCode code = 1;</code>
686+
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
687687
*
688688
* @return The code.
689689
*/
@@ -700,7 +700,7 @@ public com.google.spanner.v1.TypeCode getCode() {
700700
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
701701
* </pre>
702702
*
703-
* <code>.google.spanner.v1.TypeCode code = 1;</code>
703+
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
704704
*
705705
* @param value The code to set.
706706
* @return This builder for chaining.
@@ -721,7 +721,7 @@ public Builder setCode(com.google.spanner.v1.TypeCode value) {
721721
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
722722
* </pre>
723723
*
724-
* <code>.google.spanner.v1.TypeCode code = 1;</code>
724+
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
725725
*
726726
* @return This builder for chaining.
727727
*/

proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java

+36
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,23 @@ public enum TypeCode implements com.google.protobuf.ProtocolMessageEnum {
144144
* <code>STRUCT = 9;</code>
145145
*/
146146
STRUCT(9),
147+
/**
148+
*
149+
*
150+
* <pre>
151+
* Encoded as `string`, in decimal format or scientific notation format.
152+
* &lt;br&gt;Decimal format:
153+
* &lt;br&gt;`[+-]Digits[.[Digits]]` or
154+
* &lt;br&gt;`[+-][Digits].Digits`
155+
* Scientific notation:
156+
* &lt;br&gt;`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
157+
* &lt;br&gt;`[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
158+
* &lt;br&gt;(ExponentIndicator is `"e"` or `"E"`)
159+
* </pre>
160+
*
161+
* <code>NUMERIC = 10;</code>
162+
*/
163+
NUMERIC(10),
147164
UNRECOGNIZED(-1),
148165
;
149166

@@ -258,6 +275,23 @@ public enum TypeCode implements com.google.protobuf.ProtocolMessageEnum {
258275
* <code>STRUCT = 9;</code>
259276
*/
260277
public static final int STRUCT_VALUE = 9;
278+
/**
279+
*
280+
*
281+
* <pre>
282+
* Encoded as `string`, in decimal format or scientific notation format.
283+
* &lt;br&gt;Decimal format:
284+
* &lt;br&gt;`[+-]Digits[.[Digits]]` or
285+
* &lt;br&gt;`[+-][Digits].Digits`
286+
* Scientific notation:
287+
* &lt;br&gt;`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
288+
* &lt;br&gt;`[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
289+
* &lt;br&gt;(ExponentIndicator is `"e"` or `"E"`)
290+
* </pre>
291+
*
292+
* <code>NUMERIC = 10;</code>
293+
*/
294+
public static final int NUMERIC_VALUE = 10;
261295

262296
public final int getNumber() {
263297
if (this == UNRECOGNIZED) {
@@ -303,6 +337,8 @@ public static TypeCode forNumber(int value) {
303337
return ARRAY;
304338
case 9:
305339
return STRUCT;
340+
case 10:
341+
return NUMERIC;
306342
default:
307343
return null;
308344
}

proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeOrBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public interface TypeOrBuilder
3030
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
3131
* </pre>
3232
*
33-
* <code>.google.spanner.v1.TypeCode code = 1;</code>
33+
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
3434
*
3535
* @return The enum numeric value on the wire for code.
3636
*/
@@ -42,7 +42,7 @@ public interface TypeOrBuilder
4242
* Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
4343
* </pre>
4444
*
45-
* <code>.google.spanner.v1.TypeCode code = 1;</code>
45+
* <code>.google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED];</code>
4646
*
4747
* @return The code.
4848
*/

proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeProto.java

+25-17
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,30 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
4949
static {
5050
java.lang.String[] descriptorData = {
5151
"\n\034google/spanner/v1/type.proto\022\021google.s"
52-
+ "panner.v1\032\034google/api/annotations.proto\""
53-
+ "\232\001\n\004Type\022)\n\004code\030\001 \001(\0162\033.google.spanner."
54-
+ "v1.TypeCode\0223\n\022array_element_type\030\002 \001(\0132"
55-
+ "\027.google.spanner.v1.Type\0222\n\013struct_type\030"
56-
+ "\003 \001(\0132\035.google.spanner.v1.StructType\"\177\n\n"
57-
+ "StructType\0223\n\006fields\030\001 \003(\0132#.google.span"
58-
+ "ner.v1.StructType.Field\032<\n\005Field\022\014\n\004name"
59-
+ "\030\001 \001(\t\022%\n\004type\030\002 \001(\0132\027.google.spanner.v1"
60-
+ ".Type*\216\001\n\010TypeCode\022\031\n\025TYPE_CODE_UNSPECIF"
61-
+ "IED\020\000\022\010\n\004BOOL\020\001\022\t\n\005INT64\020\002\022\013\n\007FLOAT64\020\003\022"
62-
+ "\r\n\tTIMESTAMP\020\004\022\010\n\004DATE\020\005\022\n\n\006STRING\020\006\022\t\n\005"
63-
+ "BYTES\020\007\022\t\n\005ARRAY\020\010\022\n\n\006STRUCT\020\tB\257\001\n\025com.g"
64-
+ "oogle.spanner.v1B\tTypeProtoP\001Z8google.go"
65-
+ "lang.org/genproto/googleapis/spanner/v1;"
66-
+ "spanner\252\002\027Google.Cloud.Spanner.V1\312\002\027Goog"
67-
+ "le\\Cloud\\Spanner\\V1\352\002\032Google::Cloud::Spa"
68-
+ "nner::V1b\006proto3"
52+
+ "panner.v1\032\037google/api/field_behavior.pro"
53+
+ "to\032\034google/api/annotations.proto\"\237\001\n\004Typ"
54+
+ "e\022.\n\004code\030\001 \001(\0162\033.google.spanner.v1.Type"
55+
+ "CodeB\003\340A\002\0223\n\022array_element_type\030\002 \001(\0132\027."
56+
+ "google.spanner.v1.Type\0222\n\013struct_type\030\003 "
57+
+ "\001(\0132\035.google.spanner.v1.StructType\"\177\n\nSt"
58+
+ "ructType\0223\n\006fields\030\001 \003(\0132#.google.spanne"
59+
+ "r.v1.StructType.Field\032<\n\005Field\022\014\n\004name\030\001"
60+
+ " \001(\t\022%\n\004type\030\002 \001(\0132\027.google.spanner.v1.T"
61+
+ "ype*\233\001\n\010TypeCode\022\031\n\025TYPE_CODE_UNSPECIFIE"
62+
+ "D\020\000\022\010\n\004BOOL\020\001\022\t\n\005INT64\020\002\022\013\n\007FLOAT64\020\003\022\r\n"
63+
+ "\tTIMESTAMP\020\004\022\010\n\004DATE\020\005\022\n\n\006STRING\020\006\022\t\n\005BY"
64+
+ "TES\020\007\022\t\n\005ARRAY\020\010\022\n\n\006STRUCT\020\t\022\013\n\007NUMERIC\020"
65+
+ "\nB\257\001\n\025com.google.spanner.v1B\tTypeProtoP\001"
66+
+ "Z8google.golang.org/genproto/googleapis/"
67+
+ "spanner/v1;spanner\252\002\027Google.Cloud.Spanne"
68+
+ "r.V1\312\002\027Google\\Cloud\\Spanner\\V1\352\002\032Google:"
69+
+ ":Cloud::Spanner::V1b\006proto3"
6970
};
7071
descriptor =
7172
com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(
7273
descriptorData,
7374
new com.google.protobuf.Descriptors.FileDescriptor[] {
75+
com.google.api.FieldBehaviorProto.getDescriptor(),
7476
com.google.api.AnnotationsProto.getDescriptor(),
7577
});
7678
internal_static_google_spanner_v1_Type_descriptor = getDescriptor().getMessageTypes().get(0);
@@ -96,6 +98,12 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
9698
new java.lang.String[] {
9799
"Name", "Type",
98100
});
101+
com.google.protobuf.ExtensionRegistry registry =
102+
com.google.protobuf.ExtensionRegistry.newInstance();
103+
registry.add(com.google.api.FieldBehaviorProto.fieldBehavior);
104+
com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor(
105+
descriptor, registry);
106+
com.google.api.FieldBehaviorProto.getDescriptor();
99107
com.google.api.AnnotationsProto.getDescriptor();
100108
}
101109

proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/type.proto

+52-40
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ syntax = "proto3";
1616

1717
package google.spanner.v1;
1818

19+
import "google/api/field_behavior.proto";
1920
import "google/api/annotations.proto";
2021

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

30+
// `Type` indicates the type of a Cloud Spanner value, as might be stored in a
31+
// table cell or returned from an SQL query.
32+
message Type {
33+
// Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
34+
TypeCode code = 1 [(google.api.field_behavior) = REQUIRED];
35+
36+
// If [code][google.spanner.v1.Type.code] == [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type`
37+
// is the type of the array elements.
38+
Type array_element_type = 2;
39+
40+
// If [code][google.spanner.v1.Type.code] == [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type`
41+
// provides type information for the struct's fields.
42+
StructType struct_type = 3;
43+
}
44+
45+
// `StructType` defines the fields of a [STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
46+
message StructType {
47+
// Message representing a single field of a struct.
48+
message Field {
49+
// The name of the field. For reads, this is the column name. For
50+
// SQL queries, it is the column alias (e.g., `"Word"` in the
51+
// query `"SELECT 'hello' AS Word"`), or the column name (e.g.,
52+
// `"ColName"` in the query `"SELECT ColName FROM Table"`). Some
53+
// columns might have an empty name (e.g., !"SELECT
54+
// UPPER(ColName)"`). Note that a query result can contain
55+
// multiple fields with the same name.
56+
string name = 1;
57+
58+
// The type of the field.
59+
Type type = 2;
60+
}
61+
62+
// The list of fields that make up this struct. Order is
63+
// significant, because values of this struct type are represented as
64+
// lists, where the order of field values matches the order of
65+
// fields in the [StructType][google.spanner.v1.StructType]. In turn, the order of fields
66+
// matches the order of columns in a read request, or the order of
67+
// fields in the `SELECT` clause of a query.
68+
repeated Field fields = 1;
69+
}
70+
2971
// `TypeCode` is used as part of [Type][google.spanner.v1.Type] to
3072
// indicate the type of a Cloud Spanner value.
3173
//
@@ -75,45 +117,15 @@ enum TypeCode {
75117
// Encoded as `list`, where list element `i` is represented according
76118
// to [struct_type.fields[i]][google.spanner.v1.StructType.fields].
77119
STRUCT = 9;
78-
}
79-
80-
// `Type` indicates the type of a Cloud Spanner value, as might be stored in a
81-
// table cell or returned from an SQL query.
82-
message Type {
83-
// Required. The [TypeCode][google.spanner.v1.TypeCode] for this type.
84-
TypeCode code = 1;
85-
86-
// If [code][google.spanner.v1.Type.code] == [ARRAY][google.spanner.v1.TypeCode.ARRAY], then `array_element_type`
87-
// is the type of the array elements.
88-
Type array_element_type = 2;
89-
90-
// If [code][google.spanner.v1.Type.code] == [STRUCT][google.spanner.v1.TypeCode.STRUCT], then `struct_type`
91-
// provides type information for the struct's fields.
92-
StructType struct_type = 3;
93-
}
94-
95-
// `StructType` defines the fields of a [STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
96-
message StructType {
97-
// Message representing a single field of a struct.
98-
message Field {
99-
// The name of the field. For reads, this is the column name. For
100-
// SQL queries, it is the column alias (e.g., `"Word"` in the
101-
// query `"SELECT 'hello' AS Word"`), or the column name (e.g.,
102-
// `"ColName"` in the query `"SELECT ColName FROM Table"`). Some
103-
// columns might have an empty name (e.g., !"SELECT
104-
// UPPER(ColName)"`). Note that a query result can contain
105-
// multiple fields with the same name.
106-
string name = 1;
107-
108-
// The type of the field.
109-
Type type = 2;
110-
}
111120

112-
// The list of fields that make up this struct. Order is
113-
// significant, because values of this struct type are represented as
114-
// lists, where the order of field values matches the order of
115-
// fields in the [StructType][google.spanner.v1.StructType]. In turn, the order of fields
116-
// matches the order of columns in a read request, or the order of
117-
// fields in the `SELECT` clause of a query.
118-
repeated Field fields = 1;
121+
// Encoded as `string`, in decimal format or scientific notation format.
122+
// <br>Decimal format:
123+
// <br>`[+-]Digits[.[Digits]]` or
124+
// <br>`[+-][Digits].Digits`
125+
//
126+
// Scientific notation:
127+
// <br>`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or
128+
// <br>`[+-][Digits].Digits[ExponentIndicator[+-]Digits]`
129+
// <br>(ExponentIndicator is `"e"` or `"E"`)
130+
NUMERIC = 10;
119131
}

synth.metadata

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/java-spanner.git",
7-
"sha": "fd2485a6cd796be573b1be875f567c9ad74f3434"
7+
"sha": "f89cd040a308badb46b5f3847242c6474df78df9"
88
}
99
},
1010
{
1111
"git": {
1212
"name": "googleapis",
1313
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "c29c4c519667a51c0e2cfddda9c3a66be77bdf38",
15-
"internalRef": "320114059"
14+
"sha": "59f97e6044a1275f83427ab7962a154c00d915b5",
15+
"internalRef": "321058159"
1616
}
1717
},
1818
{

0 commit comments

Comments
 (0)