google-cloud-bigquery 1.42.0 → 1.43.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3528,6 +3528,22 @@ module Google
3528
3528
  # At most 1 policy tag is currently allowed.
3529
3529
  # @param [Integer] max_length The maximum UTF-8 length of strings
3530
3530
  # allowed in the field.
3531
+ # @param default_value_expression [String] The default value of a field
3532
+ # using a SQL expression. It can only be set for top level fields (columns).
3533
+ # Use a struct or array expression to specify default value for the entire struct or
3534
+ # array. The valid SQL expressions are:
3535
+ # - Literals for all data types, including STRUCT and ARRAY.
3536
+ # - The following functions:
3537
+ # `CURRENT_TIMESTAMP`
3538
+ # `CURRENT_TIME`
3539
+ # `CURRENT_DATE`
3540
+ # `CURRENT_DATETIME`
3541
+ # `GENERATE_UUID`
3542
+ # `RAND`
3543
+ # `SESSION_USER`
3544
+ # `ST_GEOPOINT`
3545
+ # - Struct or array composed with the above allowed functions, for example:
3546
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3531
3547
  #
3532
3548
  # @example
3533
3549
  # require "google/cloud/bigquery"
@@ -3538,9 +3554,20 @@ module Google
3538
3554
  # schema.string "first_name", mode: :required
3539
3555
  # end
3540
3556
  #
3557
+ # @example Add field with default value.
3558
+ # require "google/cloud/bigquery"
3559
+ #
3560
+ # bigquery = Google::Cloud::Bigquery.new
3561
+ # dataset = bigquery.dataset "my_dataset"
3562
+ # table = dataset.create_table "my_table" do |schema|
3563
+ # schema.string "first_name", default_value_expression: "'name'"
3564
+ # end
3565
+ #
3541
3566
  # @!group Schema
3542
- def string name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
3543
- schema.string name, description: description, mode: mode, policy_tags: policy_tags, max_length: max_length
3567
+ def string name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil,
3568
+ default_value_expression: nil
3569
+ schema.string name, description: description, mode: mode, policy_tags: policy_tags, max_length: max_length,
3570
+ default_value_expression: default_value_expression
3544
3571
  end
3545
3572
 
3546
3573
  ##
@@ -3560,6 +3587,22 @@ module Google
3560
3587
  # single policy tag for the field. Policy tag identifiers are of
3561
3588
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
3562
3589
  # At most 1 policy tag is currently allowed.
3590
+ # @param default_value_expression [String] The default value of a field
3591
+ # using a SQL expression. It can only be set for top level fields (columns).
3592
+ # Use a struct or array expression to specify default value for the entire struct or
3593
+ # array. The valid SQL expressions are:
3594
+ # - Literals for all data types, including STRUCT and ARRAY.
3595
+ # - The following functions:
3596
+ # `CURRENT_TIMESTAMP`
3597
+ # `CURRENT_TIME`
3598
+ # `CURRENT_DATE`
3599
+ # `CURRENT_DATETIME`
3600
+ # `GENERATE_UUID`
3601
+ # `RAND`
3602
+ # `SESSION_USER`
3603
+ # `ST_GEOPOINT`
3604
+ # - Struct or array composed with the above allowed functions, for example:
3605
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3563
3606
  #
3564
3607
  # @example
3565
3608
  # require "google/cloud/bigquery"
@@ -3570,9 +3613,20 @@ module Google
3570
3613
  # schema.integer "age", mode: :required
3571
3614
  # end
3572
3615
  #
3616
+ # @example Add field with default value.
3617
+ # require "google/cloud/bigquery"
3618
+ #
3619
+ # bigquery = Google::Cloud::Bigquery.new
3620
+ # dataset = bigquery.dataset "my_dataset"
3621
+ # table = dataset.create_table "my_table" do |schema|
3622
+ # schema.integer "age", default_value_expression: "1"
3623
+ # end
3624
+ #
3573
3625
  # @!group Schema
3574
- def integer name, description: nil, mode: :nullable, policy_tags: nil
3575
- schema.integer name, description: description, mode: mode, policy_tags: policy_tags
3626
+ def integer name, description: nil, mode: :nullable, policy_tags: nil,
3627
+ default_value_expression: nil
3628
+ schema.integer name, description: description, mode: mode, policy_tags: policy_tags,
3629
+ default_value_expression: default_value_expression
3576
3630
  end
3577
3631
 
3578
3632
  ##
@@ -3592,6 +3646,22 @@ module Google
3592
3646
  # single policy tag for the field. Policy tag identifiers are of
3593
3647
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
3594
3648
  # At most 1 policy tag is currently allowed.
3649
+ # @param default_value_expression [String] The default value of a field
3650
+ # using a SQL expression. It can only be set for top level fields (columns).
3651
+ # Use a struct or array expression to specify default value for the entire struct or
3652
+ # array. The valid SQL expressions are:
3653
+ # - Literals for all data types, including STRUCT and ARRAY.
3654
+ # - The following functions:
3655
+ # `CURRENT_TIMESTAMP`
3656
+ # `CURRENT_TIME`
3657
+ # `CURRENT_DATE`
3658
+ # `CURRENT_DATETIME`
3659
+ # `GENERATE_UUID`
3660
+ # `RAND`
3661
+ # `SESSION_USER`
3662
+ # `ST_GEOPOINT`
3663
+ # - Struct or array composed with the above allowed functions, for example:
3664
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3595
3665
  #
3596
3666
  # @example
3597
3667
  # require "google/cloud/bigquery"
@@ -3602,9 +3672,20 @@ module Google
3602
3672
  # schema.float "price", mode: :required
3603
3673
  # end
3604
3674
  #
3675
+ # @example Add field with default value.
3676
+ # require "google/cloud/bigquery"
3677
+ #
3678
+ # bigquery = Google::Cloud::Bigquery.new
3679
+ # dataset = bigquery.dataset "my_dataset"
3680
+ # table = dataset.create_table "my_table" do |schema|
3681
+ # schema.float "price", default_value_expression: "1.0"
3682
+ # end
3683
+ #
3605
3684
  # @!group Schema
3606
- def float name, description: nil, mode: :nullable, policy_tags: nil
3607
- schema.float name, description: description, mode: mode, policy_tags: policy_tags
3685
+ def float name, description: nil, mode: :nullable, policy_tags: nil,
3686
+ default_value_expression: nil
3687
+ schema.float name, description: description, mode: mode, policy_tags: policy_tags,
3688
+ default_value_expression: default_value_expression
3608
3689
  end
3609
3690
 
3610
3691
  ##
@@ -3645,6 +3726,22 @@ module Google
3645
3726
  # must be: `1 ≤ (precision - scale) ≤ 29`. Values for scale must
3646
3727
  # be: `0 ≤ scale ≤ 9`. If the scale value is set, the precision
3647
3728
  # value must be set as well.
3729
+ # @param default_value_expression [String] The default value of a field
3730
+ # using a SQL expression. It can only be set for top level fields (columns).
3731
+ # Use a struct or array expression to specify default value for the entire struct or
3732
+ # array. The valid SQL expressions are:
3733
+ # - Literals for all data types, including STRUCT and ARRAY.
3734
+ # - The following functions:
3735
+ # `CURRENT_TIMESTAMP`
3736
+ # `CURRENT_TIME`
3737
+ # `CURRENT_DATE`
3738
+ # `CURRENT_DATETIME`
3739
+ # `GENERATE_UUID`
3740
+ # `RAND`
3741
+ # `SESSION_USER`
3742
+ # `ST_GEOPOINT`
3743
+ # - Struct or array composed with the above allowed functions, for example:
3744
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3648
3745
  #
3649
3746
  # @example
3650
3747
  # require "google/cloud/bigquery"
@@ -3655,14 +3752,25 @@ module Google
3655
3752
  # schema.numeric "total_cost", mode: :required
3656
3753
  # end
3657
3754
  #
3755
+ # @example Add field with default value.
3756
+ # require "google/cloud/bigquery"
3757
+ #
3758
+ # bigquery = Google::Cloud::Bigquery.new
3759
+ # dataset = bigquery.dataset "my_dataset"
3760
+ # table = dataset.create_table "my_table" do |schema|
3761
+ # schema.numeric "total_cost", default_value_expression: "1.0e4"
3762
+ # end
3763
+ #
3658
3764
  # @!group Schema
3659
- def numeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil
3765
+ def numeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil,
3766
+ default_value_expression: nil
3660
3767
  schema.numeric name,
3661
3768
  description: description,
3662
3769
  mode: mode,
3663
3770
  policy_tags: policy_tags,
3664
3771
  precision: precision,
3665
- scale: scale
3772
+ scale: scale,
3773
+ default_value_expression: default_value_expression
3666
3774
  end
3667
3775
 
3668
3776
  ##
@@ -3703,6 +3811,22 @@ module Google
3703
3811
  # must be: `1 ≤ (precision - scale) ≤ 38`. Values for scale must
3704
3812
  # be: `0 ≤ scale ≤ 38`. If the scale value is set, the precision
3705
3813
  # value must be set as well.
3814
+ # @param default_value_expression [String] The default value of a field
3815
+ # using a SQL expression. It can only be set for top level fields (columns).
3816
+ # Use a struct or array expression to specify default value for the entire struct or
3817
+ # array. The valid SQL expressions are:
3818
+ # - Literals for all data types, including STRUCT and ARRAY.
3819
+ # - The following functions:
3820
+ # `CURRENT_TIMESTAMP`
3821
+ # `CURRENT_TIME`
3822
+ # `CURRENT_DATE`
3823
+ # `CURRENT_DATETIME`
3824
+ # `GENERATE_UUID`
3825
+ # `RAND`
3826
+ # `SESSION_USER`
3827
+ # `ST_GEOPOINT`
3828
+ # - Struct or array composed with the above allowed functions, for example:
3829
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3706
3830
  #
3707
3831
  # @example
3708
3832
  # require "google/cloud/bigquery"
@@ -3713,14 +3837,25 @@ module Google
3713
3837
  # schema.bignumeric "total_cost", mode: :required
3714
3838
  # end
3715
3839
  #
3840
+ # @example Add field with default value.
3841
+ # require "google/cloud/bigquery"
3842
+ #
3843
+ # bigquery = Google::Cloud::Bigquery.new
3844
+ # dataset = bigquery.dataset "my_dataset"
3845
+ # table = dataset.create_table "my_table" do |schema|
3846
+ # schema.bignumeric "total_cost", default_value_expression: "1.0e4"
3847
+ # end
3848
+ #
3716
3849
  # @!group Schema
3717
- def bignumeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil
3850
+ def bignumeric name, description: nil, mode: :nullable, policy_tags: nil, precision: nil, scale: nil,
3851
+ default_value_expression: nil
3718
3852
  schema.bignumeric name,
3719
3853
  description: description,
3720
3854
  mode: mode,
3721
3855
  policy_tags: policy_tags,
3722
3856
  precision: precision,
3723
- scale: scale
3857
+ scale: scale,
3858
+ default_value_expression: default_value_expression
3724
3859
  end
3725
3860
 
3726
3861
  ##
@@ -3740,6 +3875,22 @@ module Google
3740
3875
  # single policy tag for the field. Policy tag identifiers are of
3741
3876
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
3742
3877
  # At most 1 policy tag is currently allowed.
3878
+ # @param default_value_expression [String] The default value of a field
3879
+ # using a SQL expression. It can only be set for top level fields (columns).
3880
+ # Use a struct or array expression to specify default value for the entire struct or
3881
+ # array. The valid SQL expressions are:
3882
+ # - Literals for all data types, including STRUCT and ARRAY.
3883
+ # - The following functions:
3884
+ # `CURRENT_TIMESTAMP`
3885
+ # `CURRENT_TIME`
3886
+ # `CURRENT_DATE`
3887
+ # `CURRENT_DATETIME`
3888
+ # `GENERATE_UUID`
3889
+ # `RAND`
3890
+ # `SESSION_USER`
3891
+ # `ST_GEOPOINT`
3892
+ # - Struct or array composed with the above allowed functions, for example:
3893
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3743
3894
  #
3744
3895
  # @example
3745
3896
  # require "google/cloud/bigquery"
@@ -3750,9 +3901,20 @@ module Google
3750
3901
  # schema.boolean "active", mode: :required
3751
3902
  # end
3752
3903
  #
3904
+ # @example Add field with default value.
3905
+ # require "google/cloud/bigquery"
3906
+ #
3907
+ # bigquery = Google::Cloud::Bigquery.new
3908
+ # dataset = bigquery.dataset "my_dataset"
3909
+ # table = dataset.create_table "my_table" do |schema|
3910
+ # schema.boolean "active", default_value_expression: "true"
3911
+ # end
3912
+ #
3753
3913
  # @!group Schema
3754
- def boolean name, description: nil, mode: :nullable, policy_tags: nil
3755
- schema.boolean name, description: description, mode: mode, policy_tags: policy_tags
3914
+ def boolean name, description: nil, mode: :nullable, policy_tags: nil,
3915
+ default_value_expression: nil
3916
+ schema.boolean name, description: description, mode: mode, policy_tags: policy_tags,
3917
+ default_value_expression: default_value_expression
3756
3918
  end
3757
3919
 
3758
3920
  ##
@@ -3774,6 +3936,22 @@ module Google
3774
3936
  # At most 1 policy tag is currently allowed.
3775
3937
  # @param [Integer] max_length The maximum the maximum number of
3776
3938
  # bytes in the field.
3939
+ # @param default_value_expression [String] The default value of a field
3940
+ # using a SQL expression. It can only be set for top level fields (columns).
3941
+ # Use a struct or array expression to specify default value for the entire struct or
3942
+ # array. The valid SQL expressions are:
3943
+ # - Literals for all data types, including STRUCT and ARRAY.
3944
+ # - The following functions:
3945
+ # `CURRENT_TIMESTAMP`
3946
+ # `CURRENT_TIME`
3947
+ # `CURRENT_DATE`
3948
+ # `CURRENT_DATETIME`
3949
+ # `GENERATE_UUID`
3950
+ # `RAND`
3951
+ # `SESSION_USER`
3952
+ # `ST_GEOPOINT`
3953
+ # - Struct or array composed with the above allowed functions, for example:
3954
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3777
3955
  #
3778
3956
  # @example
3779
3957
  # require "google/cloud/bigquery"
@@ -3784,9 +3962,20 @@ module Google
3784
3962
  # schema.bytes "avatar", mode: :required
3785
3963
  # end
3786
3964
  #
3965
+ # @example Add field with default value.
3966
+ # require "google/cloud/bigquery"
3967
+ #
3968
+ # bigquery = Google::Cloud::Bigquery.new
3969
+ # dataset = bigquery.dataset "my_dataset"
3970
+ # table = dataset.create_table "my_table" do |schema|
3971
+ # schema.bytes "avatar", default_value_expression: "b'101'"
3972
+ # end
3973
+ #
3787
3974
  # @!group Schema
3788
- def bytes name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil
3789
- schema.bytes name, description: description, mode: mode, policy_tags: policy_tags, max_length: max_length
3975
+ def bytes name, description: nil, mode: :nullable, policy_tags: nil, max_length: nil,
3976
+ default_value_expression: nil
3977
+ schema.bytes name, description: description, mode: mode, policy_tags: policy_tags, max_length: max_length,
3978
+ default_value_expression: default_value_expression
3790
3979
  end
3791
3980
 
3792
3981
  ##
@@ -3806,6 +3995,22 @@ module Google
3806
3995
  # single policy tag for the field. Policy tag identifiers are of
3807
3996
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
3808
3997
  # At most 1 policy tag is currently allowed.
3998
+ # @param default_value_expression [String] The default value of a field
3999
+ # using a SQL expression. It can only be set for top level fields (columns).
4000
+ # Use a struct or array expression to specify default value for the entire struct or
4001
+ # array. The valid SQL expressions are:
4002
+ # - Literals for all data types, including STRUCT and ARRAY.
4003
+ # - The following functions:
4004
+ # `CURRENT_TIMESTAMP`
4005
+ # `CURRENT_TIME`
4006
+ # `CURRENT_DATE`
4007
+ # `CURRENT_DATETIME`
4008
+ # `GENERATE_UUID`
4009
+ # `RAND`
4010
+ # `SESSION_USER`
4011
+ # `ST_GEOPOINT`
4012
+ # - Struct or array composed with the above allowed functions, for example:
4013
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3809
4014
  #
3810
4015
  # @example
3811
4016
  # require "google/cloud/bigquery"
@@ -3816,9 +4021,20 @@ module Google
3816
4021
  # schema.timestamp "creation_date", mode: :required
3817
4022
  # end
3818
4023
  #
4024
+ # @example Add field with default value.
4025
+ # require "google/cloud/bigquery"
4026
+ #
4027
+ # bigquery = Google::Cloud::Bigquery.new
4028
+ # dataset = bigquery.dataset "my_dataset"
4029
+ # table = dataset.create_table "my_table" do |schema|
4030
+ # schema.timestamp "creation_date", default_value_expression: "CURRENT_TIMESTAMP"
4031
+ # end
4032
+ #
3819
4033
  # @!group Schema
3820
- def timestamp name, description: nil, mode: :nullable, policy_tags: nil
3821
- schema.timestamp name, description: description, mode: mode, policy_tags: policy_tags
4034
+ def timestamp name, description: nil, mode: :nullable, policy_tags: nil,
4035
+ default_value_expression: nil
4036
+ schema.timestamp name, description: description, mode: mode, policy_tags: policy_tags,
4037
+ default_value_expression: default_value_expression
3822
4038
  end
3823
4039
 
3824
4040
  ##
@@ -3838,6 +4054,22 @@ module Google
3838
4054
  # single policy tag for the field. Policy tag identifiers are of
3839
4055
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
3840
4056
  # At most 1 policy tag is currently allowed.
4057
+ # @param default_value_expression [String] The default value of a field
4058
+ # using a SQL expression. It can only be set for top level fields (columns).
4059
+ # Use a struct or array expression to specify default value for the entire struct or
4060
+ # array. The valid SQL expressions are:
4061
+ # - Literals for all data types, including STRUCT and ARRAY.
4062
+ # - The following functions:
4063
+ # `CURRENT_TIMESTAMP`
4064
+ # `CURRENT_TIME`
4065
+ # `CURRENT_DATE`
4066
+ # `CURRENT_DATETIME`
4067
+ # `GENERATE_UUID`
4068
+ # `RAND`
4069
+ # `SESSION_USER`
4070
+ # `ST_GEOPOINT`
4071
+ # - Struct or array composed with the above allowed functions, for example:
4072
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3841
4073
  #
3842
4074
  # @example
3843
4075
  # require "google/cloud/bigquery"
@@ -3848,9 +4080,20 @@ module Google
3848
4080
  # schema.time "duration", mode: :required
3849
4081
  # end
3850
4082
  #
4083
+ # @example Add field with default value.
4084
+ # require "google/cloud/bigquery"
4085
+ #
4086
+ # bigquery = Google::Cloud::Bigquery.new
4087
+ # dataset = bigquery.dataset "my_dataset"
4088
+ # table = dataset.create_table "my_table" do |schema|
4089
+ # schema.time "duration", default_value_expression: "CURRENT_TIME"
4090
+ # end
4091
+ #
3851
4092
  # @!group Schema
3852
- def time name, description: nil, mode: :nullable, policy_tags: nil
3853
- schema.time name, description: description, mode: mode, policy_tags: policy_tags
4093
+ def time name, description: nil, mode: :nullable, policy_tags: nil,
4094
+ default_value_expression: nil
4095
+ schema.time name, description: description, mode: mode, policy_tags: policy_tags,
4096
+ default_value_expression: default_value_expression
3854
4097
  end
3855
4098
 
3856
4099
  ##
@@ -3870,6 +4113,22 @@ module Google
3870
4113
  # single policy tag for the field. Policy tag identifiers are of
3871
4114
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
3872
4115
  # At most 1 policy tag is currently allowed.
4116
+ # @param default_value_expression [String] The default value of a field
4117
+ # using a SQL expression. It can only be set for top level fields (columns).
4118
+ # Use a struct or array expression to specify default value for the entire struct or
4119
+ # array. The valid SQL expressions are:
4120
+ # - Literals for all data types, including STRUCT and ARRAY.
4121
+ # - The following functions:
4122
+ # `CURRENT_TIMESTAMP`
4123
+ # `CURRENT_TIME`
4124
+ # `CURRENT_DATE`
4125
+ # `CURRENT_DATETIME`
4126
+ # `GENERATE_UUID`
4127
+ # `RAND`
4128
+ # `SESSION_USER`
4129
+ # `ST_GEOPOINT`
4130
+ # - Struct or array composed with the above allowed functions, for example:
4131
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3873
4132
  #
3874
4133
  # @example
3875
4134
  # require "google/cloud/bigquery"
@@ -3880,9 +4139,20 @@ module Google
3880
4139
  # schema.datetime "target_end", mode: :required
3881
4140
  # end
3882
4141
  #
4142
+ # @example Add field with default value.
4143
+ # require "google/cloud/bigquery"
4144
+ #
4145
+ # bigquery = Google::Cloud::Bigquery.new
4146
+ # dataset = bigquery.dataset "my_dataset"
4147
+ # table = dataset.create_table "my_table" do |schema|
4148
+ # schema.datetime "target_end", default_value_expression: "CURRENT_DATETIME"
4149
+ # end
4150
+ #
3883
4151
  # @!group Schema
3884
- def datetime name, description: nil, mode: :nullable, policy_tags: nil
3885
- schema.datetime name, description: description, mode: mode, policy_tags: policy_tags
4152
+ def datetime name, description: nil, mode: :nullable, policy_tags: nil,
4153
+ default_value_expression: nil
4154
+ schema.datetime name, description: description, mode: mode, policy_tags: policy_tags,
4155
+ default_value_expression: default_value_expression
3886
4156
  end
3887
4157
 
3888
4158
  ##
@@ -3902,6 +4172,22 @@ module Google
3902
4172
  # single policy tag for the field. Policy tag identifiers are of
3903
4173
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
3904
4174
  # At most 1 policy tag is currently allowed.
4175
+ # @param default_value_expression [String] The default value of a field
4176
+ # using a SQL expression. It can only be set for top level fields (columns).
4177
+ # Use a struct or array expression to specify default value for the entire struct or
4178
+ # array. The valid SQL expressions are:
4179
+ # - Literals for all data types, including STRUCT and ARRAY.
4180
+ # - The following functions:
4181
+ # `CURRENT_TIMESTAMP`
4182
+ # `CURRENT_TIME`
4183
+ # `CURRENT_DATE`
4184
+ # `CURRENT_DATETIME`
4185
+ # `GENERATE_UUID`
4186
+ # `RAND`
4187
+ # `SESSION_USER`
4188
+ # `ST_GEOPOINT`
4189
+ # - Struct or array composed with the above allowed functions, for example:
4190
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3905
4191
  #
3906
4192
  # @example
3907
4193
  # require "google/cloud/bigquery"
@@ -3912,9 +4198,20 @@ module Google
3912
4198
  # schema.date "birthday", mode: :required
3913
4199
  # end
3914
4200
  #
4201
+ # @example Add field with default value.
4202
+ # require "google/cloud/bigquery"
4203
+ #
4204
+ # bigquery = Google::Cloud::Bigquery.new
4205
+ # dataset = bigquery.dataset "my_dataset"
4206
+ # table = dataset.create_table "my_table" do |schema|
4207
+ # schema.date "birthday", default_value_expression: "CURRENT_DATE"
4208
+ # end
4209
+ #
3915
4210
  # @!group Schema
3916
- def date name, description: nil, mode: :nullable, policy_tags: nil
3917
- schema.date name, description: description, mode: mode, policy_tags: policy_tags
4211
+ def date name, description: nil, mode: :nullable, policy_tags: nil,
4212
+ default_value_expression: nil
4213
+ schema.date name, description: description, mode: mode, policy_tags: policy_tags,
4214
+ default_value_expression: default_value_expression
3918
4215
  end
3919
4216
 
3920
4217
  ##
@@ -3934,6 +4231,22 @@ module Google
3934
4231
  # single policy tag for the field. Policy tag identifiers are of
3935
4232
  # the form `projects/*/locations/*/taxonomies/*/policyTags/*`.
3936
4233
  # At most 1 policy tag is currently allowed.
4234
+ # @param default_value_expression [String] The default value of a field
4235
+ # using a SQL expression. It can only be set for top level fields (columns).
4236
+ # Use a struct or array expression to specify default value for the entire struct or
4237
+ # array. The valid SQL expressions are:
4238
+ # - Literals for all data types, including STRUCT and ARRAY.
4239
+ # - The following functions:
4240
+ # `CURRENT_TIMESTAMP`
4241
+ # `CURRENT_TIME`
4242
+ # `CURRENT_DATE`
4243
+ # `CURRENT_DATETIME`
4244
+ # `GENERATE_UUID`
4245
+ # `RAND`
4246
+ # `SESSION_USER`
4247
+ # `ST_GEOPOINT`
4248
+ # - Struct or array composed with the above allowed functions, for example:
4249
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
3937
4250
  #
3938
4251
  # @example
3939
4252
  # require "google/cloud/bigquery"
@@ -3944,8 +4257,19 @@ module Google
3944
4257
  # schema.geography "home", mode: :required
3945
4258
  # end
3946
4259
  #
3947
- def geography name, description: nil, mode: :nullable, policy_tags: nil
3948
- schema.geography name, description: description, mode: mode, policy_tags: policy_tags
4260
+ # @example Add field with default value.
4261
+ # require "google/cloud/bigquery"
4262
+ #
4263
+ # bigquery = Google::Cloud::Bigquery.new
4264
+ # dataset = bigquery.dataset "my_dataset"
4265
+ # table = dataset.create_table "my_table" do |schema|
4266
+ # schema.geography "home", default_value_expression: "ST_GEOGPOINT(-122.084801, 37.422131)"
4267
+ # end
4268
+ #
4269
+ def geography name, description: nil, mode: :nullable, policy_tags: nil,
4270
+ default_value_expression: nil
4271
+ schema.geography name, description: description, mode: mode, policy_tags: policy_tags,
4272
+ default_value_expression: default_value_expression
3949
4273
  end
3950
4274
 
3951
4275
  ##
@@ -3965,6 +4289,23 @@ module Google
3965
4289
  # @param [Symbol] mode The field's mode. The possible values are
3966
4290
  # `:nullable`, `:required`, and `:repeated`. The default value is
3967
4291
  # `:nullable`.
4292
+ # @param default_value_expression [String] The default value of a field
4293
+ # using a SQL expression. It can only be set for top level fields (columns).
4294
+ # Use a struct or array expression to specify default value for the entire struct or
4295
+ # array. The valid SQL expressions are:
4296
+ # - Literals for all data types, including STRUCT and ARRAY.
4297
+ # - The following functions:
4298
+ # `CURRENT_TIMESTAMP`
4299
+ # `CURRENT_TIME`
4300
+ # `CURRENT_DATE`
4301
+ # `CURRENT_DATETIME`
4302
+ # `GENERATE_UUID`
4303
+ # `RAND`
4304
+ # `SESSION_USER`
4305
+ # `ST_GEOPOINT`
4306
+ # - Struct or array composed with the above allowed functions, for example:
4307
+ # "[CURRENT_DATE(), DATE '2020-01-01'"]
4308
+ #
3968
4309
  # @yield [nested_schema] a block for setting the nested schema
3969
4310
  # @yieldparam [Schema] nested_schema the object accepting the
3970
4311
  # nested schema
@@ -3981,10 +4322,22 @@ module Google
3981
4322
  # end
3982
4323
  # end
3983
4324
  #
3984
- # @!group Schema
4325
+ # @example Add field with default value.
4326
+ # require "google/cloud/bigquery"
4327
+ #
4328
+ # bigquery = Google::Cloud::Bigquery.new
4329
+ # dataset = bigquery.dataset "my_dataset"
4330
+ # table = dataset.create_table "my_table" do |schema|
4331
+ # schema.record "cities_lived", mode: :repeated, "[STRUCT('place',10)]" do |cities_lived|
4332
+ # cities_lived.string "place", mode: :required
4333
+ # cities_lived.integer "number_of_years", mode: :required
4334
+ # end
4335
+ # end
3985
4336
  #
3986
- def record name, description: nil, mode: nil, &block
3987
- schema.record name, description: description, mode: mode, &block
4337
+ # @!group Schema
4338
+ def record name, description: nil, mode: nil, default_value_expression: nil, &block
4339
+ schema.record name, description: description, mode: mode,
4340
+ default_value_expression: default_value_expression, &block
3988
4341
  end
3989
4342
 
3990
4343
  ##
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigquery
19
- VERSION = "1.42.0".freeze
19
+ VERSION = "1.43.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-bigquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.42.0
4
+ version: 1.43.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-16 00:00:00.000000000 Z
12
+ date: 2023-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby