From 78c3192266c474fc43277a8bf3f15caa968a0100 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 14 Jul 2020 23:02:10 -0700 Subject: [PATCH] feat: spanner NUMERIC type (#349) This PR was generated using Autosynth. :rainbow: 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: https://github.com/googleapis/googleapis/commit/59f97e6044a1275f83427ab7962a154c00d915b5 --- README.md | 2 +- .../main/java/com/google/spanner/v1/Type.java | 14 +-- .../java/com/google/spanner/v1/TypeCode.java | 36 ++++++++ .../com/google/spanner/v1/TypeOrBuilder.java | 4 +- .../java/com/google/spanner/v1/TypeProto.java | 42 +++++---- .../main/proto/google/spanner/v1/type.proto | 92 +++++++++++-------- synth.metadata | 6 +- 7 files changed, 126 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 23bd5c6cde..918b6f4abf 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud libraries-bom - 8.0.0 + 8.1.0 pom import diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Type.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Type.java index eb4454331b..f02ccb4e13 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Type.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/Type.java @@ -148,7 +148,7 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. * * - * .google.spanner.v1.TypeCode code = 1; + * .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The enum numeric value on the wire for code. */ @@ -163,7 +163,7 @@ public int getCodeValue() { * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. * * - * .google.spanner.v1.TypeCode code = 1; + * .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The code. */ @@ -650,7 +650,7 @@ public Builder mergeFrom( * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. * * - * .google.spanner.v1.TypeCode code = 1; + * .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The enum numeric value on the wire for code. */ @@ -665,7 +665,7 @@ public int getCodeValue() { * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. * * - * .google.spanner.v1.TypeCode code = 1; + * .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The enum numeric value on the wire for code to set. * @return This builder for chaining. @@ -683,7 +683,7 @@ public Builder setCodeValue(int value) { * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. * * - * .google.spanner.v1.TypeCode code = 1; + * .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The code. */ @@ -700,7 +700,7 @@ public com.google.spanner.v1.TypeCode getCode() { * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. * * - * .google.spanner.v1.TypeCode code = 1; + * .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The code to set. * @return This builder for chaining. @@ -721,7 +721,7 @@ public Builder setCode(com.google.spanner.v1.TypeCode value) { * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. * * - * .google.spanner.v1.TypeCode code = 1; + * .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return This builder for chaining. */ diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java index 1f1087e879..77d751575c 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java @@ -144,6 +144,23 @@ public enum TypeCode implements com.google.protobuf.ProtocolMessageEnum { * STRUCT = 9; */ STRUCT(9), + /** + * + * + *
+   * 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; + */ + NUMERIC(10), UNRECOGNIZED(-1), ; @@ -258,6 +275,23 @@ public enum TypeCode implements com.google.protobuf.ProtocolMessageEnum { * STRUCT = 9; */ public static final int STRUCT_VALUE = 9; + /** + * + * + *
+   * 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; + */ + public static final int NUMERIC_VALUE = 10; public final int getNumber() { if (this == UNRECOGNIZED) { @@ -303,6 +337,8 @@ public static TypeCode forNumber(int value) { return ARRAY; case 9: return STRUCT; + case 10: + return NUMERIC; default: return null; } diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeOrBuilder.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeOrBuilder.java index 032553cbfc..bd37d1e7d2 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeOrBuilder.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeOrBuilder.java @@ -30,7 +30,7 @@ public interface TypeOrBuilder * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. * * - * .google.spanner.v1.TypeCode code = 1; + * .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The enum numeric value on the wire for code. */ @@ -42,7 +42,7 @@ public interface TypeOrBuilder * Required. The [TypeCode][google.spanner.v1.TypeCode] for this type. * * - * .google.spanner.v1.TypeCode code = 1; + * .google.spanner.v1.TypeCode code = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The code. */ diff --git a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeProto.java b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeProto.java index 1cc1230c3c..042f242919 100644 --- a/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeProto.java +++ b/proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeProto.java @@ -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); @@ -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(); } diff --git a/proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/type.proto b/proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/type.proto index eebed5a49b..1e5e5ff313 100644 --- a/proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/type.proto +++ b/proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/type.proto @@ -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"; @@ -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. // @@ -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. + //
Decimal format: + //
`[+-]Digits[.[Digits]]` or + //
`[+-][Digits].Digits` + // + // Scientific notation: + //
`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or + //
`[+-][Digits].Digits[ExponentIndicator[+-]Digits]` + //
(ExponentIndicator is `"e"` or `"E"`) + NUMERIC = 10; } diff --git a/synth.metadata b/synth.metadata index 4827caeb9f..2907acc5f7 100644 --- a/synth.metadata +++ b/synth.metadata @@ -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" } }, {