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
|
@@ -652,6 +652,111 @@ 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 SQL-style values. See
|
|
657
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
658
|
+
#
|
|
659
|
+
# @return [String, nil] The date format pattern, such as
|
|
660
|
+
# `YYYY-MM-DD`. `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 SQL-style values. See
|
|
667
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
668
|
+
#
|
|
669
|
+
# @return [String, nil] The datetime format pattern, such as
|
|
670
|
+
# `YYYY-MM-DD HH24:MI:SS`. `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 SQL-style values. See
|
|
677
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
678
|
+
#
|
|
679
|
+
# @return [String, nil] The time format pattern, such as
|
|
680
|
+
# `HH24:MI:SS`. `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 SQL-style values. See
|
|
687
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
688
|
+
#
|
|
689
|
+
# @return [String, nil] The timestamp format pattern, such as
|
|
690
|
+
# `YYYY-MM-DD HH24:MI:SS.FF3 TZH`. `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
|
+
|
|
739
|
+
##
|
|
740
|
+
# The URI of the reference file with the reader schema. This file is only
|
|
741
|
+
# loaded if it is part of source URIs, but is not loaded otherwise.
|
|
742
|
+
# It is enabled for the following formats: `AVRO`, `PARQUET`, `ORC`.
|
|
743
|
+
#
|
|
744
|
+
# @return [String, nil] The URI of the reference file, or `nil` if not set.
|
|
745
|
+
def reference_file_schema_uri
|
|
746
|
+
@gapi.configuration.load.reference_file_schema_uri
|
|
747
|
+
end
|
|
748
|
+
|
|
749
|
+
# When source_format is set to `CSV`, indicates if the embedded ASCII
|
|
750
|
+
# control characters (the first 32 characters in the ASCII-table, from
|
|
751
|
+
# `\x00` to `\x1F`) are preserved. By default, ASCII control
|
|
752
|
+
# characters are not preserved.
|
|
753
|
+
#
|
|
754
|
+
# @return [Boolean, nil] whether or not ASCII control characters are
|
|
755
|
+
# preserved. `nil` if not set.
|
|
756
|
+
def preserve_ascii_control_characters
|
|
757
|
+
@gapi.configuration.load.preserve_ascii_control_characters
|
|
758
|
+
end
|
|
759
|
+
|
|
655
760
|
##
|
|
656
761
|
# Yielded to a block to accumulate changes for a patch request.
|
|
657
762
|
class Updater < LoadJob
|
|
@@ -2585,6 +2690,128 @@ module Google
|
|
|
2585
2690
|
@gapi.configuration.load.clustering.fields = fields
|
|
2586
2691
|
end
|
|
2587
2692
|
|
|
2693
|
+
##
|
|
2694
|
+
# Sets the format used to parse DATE values. Supports SQL-style
|
|
2695
|
+
# values. See
|
|
2696
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2697
|
+
#
|
|
2698
|
+
# @param [String, nil] date_format The date format pattern, such as
|
|
2699
|
+
# `YYYY-MM-DD`. `nil` to unset.
|
|
2700
|
+
def date_format= date_format
|
|
2701
|
+
@gapi.configuration.load.update! date_format: date_format
|
|
2702
|
+
end
|
|
2703
|
+
|
|
2704
|
+
##
|
|
2705
|
+
# Sets the format used to parse DATETIME values. Supports SQL-style
|
|
2706
|
+
# values. See
|
|
2707
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2708
|
+
#
|
|
2709
|
+
# @param [String, nil] datetime_format The datetime format pattern, such as
|
|
2710
|
+
# `YYYY-MM-DD HH24:MI:SS`. `nil` to unset.
|
|
2711
|
+
def datetime_format= datetime_format
|
|
2712
|
+
@gapi.configuration.load.update! datetime_format: datetime_format
|
|
2713
|
+
end
|
|
2714
|
+
|
|
2715
|
+
##
|
|
2716
|
+
# Sets the format used to parse TIME values. Supports SQL-style
|
|
2717
|
+
# values. See
|
|
2718
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2719
|
+
#
|
|
2720
|
+
# @param [String, nil] time_format The time format pattern, such as
|
|
2721
|
+
# `HH24:MI:SS`. `nil` to unset.
|
|
2722
|
+
def time_format= time_format
|
|
2723
|
+
@gapi.configuration.load.update! time_format: time_format
|
|
2724
|
+
end
|
|
2725
|
+
|
|
2726
|
+
##
|
|
2727
|
+
# Sets the format used to parse TIMESTAMP values. Supports SQL-style
|
|
2728
|
+
# values. See
|
|
2729
|
+
# [date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
|
|
2730
|
+
#
|
|
2731
|
+
# @param [String, nil] timestamp_format The timestamp format pattern, such as
|
|
2732
|
+
# `YYYY-MM-DD HH24:MI:SS.FF3 TZH`. `nil` to unset.
|
|
2733
|
+
def timestamp_format= timestamp_format
|
|
2734
|
+
@gapi.configuration.load.update! timestamp_format: timestamp_format
|
|
2735
|
+
end
|
|
2736
|
+
|
|
2737
|
+
##
|
|
2738
|
+
# Sets the list of strings represented as SQL NULL value in a CSV file.
|
|
2739
|
+
# null_marker and null_markers can't be set at the same time. If null_marker is
|
|
2740
|
+
# set, null_markers has to be not set. If null_markers is set, null_marker has
|
|
2741
|
+
# to be not set. If both null_marker and null_markers are set at the same time,
|
|
2742
|
+
# a user error would be thrown. Any strings listed in null_markers, including
|
|
2743
|
+
# empty string would be interpreted as SQL NULL. This applies to all column
|
|
2744
|
+
# types.
|
|
2745
|
+
#
|
|
2746
|
+
# @param [Array<String>] null_markers The array of null marker strings.
|
|
2747
|
+
def null_markers= null_markers
|
|
2748
|
+
@gapi.configuration.load.update! null_markers: null_markers
|
|
2749
|
+
end
|
|
2750
|
+
|
|
2751
|
+
# Sets the strategy used to match loaded columns to the schema.
|
|
2752
|
+
# If not set, a sensible default is chosen based on how the schema is
|
|
2753
|
+
# provided. If autodetect is used, then columns are matched by name.
|
|
2754
|
+
# Otherwise, columns are matched by position. This is done to keep the
|
|
2755
|
+
# behavior backward-compatible.
|
|
2756
|
+
#
|
|
2757
|
+
# Acceptable values are:
|
|
2758
|
+
# - `POSITION`: matches by position. Assumes columns are ordered the
|
|
2759
|
+
# same way as the schema.
|
|
2760
|
+
# - `NAME`: matches by name. Reads the header row as column names and
|
|
2761
|
+
# reorders columns to match the schema.
|
|
2762
|
+
#
|
|
2763
|
+
# @param [String, nil] source_column_match The new source column match value.
|
|
2764
|
+
# `nil` to unset.
|
|
2765
|
+
def source_column_match= source_column_match
|
|
2766
|
+
@gapi.configuration.load.update! source_column_match: source_column_match
|
|
2767
|
+
end
|
|
2768
|
+
|
|
2769
|
+
##
|
|
2770
|
+
# Sets the time zone used when parsing timestamp values that do not have
|
|
2771
|
+
# specific time zone information (e.g. `2024-04-20 12:34:56`). The expected
|
|
2772
|
+
# format is an IANA timezone string (e.g. `America/Los_Angeles`).
|
|
2773
|
+
#
|
|
2774
|
+
# @param [String, nil] time_zone The IANA time zone name, such as
|
|
2775
|
+
# `America/Los_Angeles`. `nil` to unset.
|
|
2776
|
+
def time_zone= time_zone
|
|
2777
|
+
@gapi.configuration.load.update! time_zone: time_zone
|
|
2778
|
+
end
|
|
2779
|
+
|
|
2780
|
+
##
|
|
2781
|
+
|
|
2782
|
+
# Sets the URI of the reference file with the reader schema. This file
|
|
2783
|
+
# is only loaded if it is part of source URIs, but is not loaded
|
|
2784
|
+
# otherwise. It is enabled for the following formats: `AVRO`,
|
|
2785
|
+
# `PARQUET`, `ORC`.
|
|
2786
|
+
#
|
|
2787
|
+
# @param [String, nil] uri The URI of the reference file, or `nil` to unset.
|
|
2788
|
+
def reference_file_schema_uri= uri
|
|
2789
|
+
@gapi.configuration.load.update! reference_file_schema_uri: uri
|
|
2790
|
+
end
|
|
2791
|
+
|
|
2792
|
+
# When source_format is set to `CSV`, sets whether the embedded ASCII
|
|
2793
|
+
# control characters (the first 32 characters in the ASCII-table, from
|
|
2794
|
+
# `\x00` to `\x1F`) are preserved. By default, ASCII control
|
|
2795
|
+
# characters are not preserved.
|
|
2796
|
+
#
|
|
2797
|
+
# @param [Boolean, nil] val whether or not ASCII control characters
|
|
2798
|
+
# are preserved. `nil` to unset.
|
|
2799
|
+
def preserve_ascii_control_characters= val
|
|
2800
|
+
@gapi.configuration.load.update! preserve_ascii_control_characters: val
|
|
2801
|
+
end
|
|
2802
|
+
|
|
2803
|
+
##
|
|
2804
|
+
# Sets the reservation that job would use. User can specify a reservation
|
|
2805
|
+
# to execute the job. If reservation is not set, reservation is determined
|
|
2806
|
+
# based on the rules defined by the reservation assignments. The expected
|
|
2807
|
+
# format is `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
2808
|
+
# @param [String] value The reservation name.
|
|
2809
|
+
#
|
|
2810
|
+
# @!group Attributes
|
|
2811
|
+
def reservation= value
|
|
2812
|
+
@gapi.configuration.update! reservation: value
|
|
2813
|
+
end
|
|
2814
|
+
|
|
2588
2815
|
def cancel
|
|
2589
2816
|
raise "not implemented in #{self.class}"
|
|
2590
2817
|
end
|
|
@@ -545,6 +545,11 @@ module Google
|
|
|
545
545
|
# * The key portion of a label must be unique. However, you can use the
|
|
546
546
|
# same key with multiple resources.
|
|
547
547
|
# * Keys must start with a lowercase letter or international character.
|
|
548
|
+
# @param [String] reservation The reservation that job would use. User
|
|
549
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
550
|
+
# set, reservation is determined based on the rules defined by the
|
|
551
|
+
# reservation assignments. The expected format is
|
|
552
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
548
553
|
#
|
|
549
554
|
# @yield [job] a job configuration object
|
|
550
555
|
# @yieldparam [Google::Cloud::Bigquery::ExtractJob::Updater] job a job
|
|
@@ -566,9 +571,9 @@ module Google
|
|
|
566
571
|
#
|
|
567
572
|
# @!group Data
|
|
568
573
|
#
|
|
569
|
-
def extract_job extract_url, format: nil, job_id: nil, prefix: nil, labels: nil
|
|
574
|
+
def extract_job extract_url, format: nil, job_id: nil, prefix: nil, labels: nil, reservation: nil
|
|
570
575
|
ensure_service!
|
|
571
|
-
options = { format: format, job_id: job_id, prefix: prefix, labels: labels }
|
|
576
|
+
options = { format: format, job_id: job_id, prefix: prefix, labels: labels, reservation: reservation }
|
|
572
577
|
updater = ExtractJob::Updater.from_options service, model_ref, extract_url, options
|
|
573
578
|
updater.location = location if location # may be model reference
|
|
574
579
|
|
|
@@ -603,6 +608,12 @@ module Google
|
|
|
603
608
|
#
|
|
604
609
|
# * `ml_tf_saved_model` - TensorFlow SavedModel
|
|
605
610
|
# * `ml_xgboost_booster` - XGBoost Booster
|
|
611
|
+
# @param [String] reservation The reservation that job would use. User
|
|
612
|
+
# can specify a reservation to execute the job. If reservation is not
|
|
613
|
+
# set, reservation is determined based on the rules defined by the
|
|
614
|
+
# reservation assignments. The expected format is
|
|
615
|
+
# `projects/`project`/locations/`location`/reservations/`reservation``.
|
|
616
|
+
#
|
|
606
617
|
# @yield [job] a job configuration object
|
|
607
618
|
# @yieldparam [Google::Cloud::Bigquery::ExtractJob::Updater] job a job
|
|
608
619
|
# configuration object for setting additional options.
|
|
@@ -620,8 +631,8 @@ module Google
|
|
|
620
631
|
#
|
|
621
632
|
# @!group Data
|
|
622
633
|
#
|
|
623
|
-
def extract extract_url, format: nil, &block
|
|
624
|
-
job = extract_job extract_url, format: format, &block
|
|
634
|
+
def extract extract_url, format: nil, reservation: nil, &block
|
|
635
|
+
job = extract_job extract_url, format: format, reservation: reservation, &block
|
|
625
636
|
job.wait_until_done!
|
|
626
637
|
ensure_job_succeeded! job
|
|
627
638
|
true
|