standard_sql.proto 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.bigquery.v2;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/annotations.proto";
  18. option go_package = "google.golang.org/genproto/googleapis/cloud/bigquery/v2;bigquery";
  19. option java_outer_classname = "StandardSqlProto";
  20. option java_package = "com.google.cloud.bigquery.v2";
  21. // The type of a variable, e.g., a function argument.
  22. // Examples:
  23. // INT64: {type_kind="INT64"}
  24. // ARRAY<STRING>: {type_kind="ARRAY", array_element_type="STRING"}
  25. // STRUCT<x STRING, y ARRAY<DATE>>:
  26. // {type_kind="STRUCT",
  27. // struct_type={fields=[
  28. // {name="x", type={type_kind="STRING"}},
  29. // {name="y", type={type_kind="ARRAY", array_element_type="DATE"}}
  30. // ]}}
  31. message StandardSqlDataType {
  32. enum TypeKind {
  33. // Invalid type.
  34. TYPE_KIND_UNSPECIFIED = 0;
  35. // Encoded as a string in decimal format.
  36. INT64 = 2;
  37. // Encoded as a boolean "false" or "true".
  38. BOOL = 5;
  39. // Encoded as a number, or string "NaN", "Infinity" or "-Infinity".
  40. FLOAT64 = 7;
  41. // Encoded as a string value.
  42. STRING = 8;
  43. // Encoded as a base64 string per RFC 4648, section 4.
  44. BYTES = 9;
  45. // Encoded as an RFC 3339 timestamp with mandatory "Z" time zone string:
  46. // 1985-04-12T23:20:50.52Z
  47. TIMESTAMP = 19;
  48. // Encoded as RFC 3339 full-date format string: 1985-04-12
  49. DATE = 10;
  50. // Encoded as RFC 3339 partial-time format string: 23:20:50.52
  51. TIME = 20;
  52. // Encoded as RFC 3339 full-date "T" partial-time: 1985-04-12T23:20:50.52
  53. DATETIME = 21;
  54. // Encoded as fully qualified 3 part: 0-5 15 2:30:45.6
  55. INTERVAL = 26;
  56. // Encoded as WKT
  57. GEOGRAPHY = 22;
  58. // Encoded as a decimal string.
  59. NUMERIC = 23;
  60. // Encoded as a decimal string.
  61. BIGNUMERIC = 24;
  62. // Encoded as a string.
  63. JSON = 25;
  64. // Encoded as a list with types matching Type.array_type.
  65. ARRAY = 16;
  66. // Encoded as a list with fields of type Type.struct_type[i]. List is used
  67. // because a JSON object cannot have duplicate field names.
  68. STRUCT = 17;
  69. }
  70. // Required. The top level type of this field.
  71. // Can be any standard SQL data type (e.g., "INT64", "DATE", "ARRAY").
  72. TypeKind type_kind = 1 [(google.api.field_behavior) = REQUIRED];
  73. oneof sub_type {
  74. // The type of the array's elements, if type_kind = "ARRAY".
  75. StandardSqlDataType array_element_type = 2;
  76. // The fields of this struct, in order, if type_kind = "STRUCT".
  77. StandardSqlStructType struct_type = 3;
  78. }
  79. }
  80. // A field or a column.
  81. message StandardSqlField {
  82. // Optional. The name of this field. Can be absent for struct fields.
  83. string name = 1 [(google.api.field_behavior) = OPTIONAL];
  84. // Optional. The type of this parameter. Absent if not explicitly
  85. // specified (e.g., CREATE FUNCTION statement can omit the return type;
  86. // in this case the output parameter does not have this "type" field).
  87. StandardSqlDataType type = 2 [(google.api.field_behavior) = OPTIONAL];
  88. }
  89. message StandardSqlStructType {
  90. repeated StandardSqlField fields = 1;
  91. }
  92. // A table type
  93. message StandardSqlTableType {
  94. // The columns in this table type
  95. repeated StandardSqlField columns = 1;
  96. }