Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: Spanner NUMERIC type
PiperOrigin-RevId: 321058159
  • Loading branch information
Google APIs authored and Copybara-Service committed Jul 13, 2020
1 parent a7ed6d4 commit 59f97e6
Showing 1 changed file with 52 additions and 40 deletions.
92 changes: 52 additions & 40 deletions google/spanner/v1/type.proto
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;
}

0 comments on commit 59f97e6

Please sign in to comment.