gcloud 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/CHANGELOG.md +7 -0
- data/lib/gcloud/bigquery/schema.rb +2 -2
- data/lib/gcloud/bigquery/table.rb +220 -1
- data/lib/gcloud/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OThmNGI2N2Q2MjdmYTUwZWJkMWFjZWFlZjliMDA0NGRmNmFlZmYwNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDVjY2QyZjVlZjQ0MjlhOWVmMjY3MDQxNDUxOGRkZTdkNDgxMDQ3Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTU5YjQ2ZWMxZjk5MDE2ZWYzMGE1NTNiNTg0NzkyNWM0ODJjZWFlYjc0NDA4
|
10
|
+
Y2M3NzNhM2NjOTc1MmIwNzhjNDg5NzRkNGJlYTU2YWU4YmFhOGQwMmU4Y2Nk
|
11
|
+
NjEwNTlmMjQzYjg1MzM2ODJlMzc2MzE4N2RiZmYwNjQ5MzQ3OTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTQzYjkxZmZjMmFiMTM2MTU3MjkzZWQwNTFiOTE0ODI2YWM4YjMwZmY2ZjJl
|
14
|
+
ZmVmNmExYzZlZDMzMWMxOGVhMzcwOTFkYjE4ZjM3NTdlMzU3MGQyMjY3MWI5
|
15
|
+
MTBhYjBmMGFhODcyMzg1OTVmMGI1YjljY2M5M2I5NGM3MjY1YzM=
|
data/CHANGELOG.md
CHANGED
@@ -197,8 +197,8 @@ module Gcloud
|
|
197
197
|
# `:nullable`, `:required`, and `:repeated`. The default value is
|
198
198
|
# `:nullable`.
|
199
199
|
# @yield [nested_schema] a block for setting the nested schema
|
200
|
-
# @yieldparam [
|
201
|
-
#
|
200
|
+
# @yieldparam [Schema] nested_schema the object accepting the nested
|
201
|
+
# schema
|
202
202
|
#
|
203
203
|
# @example
|
204
204
|
# require "gcloud"
|
@@ -325,7 +325,7 @@ module Gcloud
|
|
325
325
|
# already contains data, schema changes must be additive. Thus, the
|
326
326
|
# default value is `false`.
|
327
327
|
# @yield [schema] a block for setting the schema
|
328
|
-
# @yieldparam [
|
328
|
+
# @yieldparam [Schema] schema the object accepting the schema
|
329
329
|
#
|
330
330
|
# @return [Gcloud::Bigquery::Schema]
|
331
331
|
#
|
@@ -871,6 +871,41 @@ module Gcloud
|
|
871
871
|
@schema = nil
|
872
872
|
end
|
873
873
|
|
874
|
+
##
|
875
|
+
# Returns the table's schema. This method can also be used to set,
|
876
|
+
# replace, or add to the schema by passing a block. See {Schema} for
|
877
|
+
# available methods.
|
878
|
+
#
|
879
|
+
# @param [Boolean] replace Whether to replace the existing schema with
|
880
|
+
# the new schema. If `true`, the fields will replace the existing
|
881
|
+
# schema. If `false`, the fields will be added to the existing
|
882
|
+
# schema. When a table already contains data, schema changes must be
|
883
|
+
# additive. Thus, the default value is `false`.
|
884
|
+
# @yield [schema] a block for setting the schema
|
885
|
+
# @yieldparam [Schema] schema the object accepting the schema
|
886
|
+
#
|
887
|
+
# @return [Gcloud::Bigquery::Schema]
|
888
|
+
#
|
889
|
+
# @example
|
890
|
+
# require "gcloud"
|
891
|
+
#
|
892
|
+
# gcloud = Gcloud.new
|
893
|
+
# bigquery = gcloud.bigquery
|
894
|
+
# dataset = bigquery.dataset "my_dataset"
|
895
|
+
# table = dataset.create_table "my_table" do |t|
|
896
|
+
# t.name = "My Table",
|
897
|
+
# t.description = "A description of my table."
|
898
|
+
# t.schema do |s|
|
899
|
+
# s.string "first_name", mode: :required
|
900
|
+
# s.record "cities_lived", mode: :repeated do |r|
|
901
|
+
# r.string "place", mode: :required
|
902
|
+
# r.integer "number_of_years", mode: :required
|
903
|
+
# end
|
904
|
+
# end
|
905
|
+
# end
|
906
|
+
#
|
907
|
+
# @!group Schema
|
908
|
+
#
|
874
909
|
def schema replace: false
|
875
910
|
# Same as Table#schema, but not frozen
|
876
911
|
# TODO: make sure to call ensure_full_data! on Dataset#update
|
@@ -887,6 +922,190 @@ module Gcloud
|
|
887
922
|
@schema
|
888
923
|
end
|
889
924
|
|
925
|
+
##
|
926
|
+
# Adds a string field to the schema.
|
927
|
+
#
|
928
|
+
# See {Schema#string}.
|
929
|
+
#
|
930
|
+
# @param [String] name The field name. The name must contain only
|
931
|
+
# letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
|
932
|
+
# start with a letter or underscore. The maximum length is 128
|
933
|
+
# characters.
|
934
|
+
# @param [String] description A description of the field.
|
935
|
+
# @param [Symbol] mode The field's mode. The possible values are
|
936
|
+
# `:nullable`, `:required`, and `:repeated`. The default value is
|
937
|
+
# `:nullable`.
|
938
|
+
#
|
939
|
+
# @example
|
940
|
+
# require "gcloud"
|
941
|
+
#
|
942
|
+
# gcloud = Gcloud.new
|
943
|
+
# bigquery = gcloud.bigquery
|
944
|
+
# dataset = bigquery.dataset "my_dataset"
|
945
|
+
# table = dataset.create_table "my_table" do |schema|
|
946
|
+
# schema.string "first_name", mode: :required
|
947
|
+
# end
|
948
|
+
#
|
949
|
+
# @!group Schema
|
950
|
+
def string name, description: nil, mode: :nullable
|
951
|
+
schema.string name, description: description, mode: mode
|
952
|
+
end
|
953
|
+
|
954
|
+
##
|
955
|
+
# Adds an integer field to the schema.
|
956
|
+
#
|
957
|
+
# See {Schema#integer}.
|
958
|
+
#
|
959
|
+
# @param [String] name The field name. The name must contain only
|
960
|
+
# letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
|
961
|
+
# start with a letter or underscore. The maximum length is 128
|
962
|
+
# characters.
|
963
|
+
# @param [String] description A description of the field.
|
964
|
+
# @param [Symbol] mode The field's mode. The possible values are
|
965
|
+
# `:nullable`, `:required`, and `:repeated`. The default value is
|
966
|
+
# `:nullable`.
|
967
|
+
#
|
968
|
+
# @example
|
969
|
+
# require "gcloud"
|
970
|
+
#
|
971
|
+
# gcloud = Gcloud.new
|
972
|
+
# bigquery = gcloud.bigquery
|
973
|
+
# dataset = bigquery.dataset "my_dataset"
|
974
|
+
# table = dataset.create_table "my_table" do |schema|
|
975
|
+
# schema.integer "age", mode: :required
|
976
|
+
# end
|
977
|
+
#
|
978
|
+
# @!group Schema
|
979
|
+
def integer name, description: nil, mode: :nullable
|
980
|
+
schema.integer name, description: description, mode: mode
|
981
|
+
end
|
982
|
+
|
983
|
+
##
|
984
|
+
# Adds a floating-point number field to the schema.
|
985
|
+
#
|
986
|
+
# See {Schema#float}.
|
987
|
+
#
|
988
|
+
# @param [String] name The field name. The name must contain only
|
989
|
+
# letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
|
990
|
+
# start with a letter or underscore. The maximum length is 128
|
991
|
+
# characters.
|
992
|
+
# @param [String] description A description of the field.
|
993
|
+
# @param [Symbol] mode The field's mode. The possible values are
|
994
|
+
# `:nullable`, `:required`, and `:repeated`. The default value is
|
995
|
+
# `:nullable`.
|
996
|
+
#
|
997
|
+
# @example
|
998
|
+
# require "gcloud"
|
999
|
+
#
|
1000
|
+
# gcloud = Gcloud.new
|
1001
|
+
# bigquery = gcloud.bigquery
|
1002
|
+
# dataset = bigquery.dataset "my_dataset"
|
1003
|
+
# table = dataset.create_table "my_table" do |schema|
|
1004
|
+
# schema.float "price", mode: :required
|
1005
|
+
# end
|
1006
|
+
#
|
1007
|
+
# @!group Schema
|
1008
|
+
def float name, description: nil, mode: :nullable
|
1009
|
+
schema.float name, description: description, mode: mode
|
1010
|
+
end
|
1011
|
+
|
1012
|
+
##
|
1013
|
+
# Adds a boolean field to the schema.
|
1014
|
+
#
|
1015
|
+
# See {Schema#boolean}.
|
1016
|
+
#
|
1017
|
+
# @param [String] name The field name. The name must contain only
|
1018
|
+
# letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
|
1019
|
+
# start with a letter or underscore. The maximum length is 128
|
1020
|
+
# characters.
|
1021
|
+
# @param [String] description A description of the field.
|
1022
|
+
# @param [Symbol] mode The field's mode. The possible values are
|
1023
|
+
# `:nullable`, `:required`, and `:repeated`. The default value is
|
1024
|
+
# `:nullable`.
|
1025
|
+
#
|
1026
|
+
# @example
|
1027
|
+
# require "gcloud"
|
1028
|
+
#
|
1029
|
+
# gcloud = Gcloud.new
|
1030
|
+
# bigquery = gcloud.bigquery
|
1031
|
+
# dataset = bigquery.dataset "my_dataset"
|
1032
|
+
# table = dataset.create_table "my_table" do |schema|
|
1033
|
+
# schema.boolean "active", mode: :required
|
1034
|
+
# end
|
1035
|
+
#
|
1036
|
+
# @!group Schema
|
1037
|
+
def boolean name, description: nil, mode: :nullable
|
1038
|
+
schema.boolean name, description: description, mode: mode
|
1039
|
+
end
|
1040
|
+
|
1041
|
+
##
|
1042
|
+
# Adds a timestamp field to the schema.
|
1043
|
+
#
|
1044
|
+
# See {Schema#timestamp}.
|
1045
|
+
#
|
1046
|
+
# @param [String] name The field name. The name must contain only
|
1047
|
+
# letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
|
1048
|
+
# start with a letter or underscore. The maximum length is 128
|
1049
|
+
# characters.
|
1050
|
+
# @param [String] description A description of the field.
|
1051
|
+
# @param [Symbol] mode The field's mode. The possible values are
|
1052
|
+
# `:nullable`, `:required`, and `:repeated`. The default value is
|
1053
|
+
# `:nullable`.
|
1054
|
+
#
|
1055
|
+
# @example
|
1056
|
+
# require "gcloud"
|
1057
|
+
#
|
1058
|
+
# gcloud = Gcloud.new
|
1059
|
+
# bigquery = gcloud.bigquery
|
1060
|
+
# dataset = bigquery.dataset "my_dataset"
|
1061
|
+
# table = dataset.create_table "my_table" do |schema|
|
1062
|
+
# schema.timestamp "creation_date", mode: :required
|
1063
|
+
# end
|
1064
|
+
#
|
1065
|
+
# @!group Schema
|
1066
|
+
def timestamp name, description: nil, mode: :nullable
|
1067
|
+
schema.timestamp name, description: description, mode: mode
|
1068
|
+
end
|
1069
|
+
|
1070
|
+
##
|
1071
|
+
# Adds a record field to the schema. A block must be passed describing
|
1072
|
+
# the nested fields of the record. For more information about nested
|
1073
|
+
# and repeated records, see [Preparing Data for BigQuery
|
1074
|
+
# ](https://cloud.google.com/bigquery/preparing-data-for-bigquery).
|
1075
|
+
#
|
1076
|
+
# See {Schema#record}.
|
1077
|
+
#
|
1078
|
+
# @param [String] name The field name. The name must contain only
|
1079
|
+
# letters (a-z, A-Z), numbers (0-9), or underscores (_), and must
|
1080
|
+
# start with a letter or underscore. The maximum length is 128
|
1081
|
+
# characters.
|
1082
|
+
# @param [String] description A description of the field.
|
1083
|
+
# @param [Symbol] mode The field's mode. The possible values are
|
1084
|
+
# `:nullable`, `:required`, and `:repeated`. The default value is
|
1085
|
+
# `:nullable`.
|
1086
|
+
# @yield [nested_schema] a block for setting the nested schema
|
1087
|
+
# @yieldparam [Schema] nested_schema the object accepting the
|
1088
|
+
# nested schema
|
1089
|
+
#
|
1090
|
+
# @example
|
1091
|
+
# require "gcloud"
|
1092
|
+
#
|
1093
|
+
# gcloud = Gcloud.new
|
1094
|
+
# bigquery = gcloud.bigquery
|
1095
|
+
# dataset = bigquery.dataset "my_dataset"
|
1096
|
+
# table = dataset.create_table "my_table" do |schema|
|
1097
|
+
# schema.record "cities_lived", mode: :repeated do |cities_lived|
|
1098
|
+
# cities_lived.string "place", mode: :required
|
1099
|
+
# cities_lived.integer "number_of_years", mode: :required
|
1100
|
+
# end
|
1101
|
+
# end
|
1102
|
+
#
|
1103
|
+
# @!group Schema
|
1104
|
+
#
|
1105
|
+
def record name, description: nil, mode: nil, &block
|
1106
|
+
schema.record name, description: description, mode: mode, &block
|
1107
|
+
end
|
1108
|
+
|
890
1109
|
##
|
891
1110
|
# Make sure any access changes are saved
|
892
1111
|
def check_for_mutated_schema!
|
data/lib/gcloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Silvano Luciani
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-08-
|
13
|
+
date: 2016-08-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: grpc
|