google-cloud-bigquery 1.52.1 → 1.55.0
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 +4 -4
- data/CHANGELOG.md +21 -0
- data/lib/google/cloud/bigquery/condition.rb +218 -0
- data/lib/google/cloud/bigquery/convert.rb +10 -1
- data/lib/google/cloud/bigquery/data.rb +9 -3
- data/lib/google/cloud/bigquery/dataset/access.rb +281 -28
- data/lib/google/cloud/bigquery/dataset.rb +13 -4
- data/lib/google/cloud/bigquery/external/csv_source.rb +171 -0
- data/lib/google/cloud/bigquery/external/data_source.rb +216 -0
- data/lib/google/cloud/bigquery/load_job.rb +167 -0
- data/lib/google/cloud/bigquery/project.rb +39 -7
- data/lib/google/cloud/bigquery/query_job.rb +8 -5
- data/lib/google/cloud/bigquery/routine.rb +77 -0
- data/lib/google/cloud/bigquery/service.rb +17 -12
- data/lib/google/cloud/bigquery/table.rb +77 -3
- data/lib/google/cloud/bigquery/version.rb +1 -1
- metadata +14 -7
|
@@ -367,6 +367,177 @@ module Google
|
|
|
367
367
|
@gapi.csv_options.skip_leading_rows = row_count
|
|
368
368
|
end
|
|
369
369
|
|
|
370
|
+
##
|
|
371
|
+
# Specifies a string that represents a null value in a CSV file. For
|
|
372
|
+
# example, if you specify `\N`, BigQuery interprets `\N` as a null value when
|
|
373
|
+
# querying a CSV file. The default value is the empty string. If you set this
|
|
374
|
+
# property to a custom value, BigQuery throws an error if an empty string is
|
|
375
|
+
# present for all data types except for STRING and BYTE. For STRING and BYTE
|
|
376
|
+
# columns, BigQuery interprets the empty string as an empty value.
|
|
377
|
+
#
|
|
378
|
+
# @return [String, nil] The null marker string. `nil` if not set.
|
|
379
|
+
#
|
|
380
|
+
# @example
|
|
381
|
+
# require "google/cloud/bigquery"
|
|
382
|
+
#
|
|
383
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
384
|
+
#
|
|
385
|
+
# csv_url = "gs://bucket/path/to/data.csv"
|
|
386
|
+
# csv_table = bigquery.external csv_url do |csv|
|
|
387
|
+
# csv.null_marker = "\N"
|
|
388
|
+
# end
|
|
389
|
+
#
|
|
390
|
+
# csv_table.null_marker #=> "\N"
|
|
391
|
+
#
|
|
392
|
+
def null_marker
|
|
393
|
+
@gapi.csv_options.null_marker
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
##
|
|
397
|
+
# Sets a string that represents a null value in a CSV file. For
|
|
398
|
+
# example, if you specify `\N`, BigQuery interprets `\N` as a null value when
|
|
399
|
+
# querying a CSV file. The default value is the empty string. If you set this
|
|
400
|
+
# property to a custom value, BigQuery throws an error if an empty string is
|
|
401
|
+
# present for all data types except for STRING and BYTE. For STRING and BYTE
|
|
402
|
+
# columns, BigQuery interprets the empty string as an empty value.
|
|
403
|
+
#
|
|
404
|
+
# @param [String, nil] null_marker The null marker string. `nil` to unset.
|
|
405
|
+
#
|
|
406
|
+
# @example
|
|
407
|
+
# require "google/cloud/bigquery"
|
|
408
|
+
#
|
|
409
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
410
|
+
#
|
|
411
|
+
# csv_url = "gs://bucket/path/to/data.csv"
|
|
412
|
+
# csv_table = bigquery.external csv_url do |csv|
|
|
413
|
+
# csv.null_marker = "\N"
|
|
414
|
+
# end
|
|
415
|
+
#
|
|
416
|
+
# csv_table.null_marker #=> "\N"
|
|
417
|
+
#
|
|
418
|
+
def null_marker= null_marker
|
|
419
|
+
frozen_check!
|
|
420
|
+
@gapi.csv_options.null_marker = null_marker
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
##
|
|
424
|
+
# The list of strings represented as SQL NULL value in a CSV file.
|
|
425
|
+
# null_marker and null_markers can't be set at the same time. If null_marker is
|
|
426
|
+
# set, null_markers has to be not set. If null_markers is set, null_marker has
|
|
427
|
+
# to be not set. If both null_marker and null_markers are set at the same time,
|
|
428
|
+
# a user error would be thrown. Any strings listed in null_markers, including
|
|
429
|
+
# empty string would be interpreted as SQL NULL. This applies to all column
|
|
430
|
+
# types.
|
|
431
|
+
#
|
|
432
|
+
# @return [Array<String>] The array of null marker strings.
|
|
433
|
+
#
|
|
434
|
+
# @example
|
|
435
|
+
# require "google/cloud/bigquery"
|
|
436
|
+
#
|
|
437
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
438
|
+
#
|
|
439
|
+
# csv_url = "gs://bucket/path/to/data.csv"
|
|
440
|
+
# csv_table = bigquery.external csv_url do |csv|
|
|
441
|
+
# csv.null_markers = ["\N", "NULL"]
|
|
442
|
+
# end
|
|
443
|
+
#
|
|
444
|
+
# csv_table.null_markers #=> ["\N", "NULL"]
|
|
445
|
+
#
|
|
446
|
+
def null_markers
|
|
447
|
+
@gapi.csv_options.null_markers || []
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
##
|
|
451
|
+
# Sets the list of strings represented as SQL NULL value in a CSV file.
|
|
452
|
+
# null_marker and null_markers can't be set at the same time. If null_marker is
|
|
453
|
+
# set, null_markers has to be not set. If null_markers is set, null_marker has
|
|
454
|
+
# to be not set. If both null_marker and null_markers are set at the same time,
|
|
455
|
+
# a user error would be thrown. Any strings listed in null_markers, including
|
|
456
|
+
# empty string would be interpreted as SQL NULL. This applies to all column
|
|
457
|
+
# types.
|
|
458
|
+
#
|
|
459
|
+
# @param [Array<String>] null_markers The array of null marker strings.
|
|
460
|
+
#
|
|
461
|
+
#
|
|
462
|
+
# @example
|
|
463
|
+
# require "google/cloud/bigquery"
|
|
464
|
+
#
|
|
465
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
466
|
+
#
|
|
467
|
+
# csv_url = "gs://bucket/path/to/data.csv"
|
|
468
|
+
# csv_table = bigquery.external csv_url do |csv|
|
|
469
|
+
# csv.null_markers = ["\N", "NULL"]
|
|
470
|
+
# end
|
|
471
|
+
#
|
|
472
|
+
# csv_table.null_markers #=> ["\N", "NULL"]
|
|
473
|
+
#
|
|
474
|
+
def null_markers= null_markers
|
|
475
|
+
frozen_check!
|
|
476
|
+
@gapi.csv_options.null_markers = null_markers
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
# Controls the strategy used to match loaded columns to the schema.
|
|
480
|
+
# If not set, a sensible default is chosen based on how the schema is
|
|
481
|
+
# provided. If autodetect is used, then columns are matched by name.
|
|
482
|
+
# Otherwise, columns are matched by position. This is done to keep the
|
|
483
|
+
# behavior backward-compatible.
|
|
484
|
+
#
|
|
485
|
+
# Acceptable values are:
|
|
486
|
+
# - `POSITION`: matches by position. Assumes columns are ordered the
|
|
487
|
+
# same way as the schema.
|
|
488
|
+
# - `NAME`: matches by name. Reads the header row as column names and
|
|
489
|
+
# reorders columns to match the schema.
|
|
490
|
+
#
|
|
491
|
+
# @return [String, nil] The source column match value. `nil` if not set.
|
|
492
|
+
#
|
|
493
|
+
# @example
|
|
494
|
+
# require "google/cloud/bigquery"
|
|
495
|
+
#
|
|
496
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
497
|
+
#
|
|
498
|
+
# csv_url = "gs://bucket/path/to/data.csv"
|
|
499
|
+
# csv_table = bigquery.external csv_url do |csv|
|
|
500
|
+
# csv.source_column_match = "NAME"
|
|
501
|
+
# end
|
|
502
|
+
#
|
|
503
|
+
# csv_table.source_column_match #=> "NAME"
|
|
504
|
+
#
|
|
505
|
+
def source_column_match
|
|
506
|
+
@gapi.csv_options.source_column_match
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
# Sets the strategy used to match loaded columns to the schema.
|
|
510
|
+
# If not set, a sensible default is chosen based on how the schema is
|
|
511
|
+
# provided. If autodetect is used, then columns are matched by name.
|
|
512
|
+
# Otherwise, columns are matched by position. This is done to keep the
|
|
513
|
+
# behavior backward-compatible. Optional.
|
|
514
|
+
#
|
|
515
|
+
# Acceptable values are:
|
|
516
|
+
# - `POSITION`: matches by position. Assumes columns are ordered the
|
|
517
|
+
# same way as the schema.
|
|
518
|
+
# - `NAME`: matches by name. Reads the header row as column names and
|
|
519
|
+
# reorders columns to match the schema.
|
|
520
|
+
#
|
|
521
|
+
# @param [String, nil] source_column_match The new source column match value. `nil` to unset.
|
|
522
|
+
#
|
|
523
|
+
#
|
|
524
|
+
# @example
|
|
525
|
+
# require "google/cloud/bigquery"
|
|
526
|
+
#
|
|
527
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
528
|
+
#
|
|
529
|
+
# csv_url = "gs://bucket/path/to/data.csv"
|
|
530
|
+
# csv_table = bigquery.external csv_url do |csv|
|
|
531
|
+
# csv.source_column_match = "NAME"
|
|
532
|
+
# end
|
|
533
|
+
#
|
|
534
|
+
# csv_table.source_column_match #=> "NAME"
|
|
535
|
+
#
|
|
536
|
+
def source_column_match= source_column_match
|
|
537
|
+
frozen_check!
|
|
538
|
+
@gapi.csv_options.source_column_match = source_column_match
|
|
539
|
+
end
|
|
540
|
+
|
|
370
541
|
##
|
|
371
542
|
# The schema for the data.
|
|
372
543
|
#
|
|
@@ -744,6 +744,222 @@ module Google
|
|
|
744
744
|
@gapi.hive_partitioning_options.source_uri_prefix = source_uri_prefix
|
|
745
745
|
end
|
|
746
746
|
|
|
747
|
+
##
|
|
748
|
+
# Time zone used when parsing timestamp values that do not have specific
|
|
749
|
+
# time zone information (e.g. `2024-04-20 12:34:56`). The expected format
|
|
750
|
+
# is an IANA timezone string (e.g. `America/Los_Angeles`).
|
|
751
|
+
#
|
|
752
|
+
# @return [String, nil] The IANA time zone name. `nil` if not set.
|
|
753
|
+
#
|
|
754
|
+
# @example
|
|
755
|
+
# require "google/cloud/bigquery"
|
|
756
|
+
#
|
|
757
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
758
|
+
#
|
|
759
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
760
|
+
# ext.time_zone = "America/Los_Angeles"
|
|
761
|
+
# end
|
|
762
|
+
#
|
|
763
|
+
# external_data.time_zone #=> "America/Los_Angeles"
|
|
764
|
+
#
|
|
765
|
+
def time_zone
|
|
766
|
+
@gapi.time_zone
|
|
767
|
+
end
|
|
768
|
+
|
|
769
|
+
##
|
|
770
|
+
# Sets the time zone used when parsing timestamp values that do not have
|
|
771
|
+
# specific time zone information (e.g. `2024-04-20 12:34:56`). The expected
|
|
772
|
+
# format is an IANA timezone string (e.g. `America/Los_Angeles`).
|
|
773
|
+
#
|
|
774
|
+
# @param [String, nil] time_zone The IANA time zone name. `nil` to unset.
|
|
775
|
+
#
|
|
776
|
+
# @example
|
|
777
|
+
# require "google/cloud/bigquery"
|
|
778
|
+
#
|
|
779
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
780
|
+
#
|
|
781
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
782
|
+
# ext.time_zone = "America/Los_Angeles"
|
|
783
|
+
# end
|
|
784
|
+
#
|
|
785
|
+
# external_data.time_zone #=> "America/Los_Angeles"
|
|
786
|
+
#
|
|
787
|
+
def time_zone= time_zone
|
|
788
|
+
frozen_check!
|
|
789
|
+
@gapi.time_zone = time_zone
|
|
790
|
+
end
|
|
791
|
+
|
|
792
|
+
##
|
|
793
|
+
# Format used to parse TIME values. Supports C-style and SQL-style values.
|
|
794
|
+
#
|
|
795
|
+
# @return [String, nil] The time format pattern. `nil` if not set.
|
|
796
|
+
#
|
|
797
|
+
# @example
|
|
798
|
+
# require "google/cloud/bigquery"
|
|
799
|
+
#
|
|
800
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
801
|
+
#
|
|
802
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
803
|
+
# ext.time_format = "%H:%M:%S"
|
|
804
|
+
# end
|
|
805
|
+
#
|
|
806
|
+
# external_data.time_format #=> "%H:%M:%S"
|
|
807
|
+
#
|
|
808
|
+
def time_format
|
|
809
|
+
@gapi.time_format
|
|
810
|
+
end
|
|
811
|
+
|
|
812
|
+
##
|
|
813
|
+
# Sets the format used to parse TIME values. Supports C-style and SQL-style
|
|
814
|
+
# values.
|
|
815
|
+
#
|
|
816
|
+
# @param [String, nil] time_format The time format pattern. `nil` if not set.
|
|
817
|
+
#
|
|
818
|
+
# @example
|
|
819
|
+
# require "google/cloud/bigquery"
|
|
820
|
+
#
|
|
821
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
822
|
+
#
|
|
823
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
824
|
+
# ext.time_format = "%H:%M:%S"
|
|
825
|
+
# end
|
|
826
|
+
#
|
|
827
|
+
# external_data.time_format #=> "%H:%M:%S"
|
|
828
|
+
#
|
|
829
|
+
def time_format= time_format
|
|
830
|
+
frozen_check!
|
|
831
|
+
@gapi.time_format = time_format
|
|
832
|
+
end
|
|
833
|
+
|
|
834
|
+
##
|
|
835
|
+
# Format used to parse TIMESTAMP values. Supports C-style and SQL-style
|
|
836
|
+
# values.
|
|
837
|
+
#
|
|
838
|
+
# @return [String, nil] The timestamp format pattern. `nil` if not set.
|
|
839
|
+
#
|
|
840
|
+
# @example
|
|
841
|
+
# require "google/cloud/bigquery"
|
|
842
|
+
#
|
|
843
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
844
|
+
#
|
|
845
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
846
|
+
# ext.timestamp_format = "%Y-%m-%d %H:%M:%S.%f %z"
|
|
847
|
+
# end
|
|
848
|
+
#
|
|
849
|
+
# external_data.timestamp_format #=> "%Y-%m-%d %H:%M:%S.%f %z"
|
|
850
|
+
#
|
|
851
|
+
def timestamp_format
|
|
852
|
+
@gapi.timestamp_format
|
|
853
|
+
end
|
|
854
|
+
|
|
855
|
+
##
|
|
856
|
+
# Sets the format used to parse TIMESTAMP values. Supports C-style and SQL-style
|
|
857
|
+
# values.
|
|
858
|
+
#
|
|
859
|
+
# @param [String, nil] timestamp_format The timestamp format pattern. `nil` to unset.
|
|
860
|
+
#
|
|
861
|
+
# @example
|
|
862
|
+
# require "google/cloud/bigquery"
|
|
863
|
+
#
|
|
864
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
865
|
+
#
|
|
866
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
867
|
+
# ext.timestamp_format = "%Y-%m-%d %H:%M:%S.%f %z"
|
|
868
|
+
# end
|
|
869
|
+
#
|
|
870
|
+
# external_data.timestamp_format #=> "%Y-%m-%d %H:%M:%S.%f %z"
|
|
871
|
+
#
|
|
872
|
+
def timestamp_format= timestamp_format
|
|
873
|
+
frozen_check!
|
|
874
|
+
@gapi.timestamp_format = timestamp_format
|
|
875
|
+
end
|
|
876
|
+
|
|
877
|
+
##
|
|
878
|
+
# Format used to parse DATETIME values. Supports C-style and SQL-style
|
|
879
|
+
# values.
|
|
880
|
+
#
|
|
881
|
+
# @return [String, nil] The datetime format pattern. `nil` if not set.
|
|
882
|
+
#
|
|
883
|
+
# @example
|
|
884
|
+
# require "google/cloud/bigquery"
|
|
885
|
+
#
|
|
886
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
887
|
+
#
|
|
888
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
889
|
+
# ext.datetime_format = "%Y-%m-%d %H:%M:%S"
|
|
890
|
+
# end
|
|
891
|
+
#
|
|
892
|
+
# external_data.datetime_format #=> "%Y-%m-%d %H:%M:%S"
|
|
893
|
+
#
|
|
894
|
+
def datetime_format
|
|
895
|
+
@gapi.datetime_format
|
|
896
|
+
end
|
|
897
|
+
|
|
898
|
+
##
|
|
899
|
+
# Sets the format used to parse DATETIME values. Supports C-style and SQL-style
|
|
900
|
+
# values.
|
|
901
|
+
#
|
|
902
|
+
# @param [String, nil] datetime_format The datetime format pattern. `nil` to unset.
|
|
903
|
+
#
|
|
904
|
+
# @example
|
|
905
|
+
# require "google/cloud/bigquery"
|
|
906
|
+
#
|
|
907
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
908
|
+
#
|
|
909
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
910
|
+
# ext.datetime_format = "%Y-%m-%d %H:%M:%S"
|
|
911
|
+
# end
|
|
912
|
+
#
|
|
913
|
+
# external_data.datetime_format #=> "%Y-%m-%d %H:%M:%S"
|
|
914
|
+
#
|
|
915
|
+
def datetime_format= datetime_format
|
|
916
|
+
frozen_check!
|
|
917
|
+
@gapi.datetime_format = datetime_format
|
|
918
|
+
end
|
|
919
|
+
|
|
920
|
+
##
|
|
921
|
+
# Format used to parse DATE values. Supports C-style and SQL-style
|
|
922
|
+
# values.
|
|
923
|
+
#
|
|
924
|
+
# @return [String, nil] The date format pattern. `nil` if not set.
|
|
925
|
+
#
|
|
926
|
+
# @example
|
|
927
|
+
# require "google/cloud/bigquery"
|
|
928
|
+
#
|
|
929
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
930
|
+
#
|
|
931
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
932
|
+
# ext.date_format = "%Y-%m-%d"
|
|
933
|
+
# end
|
|
934
|
+
#
|
|
935
|
+
# external_data.date_format #=> "%Y-%m-%d"
|
|
936
|
+
#
|
|
937
|
+
def date_format
|
|
938
|
+
@gapi.date_format
|
|
939
|
+
end
|
|
940
|
+
|
|
941
|
+
##
|
|
942
|
+
# Sets the format used to parse DATE values. Supports C-style and SQL-style
|
|
943
|
+
# values.
|
|
944
|
+
#
|
|
945
|
+
# @param [String, nil] date_format The date format pattern. `nil` to unset.
|
|
946
|
+
#
|
|
947
|
+
# @example
|
|
948
|
+
# require "google/cloud/bigquery"
|
|
949
|
+
#
|
|
950
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
951
|
+
#
|
|
952
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
953
|
+
# ext.date_format = "%Y-%m-%d"
|
|
954
|
+
# end
|
|
955
|
+
#
|
|
956
|
+
# external_data.date_format #=> "%Y-%m-%d"
|
|
957
|
+
#
|
|
958
|
+
def date_format= date_format
|
|
959
|
+
frozen_check!
|
|
960
|
+
@gapi.date_format = date_format
|
|
961
|
+
end
|
|
962
|
+
|
|
747
963
|
##
|
|
748
964
|
# @private Google API Client object.
|
|
749
965
|
def to_gapi
|
|
@@ -652,6 +652,90 @@ module Google
|
|
|
652
652
|
@gapi.configuration.load.clustering.fields if clustering?
|
|
653
653
|
end
|
|
654
654
|
|
|
655
|
+
##
|
|
656
|
+
# Format used to parse DATE values. Supports C-style and SQL-style
|
|
657
|
+
# values.
|
|
658
|
+
#
|
|
659
|
+
# @return [String, nil] The date format pattern, such as
|
|
660
|
+
# `%Y-%m-%d`. `nil` if not set.
|
|
661
|
+
def date_format
|
|
662
|
+
@gapi.configuration.load.date_format
|
|
663
|
+
end
|
|
664
|
+
|
|
665
|
+
##
|
|
666
|
+
# Format used to parse DATETIME values. Supports C-style and SQL-style
|
|
667
|
+
# values.
|
|
668
|
+
#
|
|
669
|
+
# @return [String, nil] The datetime format pattern, such as
|
|
670
|
+
# `%Y-%m-%d %H:%M:%S`. `nil` if not set.
|
|
671
|
+
def datetime_format
|
|
672
|
+
@gapi.configuration.load.datetime_format
|
|
673
|
+
end
|
|
674
|
+
|
|
675
|
+
##
|
|
676
|
+
# Format used to parse TIME values. Supports C-style and SQL-style
|
|
677
|
+
# values.
|
|
678
|
+
#
|
|
679
|
+
# @return [String, nil] The time format pattern, such as
|
|
680
|
+
# `%H:%M:%S`. `nil` if not set.
|
|
681
|
+
def time_format
|
|
682
|
+
@gapi.configuration.load.time_format
|
|
683
|
+
end
|
|
684
|
+
|
|
685
|
+
##
|
|
686
|
+
# Format used to parse TIMESTAMP values. Supports C-style and SQL-style
|
|
687
|
+
# values.
|
|
688
|
+
#
|
|
689
|
+
# @return [String, nil] The timestamp format pattern, such as
|
|
690
|
+
# `%Y-%m-%d %H:%M:%S.%f %z`. `nil` if not set.
|
|
691
|
+
def timestamp_format
|
|
692
|
+
@gapi.configuration.load.timestamp_format
|
|
693
|
+
end
|
|
694
|
+
|
|
695
|
+
##
|
|
696
|
+
# A list of strings represented as SQL NULL value in a CSV file.
|
|
697
|
+
# null_marker and null_markers can't be set at the same time. If null_marker
|
|
698
|
+
# is set, null_markers has to be not set. If null_markers is set, null_marker
|
|
699
|
+
# has to be not set. If both null_marker and null_markers are set at the same
|
|
700
|
+
# time, a user error would be thrown. Any strings listed in null_markers,
|
|
701
|
+
# including empty string would be interpreted as SQL NULL. This applies to all
|
|
702
|
+
# column types.
|
|
703
|
+
#
|
|
704
|
+
# @return [Array<String>] The array of null marker strings.
|
|
705
|
+
def null_markers
|
|
706
|
+
@gapi.configuration.load.null_markers || []
|
|
707
|
+
end
|
|
708
|
+
|
|
709
|
+
##
|
|
710
|
+
# Controls the strategy used to match loaded columns to the schema. If
|
|
711
|
+
# not set, a sensible default is chosen based on how the schema is provided.
|
|
712
|
+
# If autodetect is used, then columns are matched by name. Otherwise,
|
|
713
|
+
# columns are matched by position. This is done to keep the behavior
|
|
714
|
+
# backward-compatible.
|
|
715
|
+
#
|
|
716
|
+
# Acceptable values are:
|
|
717
|
+
# * `POSITION` - matches by position. This assumes that the columns are
|
|
718
|
+
# ordered the same way as the schema.
|
|
719
|
+
# * `NAME` - matches by name. This reads the header row as column names
|
|
720
|
+
# and reorders columns to match the field names in the schema.
|
|
721
|
+
#
|
|
722
|
+
# @return [String, nil] The source column match strategy, such as
|
|
723
|
+
# `POSITION`. `nil` if not set.
|
|
724
|
+
def source_column_match
|
|
725
|
+
@gapi.configuration.load.source_column_match
|
|
726
|
+
end
|
|
727
|
+
|
|
728
|
+
##
|
|
729
|
+
# Time zone used when parsing timestamp values that do not have specific
|
|
730
|
+
# time zone information (e.g. `2024-04-20 12:34:56`). The expected format
|
|
731
|
+
# is an IANA timezone string (e.g. `America/Los_Angeles`).
|
|
732
|
+
#
|
|
733
|
+
# @return [String, nil] The IANA time zone name, such as
|
|
734
|
+
# `America/Los_Angeles`. `nil` if not set.
|
|
735
|
+
def time_zone
|
|
736
|
+
@gapi.configuration.load.time_zone
|
|
737
|
+
end
|
|
738
|
+
|
|
655
739
|
##
|
|
656
740
|
# Yielded to a block to accumulate changes for a patch request.
|
|
657
741
|
class Updater < LoadJob
|
|
@@ -2585,6 +2669,89 @@ module Google
|
|
|
2585
2669
|
@gapi.configuration.load.clustering.fields = fields
|
|
2586
2670
|
end
|
|
2587
2671
|
|
|
2672
|
+
##
|
|
2673
|
+
# Sets the format used to parse DATE values. Supports C-style and SQL-style
|
|
2674
|
+
# values.
|
|
2675
|
+
#
|
|
2676
|
+
# @param [String, nil] date_format The date format pattern, such as
|
|
2677
|
+
# `%Y-%m-%d`. `nil` to unset.
|
|
2678
|
+
def date_format= date_format
|
|
2679
|
+
@gapi.configuration.load.update! date_format: date_format
|
|
2680
|
+
end
|
|
2681
|
+
|
|
2682
|
+
##
|
|
2683
|
+
# Sets the format used to parse DATETIME values. Supports C-style and SQL-style
|
|
2684
|
+
# values.
|
|
2685
|
+
#
|
|
2686
|
+
# @param [String, nil] datetime_format The datetime format pattern, such as
|
|
2687
|
+
# `%Y-%m-%d %H:%M:%S`. `nil` to unset.
|
|
2688
|
+
def datetime_format= datetime_format
|
|
2689
|
+
@gapi.configuration.load.update! datetime_format: datetime_format
|
|
2690
|
+
end
|
|
2691
|
+
|
|
2692
|
+
##
|
|
2693
|
+
# Sets the format used to parse TIME values. Supports C-style and SQL-style
|
|
2694
|
+
# values.
|
|
2695
|
+
#
|
|
2696
|
+
# @param [String, nil] time_format The time format pattern, such as
|
|
2697
|
+
# `%H:%M:%S`. `nil` to unset.
|
|
2698
|
+
def time_format= time_format
|
|
2699
|
+
@gapi.configuration.load.update! time_format: time_format
|
|
2700
|
+
end
|
|
2701
|
+
|
|
2702
|
+
##
|
|
2703
|
+
# Sets the format used to parse TIMESTAMP values. Supports C-style and SQL-style
|
|
2704
|
+
# values.
|
|
2705
|
+
#
|
|
2706
|
+
# @param [String, nil] timestamp_format The timestamp format pattern, such as
|
|
2707
|
+
# `%Y-%m-%d %H:%M:%S.%f %z`. `nil` to unset.
|
|
2708
|
+
def timestamp_format= timestamp_format
|
|
2709
|
+
@gapi.configuration.load.update! timestamp_format: timestamp_format
|
|
2710
|
+
end
|
|
2711
|
+
|
|
2712
|
+
##
|
|
2713
|
+
# Sets the list of strings represented as SQL NULL value in a CSV file.
|
|
2714
|
+
# null_marker and null_markers can't be set at the same time. If null_marker is
|
|
2715
|
+
# set, null_markers has to be not set. If null_markers is set, null_marker has
|
|
2716
|
+
# to be not set. If both null_marker and null_markers are set at the same time,
|
|
2717
|
+
# a user error would be thrown. Any strings listed in null_markers, including
|
|
2718
|
+
# empty string would be interpreted as SQL NULL. This applies to all column
|
|
2719
|
+
# types.
|
|
2720
|
+
#
|
|
2721
|
+
# @param [Array<String>] null_markers The array of null marker strings.
|
|
2722
|
+
def null_markers= null_markers
|
|
2723
|
+
@gapi.configuration.load.update! null_markers: null_markers
|
|
2724
|
+
end
|
|
2725
|
+
|
|
2726
|
+
# Sets the strategy used to match loaded columns to the schema.
|
|
2727
|
+
# If not set, a sensible default is chosen based on how the schema is
|
|
2728
|
+
# provided. If autodetect is used, then columns are matched by name.
|
|
2729
|
+
# Otherwise, columns are matched by position. This is done to keep the
|
|
2730
|
+
# behavior backward-compatible.
|
|
2731
|
+
#
|
|
2732
|
+
# Acceptable values are:
|
|
2733
|
+
# - `POSITION`: matches by position. Assumes columns are ordered the
|
|
2734
|
+
# same way as the schema.
|
|
2735
|
+
# - `NAME`: matches by name. Reads the header row as column names and
|
|
2736
|
+
# reorders columns to match the schema.
|
|
2737
|
+
#
|
|
2738
|
+
# @param [String, nil] source_column_match The new source column match value.
|
|
2739
|
+
# `nil` to unset.
|
|
2740
|
+
def source_column_match= source_column_match
|
|
2741
|
+
@gapi.configuration.load.update! source_column_match: source_column_match
|
|
2742
|
+
end
|
|
2743
|
+
|
|
2744
|
+
##
|
|
2745
|
+
# Sets the time zone used when parsing timestamp values that do not have
|
|
2746
|
+
# specific time zone information (e.g. `2024-04-20 12:34:56`). The expected
|
|
2747
|
+
# format is an IANA timezone string (e.g. `America/Los_Angeles`).
|
|
2748
|
+
#
|
|
2749
|
+
# @param [String, nil] time_zone The IANA time zone name, such as
|
|
2750
|
+
# `America/Los_Angeles`. `nil` to unset.
|
|
2751
|
+
def time_zone= time_zone
|
|
2752
|
+
@gapi.configuration.load.update! time_zone: time_zone
|
|
2753
|
+
end
|
|
2754
|
+
|
|
2588
2755
|
def cancel
|
|
2589
2756
|
raise "not implemented in #{self.class}"
|
|
2590
2757
|
end
|
|
@@ -783,6 +783,9 @@ module Google
|
|
|
783
783
|
# `flatten` is false. Optional. The default value is false.
|
|
784
784
|
# @param [String] session_id The ID of an existing session. See the
|
|
785
785
|
# `create_session` param in {#query_job} and {Job#session_id}.
|
|
786
|
+
# @param [Boolean] format_options_use_int64_timestamp Output timestamp
|
|
787
|
+
# as usec int64. Default is true.
|
|
788
|
+
#
|
|
786
789
|
# @yield [job] a job configuration object
|
|
787
790
|
# @yieldparam [Google::Cloud::Bigquery::QueryJob::Updater] job a job
|
|
788
791
|
# configuration object for setting additional options for the query.
|
|
@@ -929,6 +932,7 @@ module Google
|
|
|
929
932
|
standard_sql: nil,
|
|
930
933
|
legacy_sql: nil,
|
|
931
934
|
session_id: nil,
|
|
935
|
+
format_options_use_int64_timestamp: true,
|
|
932
936
|
&block
|
|
933
937
|
job = query_job query,
|
|
934
938
|
params: params,
|
|
@@ -953,7 +957,7 @@ module Google
|
|
|
953
957
|
end
|
|
954
958
|
end
|
|
955
959
|
|
|
956
|
-
job.data max: max
|
|
960
|
+
job.data max: max, format_options_use_int64_timestamp: format_options_use_int64_timestamp
|
|
957
961
|
end
|
|
958
962
|
|
|
959
963
|
##
|
|
@@ -1378,6 +1382,20 @@ module Google
|
|
|
1378
1382
|
# service. Calls made on this object will raise errors if the resource
|
|
1379
1383
|
# does not exist. Default is `false`. Optional.
|
|
1380
1384
|
# @param [String] project_id The GCP Project where the dataset lives.
|
|
1385
|
+
# @param [Integer] access_policy_version Optional. The version of the
|
|
1386
|
+
# provided access policy schema. Valid values are `0`, `1`, and `3`.
|
|
1387
|
+
# Requests specifying an invalid value will be rejected. This
|
|
1388
|
+
# version refers to the schema version of the access policy and not
|
|
1389
|
+
# the version of access policy. This field's value can be equal or
|
|
1390
|
+
# more than the access policy schema provided in the request. For
|
|
1391
|
+
# example, requests with conditional access policy binding in datasets
|
|
1392
|
+
# must specify version `3`. But dataset with no conditional role
|
|
1393
|
+
# bindings in access policy may specify any valid value or leave the
|
|
1394
|
+
# field unset. If unset or if `0` or `1` value is used for dataset with
|
|
1395
|
+
# conditional bindings, request will be rejected. This field will be
|
|
1396
|
+
# mapped to
|
|
1397
|
+
# [IAM Policy version](https://cloud.google.com/iam/docs/policies#versions)
|
|
1398
|
+
# and will be used to set policy in IAM.
|
|
1381
1399
|
#
|
|
1382
1400
|
# @return [Google::Cloud::Bigquery::Dataset, nil] Returns `nil` if the
|
|
1383
1401
|
# dataset does not exist.
|
|
@@ -1405,12 +1423,12 @@ module Google
|
|
|
1405
1423
|
#
|
|
1406
1424
|
# dataset = bigquery.dataset "my_dataset", skip_lookup: true
|
|
1407
1425
|
#
|
|
1408
|
-
def dataset dataset_id, skip_lookup: nil, project_id: nil
|
|
1426
|
+
def dataset dataset_id, skip_lookup: nil, project_id: nil, access_policy_version: nil
|
|
1409
1427
|
ensure_service!
|
|
1410
1428
|
project_id ||= project
|
|
1411
1429
|
return Dataset.new_reference project_id, dataset_id, service if skip_lookup
|
|
1412
|
-
gapi = service.get_project_dataset project_id, dataset_id
|
|
1413
|
-
Dataset.from_gapi gapi, service
|
|
1430
|
+
gapi = service.get_project_dataset project_id, dataset_id, access_policy_version: access_policy_version
|
|
1431
|
+
Dataset.from_gapi gapi, service, access_policy_version: access_policy_version
|
|
1414
1432
|
rescue Google::Cloud::NotFoundError
|
|
1415
1433
|
nil
|
|
1416
1434
|
end
|
|
@@ -1429,6 +1447,20 @@ module Google
|
|
|
1429
1447
|
# @param [String] location The geographic location where the dataset
|
|
1430
1448
|
# should reside. Possible values include `EU` and `US`. The default
|
|
1431
1449
|
# value is `US`.
|
|
1450
|
+
# @param [Integer] access_policy_version Optional. The version of the
|
|
1451
|
+
# provided access policy schema. Valid values are `0`, `1`, and `3`.
|
|
1452
|
+
# Requests specifying an invalid value will be rejected. This
|
|
1453
|
+
# version refers to the schema version of the access policy and not
|
|
1454
|
+
# the version of access policy. This field's value can be equal or
|
|
1455
|
+
# more than the access policy schema provided in the request. For
|
|
1456
|
+
# example, requests with conditional access policy binding in datasets
|
|
1457
|
+
# must specify version `3`. But dataset with no conditional role
|
|
1458
|
+
# bindings in access policy may specify any valid value or leave the
|
|
1459
|
+
# field unset. If unset or if `0` or `1` value is used for dataset with
|
|
1460
|
+
# conditional bindings, request will be rejected. This field will be
|
|
1461
|
+
# mapped to
|
|
1462
|
+
# [IAM Policy version](https://cloud.google.com/iam/docs/policies#versions)
|
|
1463
|
+
# and will be used to set policy in IAM.
|
|
1432
1464
|
# @yield [access] a block for setting rules
|
|
1433
1465
|
# @yieldparam [Google::Cloud::Bigquery::Dataset] access the object
|
|
1434
1466
|
# accepting rules
|
|
@@ -1461,7 +1493,7 @@ module Google
|
|
|
1461
1493
|
# end
|
|
1462
1494
|
#
|
|
1463
1495
|
def create_dataset dataset_id, name: nil, description: nil,
|
|
1464
|
-
expiration: nil, location: nil
|
|
1496
|
+
expiration: nil, location: nil, access_policy_version: nil
|
|
1465
1497
|
ensure_service!
|
|
1466
1498
|
|
|
1467
1499
|
new_ds = Google::Apis::BigqueryV2::Dataset.new(
|
|
@@ -1484,8 +1516,8 @@ module Google
|
|
|
1484
1516
|
updater.check_for_mutated_access!
|
|
1485
1517
|
end
|
|
1486
1518
|
|
|
1487
|
-
gapi = service.insert_dataset new_ds
|
|
1488
|
-
Dataset.from_gapi gapi, service
|
|
1519
|
+
gapi = service.insert_dataset new_ds, access_policy_version: access_policy_version
|
|
1520
|
+
Dataset.from_gapi gapi, service, access_policy_version: access_policy_version
|
|
1489
1521
|
end
|
|
1490
1522
|
|
|
1491
1523
|
##
|