google-cloud-bigquery 1.52.1 → 1.61.1
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/AUTHENTICATION.md +12 -1
- data/CHANGELOG.md +69 -0
- data/OVERVIEW.md +4 -4
- data/lib/google/cloud/bigquery/condition.rb +218 -0
- data/lib/google/cloud/bigquery/convert.rb +10 -1
- data/lib/google/cloud/bigquery/copy_job.rb +14 -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 +282 -19
- data/lib/google/cloud/bigquery/external/csv_source.rb +218 -0
- data/lib/google/cloud/bigquery/external/data_source.rb +264 -0
- data/lib/google/cloud/bigquery/extract_job.rb +14 -1
- data/lib/google/cloud/bigquery/job.rb +6 -4
- data/lib/google/cloud/bigquery/load_job.rb +227 -0
- data/lib/google/cloud/bigquery/model.rb +15 -4
- data/lib/google/cloud/bigquery/project.rb +226 -23
- data/lib/google/cloud/bigquery/query_job.rb +22 -6
- data/lib/google/cloud/bigquery/remote_function_options.rb +156 -0
- data/lib/google/cloud/bigquery/routine.rb +153 -0
- data/lib/google/cloud/bigquery/schema/field.rb +31 -3
- data/lib/google/cloud/bigquery/schema.rb +6 -3
- data/lib/google/cloud/bigquery/service.rb +19 -12
- data/lib/google/cloud/bigquery/table.rb +326 -29
- data/lib/google/cloud/bigquery/version.rb +1 -1
- data/lib/google/cloud/bigquery.rb +25 -9
- data/lib/google-cloud-bigquery.rb +19 -3
- metadata +15 -7
|
@@ -367,6 +367,224 @@ 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
|
+
|
|
541
|
+
# Indicates if the embedded ASCII control characters (the first 32
|
|
542
|
+
# characters in the ASCII-table, from `\x00` to `\x1F`) are preserved.
|
|
543
|
+
# By default, ASCII control characters are not preserved.
|
|
544
|
+
#
|
|
545
|
+
# @return [Boolean, nil] whether or not ASCII control characters are
|
|
546
|
+
# preserved. `nil` if not set.
|
|
547
|
+
#
|
|
548
|
+
# @example
|
|
549
|
+
# require "google/cloud/bigquery"
|
|
550
|
+
#
|
|
551
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
552
|
+
#
|
|
553
|
+
# csv_url = "gs://bucket/path/to/data.csv"
|
|
554
|
+
# csv_table = bigquery.external csv_url do |csv|
|
|
555
|
+
# csv.preserve_ascii_control_characters = true
|
|
556
|
+
# end
|
|
557
|
+
#
|
|
558
|
+
# csv_table.preserve_ascii_control_characters #=> true
|
|
559
|
+
#
|
|
560
|
+
def preserve_ascii_control_characters
|
|
561
|
+
@gapi.csv_options.preserve_ascii_control_characters
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
# Sets whether the embedded ASCII control characters (the first 32
|
|
565
|
+
# characters in the ASCII-table, from `\x00` to `\x1F`) are preserved.
|
|
566
|
+
# By default, ASCII control characters are not preserved.
|
|
567
|
+
#
|
|
568
|
+
# @param [Boolean, nil] val whether or not ASCII control characters
|
|
569
|
+
# are preserved. `nil` to unset.
|
|
570
|
+
#
|
|
571
|
+
# @example
|
|
572
|
+
# require "google/cloud/bigquery"
|
|
573
|
+
#
|
|
574
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
575
|
+
#
|
|
576
|
+
# csv_url = "gs://bucket/path/to/data.csv"
|
|
577
|
+
# csv_table = bigquery.external csv_url do |csv|
|
|
578
|
+
# csv.preserve_ascii_control_characters = true
|
|
579
|
+
# end
|
|
580
|
+
#
|
|
581
|
+
# csv_table.preserve_ascii_control_characters #=> true
|
|
582
|
+
#
|
|
583
|
+
def preserve_ascii_control_characters= val
|
|
584
|
+
frozen_check!
|
|
585
|
+
@gapi.csv_options.preserve_ascii_control_characters = val
|
|
586
|
+
end
|
|
587
|
+
|
|
370
588
|
##
|
|
371
589
|
# The schema for the data.
|
|
372
590
|
#
|
|
@@ -504,6 +504,49 @@ module Google
|
|
|
504
504
|
@gapi.max_bad_records = new_max_bad_records
|
|
505
505
|
end
|
|
506
506
|
|
|
507
|
+
##
|
|
508
|
+
# The URI of a reference file with the table schema. This is enabled
|
|
509
|
+
# for the following formats: `AVRO`, `PARQUET`, `ORC`.
|
|
510
|
+
#
|
|
511
|
+
# @return [String, nil] The URI. `nil` if not set.
|
|
512
|
+
#
|
|
513
|
+
# @example
|
|
514
|
+
# require "google/cloud/bigquery"
|
|
515
|
+
#
|
|
516
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
517
|
+
#
|
|
518
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.avro", format: :avro do |ext|
|
|
519
|
+
# ext.reference_file_schema_uri = "gs://bucket/path/to/schema.json"
|
|
520
|
+
# end
|
|
521
|
+
#
|
|
522
|
+
# external_data.reference_file_schema_uri #=> "gs://bucket/path/to/schema.json"
|
|
523
|
+
#
|
|
524
|
+
def reference_file_schema_uri
|
|
525
|
+
@gapi.reference_file_schema_uri
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
##
|
|
529
|
+
# Sets the URI of a reference file with the table schema. This is
|
|
530
|
+
# enabled for the following formats: `AVRO`, `PARQUET`, `ORC`.
|
|
531
|
+
#
|
|
532
|
+
# @param [String, nil] uri The URI. `nil` to unset.
|
|
533
|
+
#
|
|
534
|
+
# @example
|
|
535
|
+
# require "google/cloud/bigquery"
|
|
536
|
+
#
|
|
537
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
538
|
+
#
|
|
539
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.avro", format: :avro do |ext|
|
|
540
|
+
# ext.reference_file_schema_uri = "gs://bucket/path/to/schema.json"
|
|
541
|
+
# end
|
|
542
|
+
#
|
|
543
|
+
# external_data.reference_file_schema_uri #=> "gs://bucket/path/to/schema.json"
|
|
544
|
+
#
|
|
545
|
+
def reference_file_schema_uri= uri
|
|
546
|
+
frozen_check!
|
|
547
|
+
@gapi.reference_file_schema_uri = uri
|
|
548
|
+
end
|
|
549
|
+
|
|
507
550
|
###
|
|
508
551
|
# Checks if hive partitioning options are set.
|
|
509
552
|
#
|
|
@@ -744,6 +787,227 @@ module Google
|
|
|
744
787
|
@gapi.hive_partitioning_options.source_uri_prefix = source_uri_prefix
|
|
745
788
|
end
|
|
746
789
|
|
|
790
|
+
##
|
|
791
|
+
# Time zone used when parsing timestamp values that do not have specific
|
|
792
|
+
# time zone information (e.g. `2024-04-20 12:34:56`). The expected format
|
|
793
|
+
# is an IANA timezone string (e.g. `America/Los_Angeles`).
|
|
794
|
+
#
|
|
795
|
+
# @return [String, nil] The IANA time zone name. `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_zone = "America/Los_Angeles"
|
|
804
|
+
# end
|
|
805
|
+
#
|
|
806
|
+
# external_data.time_zone #=> "America/Los_Angeles"
|
|
807
|
+
#
|
|
808
|
+
def time_zone
|
|
809
|
+
@gapi.time_zone
|
|
810
|
+
end
|
|
811
|
+
|
|
812
|
+
##
|
|
813
|
+
# Sets the time zone used when parsing timestamp values that do not have
|
|
814
|
+
# specific time zone information (e.g. `2024-04-20 12:34:56`). The expected
|
|
815
|
+
# format is an IANA timezone string (e.g. `America/Los_Angeles`).
|
|
816
|
+
#
|
|
817
|
+
# @param [String, nil] time_zone The IANA time zone name. `nil` to unset.
|
|
818
|
+
#
|
|
819
|
+
# @example
|
|
820
|
+
# require "google/cloud/bigquery"
|
|
821
|
+
#
|
|
822
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
823
|
+
#
|
|
824
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
825
|
+
# ext.time_zone = "America/Los_Angeles"
|
|
826
|
+
# end
|
|
827
|
+
#
|
|
828
|
+
# external_data.time_zone #=> "America/Los_Angeles"
|
|
829
|
+
#
|
|
830
|
+
def time_zone= time_zone
|
|
831
|
+
frozen_check!
|
|
832
|
+
@gapi.time_zone = time_zone
|
|
833
|
+
end
|
|
834
|
+
|
|
835
|
+
##
|
|
836
|
+
# Format used to parse TIME values. Supports SQL-style values. See
|
|
837
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
838
|
+
#
|
|
839
|
+
# @return [String, nil] The time format pattern. `nil` if not set.
|
|
840
|
+
#
|
|
841
|
+
# @example
|
|
842
|
+
# require "google/cloud/bigquery"
|
|
843
|
+
#
|
|
844
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
845
|
+
#
|
|
846
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
847
|
+
# ext.time_format = "HH24:MI:SS"
|
|
848
|
+
# end
|
|
849
|
+
#
|
|
850
|
+
# external_data.time_format #=> "HH24:MI:SS"
|
|
851
|
+
#
|
|
852
|
+
def time_format
|
|
853
|
+
@gapi.time_format
|
|
854
|
+
end
|
|
855
|
+
|
|
856
|
+
##
|
|
857
|
+
# Sets the format used to parse TIME values. Supports SQL-style See
|
|
858
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
859
|
+
# values.
|
|
860
|
+
#
|
|
861
|
+
# @param [String, nil] time_format The time format pattern. `nil` if not set.
|
|
862
|
+
#
|
|
863
|
+
# @example
|
|
864
|
+
# require "google/cloud/bigquery"
|
|
865
|
+
#
|
|
866
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
867
|
+
#
|
|
868
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
869
|
+
# ext.time_format = "HH24:MI:SS"
|
|
870
|
+
# end
|
|
871
|
+
#
|
|
872
|
+
# external_data.time_format #=> "HH24:MI:SS"
|
|
873
|
+
#
|
|
874
|
+
def time_format= time_format
|
|
875
|
+
frozen_check!
|
|
876
|
+
@gapi.time_format = time_format
|
|
877
|
+
end
|
|
878
|
+
|
|
879
|
+
##
|
|
880
|
+
# Format used to parse TIMESTAMP values. Supports SQL-style values. See
|
|
881
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
882
|
+
#
|
|
883
|
+
# @return [String, nil] The timestamp format pattern. `nil` if not set.
|
|
884
|
+
#
|
|
885
|
+
# @example
|
|
886
|
+
# require "google/cloud/bigquery"
|
|
887
|
+
#
|
|
888
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
889
|
+
#
|
|
890
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
891
|
+
# ext.timestamp_format = "YYYY-MM-DD HH24:MI:SS.FF3 TZH"
|
|
892
|
+
# end
|
|
893
|
+
#
|
|
894
|
+
# external_data.timestamp_format #=> "YYYY-MM-DD HH24:MI:SS.FF3 TZH"
|
|
895
|
+
#
|
|
896
|
+
def timestamp_format
|
|
897
|
+
@gapi.timestamp_format
|
|
898
|
+
end
|
|
899
|
+
|
|
900
|
+
##
|
|
901
|
+
# Sets the format used to parse TIMESTAMP values. Supports SQL-style
|
|
902
|
+
# values. See
|
|
903
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
904
|
+
#
|
|
905
|
+
# @param [String, nil] timestamp_format The timestamp format pattern. `nil` to unset.
|
|
906
|
+
#
|
|
907
|
+
# @example
|
|
908
|
+
# require "google/cloud/bigquery"
|
|
909
|
+
#
|
|
910
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
911
|
+
#
|
|
912
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
913
|
+
# ext.timestamp_format = "YYYY-MM-DD HH24:MI:SS.FF3 TZH"
|
|
914
|
+
# end
|
|
915
|
+
#
|
|
916
|
+
# external_data.timestamp_format #=> "YYYY-MM-DD HH24:MI:SS.FF3 TZH"
|
|
917
|
+
#
|
|
918
|
+
def timestamp_format= timestamp_format
|
|
919
|
+
frozen_check!
|
|
920
|
+
@gapi.timestamp_format = timestamp_format
|
|
921
|
+
end
|
|
922
|
+
|
|
923
|
+
##
|
|
924
|
+
# Format used to parse DATETIME values. Supports SQL-style values. See
|
|
925
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
926
|
+
#
|
|
927
|
+
# @return [String, nil] The datetime format pattern. `nil` if not set.
|
|
928
|
+
#
|
|
929
|
+
# @example
|
|
930
|
+
# require "google/cloud/bigquery"
|
|
931
|
+
#
|
|
932
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
933
|
+
#
|
|
934
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
935
|
+
# ext.datetime_format = "YYYY-MM-DD HH24:MI:SS"
|
|
936
|
+
# end
|
|
937
|
+
#
|
|
938
|
+
# external_data.datetime_format #=> "YYYY-MM-DD HH24:MI:SS"
|
|
939
|
+
#
|
|
940
|
+
def datetime_format
|
|
941
|
+
@gapi.datetime_format
|
|
942
|
+
end
|
|
943
|
+
|
|
944
|
+
##
|
|
945
|
+
# Sets the format used to parse DATETIME values. Supports SQL-style
|
|
946
|
+
# values. See
|
|
947
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
948
|
+
#
|
|
949
|
+
# @param [String, nil] datetime_format The datetime format pattern. `nil` to unset.
|
|
950
|
+
#
|
|
951
|
+
# @example
|
|
952
|
+
# require "google/cloud/bigquery"
|
|
953
|
+
#
|
|
954
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
955
|
+
#
|
|
956
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
957
|
+
# ext.datetime_format = "YYYY-MM-DD HH24:MI:SS"
|
|
958
|
+
# end
|
|
959
|
+
#
|
|
960
|
+
# external_data.datetime_format #=> "YYYY-MM-DD HH24:MI:SS"
|
|
961
|
+
#
|
|
962
|
+
def datetime_format= datetime_format
|
|
963
|
+
frozen_check!
|
|
964
|
+
@gapi.datetime_format = datetime_format
|
|
965
|
+
end
|
|
966
|
+
|
|
967
|
+
##
|
|
968
|
+
# Format used to parse DATE values. Supports SQL-style values. See
|
|
969
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
970
|
+
#
|
|
971
|
+
# @return [String, nil] The date format pattern. `nil` if not set.
|
|
972
|
+
#
|
|
973
|
+
# @example
|
|
974
|
+
# require "google/cloud/bigquery"
|
|
975
|
+
#
|
|
976
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
977
|
+
#
|
|
978
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
979
|
+
# ext.date_format = "YYYY-MM-DD"
|
|
980
|
+
# end
|
|
981
|
+
#
|
|
982
|
+
# external_data.date_format #=> "YYYY-MM-DD"
|
|
983
|
+
#
|
|
984
|
+
def date_format
|
|
985
|
+
@gapi.date_format
|
|
986
|
+
end
|
|
987
|
+
|
|
988
|
+
##
|
|
989
|
+
# Sets the format used to parse DATE values. Supports SQL-style
|
|
990
|
+
# values. See
|
|
991
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
992
|
+
#
|
|
993
|
+
# @param [String, nil] date_format The date format pattern. `nil` to unset.
|
|
994
|
+
#
|
|
995
|
+
# @example
|
|
996
|
+
# require "google/cloud/bigquery"
|
|
997
|
+
#
|
|
998
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
999
|
+
#
|
|
1000
|
+
# external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
|
|
1001
|
+
# ext.date_format = "YYYY-MM-DD"
|
|
1002
|
+
# end
|
|
1003
|
+
#
|
|
1004
|
+
# external_data.date_format #=> "YYYY-MM-DD"
|
|
1005
|
+
#
|
|
1006
|
+
def date_format= date_format
|
|
1007
|
+
frozen_check!
|
|
1008
|
+
@gapi.date_format = date_format
|
|
1009
|
+
end
|
|
1010
|
+
|
|
747
1011
|
##
|
|
748
1012
|
# @private Google API Client object.
|
|
749
1013
|
def to_gapi
|
|
@@ -280,7 +280,8 @@ module Google
|
|
|
280
280
|
job_reference: job_ref,
|
|
281
281
|
configuration: Google::Apis::BigqueryV2::JobConfiguration.new(
|
|
282
282
|
extract: extract_config,
|
|
283
|
-
dry_run: options[:dryrun]
|
|
283
|
+
dry_run: options[:dryrun],
|
|
284
|
+
reservation: options[:reservation]
|
|
284
285
|
)
|
|
285
286
|
)
|
|
286
287
|
|
|
@@ -438,6 +439,18 @@ module Google
|
|
|
438
439
|
@gapi.configuration.extract.use_avro_logical_types = value
|
|
439
440
|
end
|
|
440
441
|
|
|
442
|
+
##
|
|
443
|
+
# Sets the reservation that job would use. User can specify a reservation
|
|
444
|
+
# to execute the job. If reservation is not set, reservation is determined
|
|
445
|
+
# based on the rules defined by the reservation assignments. The expected
|
|
446
|
+
# format is `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
447
|
+
# @param [String] value The reservation name.
|
|
448
|
+
#
|
|
449
|
+
# @!group Attributes
|
|
450
|
+
def reservation= value
|
|
451
|
+
@gapi.configuration.update! reservation: value
|
|
452
|
+
end
|
|
453
|
+
|
|
441
454
|
def cancel
|
|
442
455
|
raise "not implemented in #{self.class}"
|
|
443
456
|
end
|
|
@@ -327,8 +327,8 @@ module Google
|
|
|
327
327
|
end
|
|
328
328
|
|
|
329
329
|
##
|
|
330
|
-
#
|
|
331
|
-
#
|
|
330
|
+
# Output only. Final error result of the job. If present, indicates that
|
|
331
|
+
# the job has completed and was unsuccessful.
|
|
332
332
|
#
|
|
333
333
|
# @see https://cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API
|
|
334
334
|
# reference
|
|
@@ -346,8 +346,10 @@ module Google
|
|
|
346
346
|
end
|
|
347
347
|
|
|
348
348
|
##
|
|
349
|
-
#
|
|
350
|
-
# of
|
|
349
|
+
# Output only. The first errors encountered during the running of the
|
|
350
|
+
# job. The final message includes the number of errors that caused the
|
|
351
|
+
# process to stop. Errors here do not necessarily mean that the job has
|
|
352
|
+
# not completed or was unsuccessful.
|
|
351
353
|
#
|
|
352
354
|
# @return [Array<Hash>, nil] Returns an array of hashes containing
|
|
353
355
|
# `reason` and `message` keys:
|