/
type.proto
131 lines (110 loc) · 4.69 KB
/
type.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.spanner.v1;
import "google/api/field_behavior.proto";
import "google/api/annotations.proto";
option csharp_namespace = "Google.Cloud.Spanner.V1";
option go_package = "google.golang.org/genproto/googleapis/spanner/v1;spanner";
option java_multiple_files = true;
option java_outer_classname = "TypeProto";
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.
//
// Each legal value of a type can be encoded to or decoded from a JSON
// value, using the encodings described below. All Cloud Spanner values can
// be `null`, regardless of type; `null`s are always encoded as a JSON
// `null`.
enum TypeCode {
// Not specified.
TYPE_CODE_UNSPECIFIED = 0;
// Encoded as JSON `true` or `false`.
BOOL = 1;
// Encoded as `string`, in decimal format.
INT64 = 2;
// Encoded as `number`, or the strings `"NaN"`, `"Infinity"`, or
// `"-Infinity"`.
FLOAT64 = 3;
// Encoded as `string` in RFC 3339 timestamp format. The time zone
// must be present, and must be `"Z"`.
//
// If the schema has the column option
// `allow_commit_timestamp=true`, the placeholder string
// `"spanner.commit_timestamp()"` can be used to instruct the system
// to insert the commit timestamp associated with the transaction
// commit.
TIMESTAMP = 4;
// Encoded as `string` in RFC 3339 date format.
DATE = 5;
// Encoded as `string`.
STRING = 6;
// Encoded as a base64-encoded `string`, as described in RFC 4648,
// section 4.
BYTES = 7;
// Encoded as `list`, where the list elements are represented
// according to
// [array_element_type][google.spanner.v1.Type.array_element_type].
ARRAY = 8;
// Encoded as `list`, where list element `i` is represented according
// to [struct_type.fields[i]][google.spanner.v1.StructType.fields].
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;
}