1.64.1 (latest) 1.64.0 1.63.1 1.62.0 1.61.1 1.60.0 1.59.0 1.58.0 1.57.0 1.56.0 1.55.0 1.54.0 1.53.0 1.52.1 1.51.1 1.50.0 1.49.1 1.48.1 1.47.0 1.46.1 1.45.0 1.44.2 1.43.1 1.42.0 1.41.0 1.40.0 1.39.0 1.38.1 Reference documentation and code samples for the BigQuery API class Google::Cloud::Bigquery::External::DataSource.

## DataSource

External::DataSource and its subclasses represents an external data
source that can be queried from directly, even though the data is not
stored in BigQuery. Instead of loading or streaming the data, this
object references the external data source.

The AVRO and Datastore Backup formats use [DataSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource "Google::Cloud::Bigquery::External::DataSource (class)"). See
[CsvSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-CsvSource "Google::Cloud::Bigquery::External::CsvSource (class)"), [JsonSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-JsonSource "Google::Cloud::Bigquery::External::JsonSource (class)"),
[SheetsSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-SheetsSource "Google::Cloud::Bigquery::External::SheetsSource (class)"), [BigtableSource](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-BigtableSource "Google::Cloud::Bigquery::External::BigtableSource (class)") for the other
formats.

## Inherits

- Object

## Examples

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

avro_url = "gs://bucket/path/to/*.avro"
avro_table = bigquery.external avro_url do |avro|
  avro.autodetect = true
end

data = bigquery.query "SELECT * FROM my_ext_table",
                      external: { my_ext_table: avro_table }

# Iterate over the first page of results
data.each do |row|
  puts row[:name]
end
# Retrieve the next page of results
data = data.next if data.next?
```

Hive partitioning options:

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

gcs_uri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/*"
source_uri_prefix = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/"
external_data = bigquery.external gcs_uri, format: :parquet do |ext|
  ext.hive_partitioning_mode = :auto
  ext.hive_partitioning_require_partition_filter = true
  ext.hive_partitioning_source_uri_prefix = source_uri_prefix
end

external_data.hive_partitioning? #=> true
external_data.hive_partitioning_mode #=> "AUTO"
external_data.hive_partitioning_require_partition_filter? #=> true
external_data.hive_partitioning_source_uri_prefix #=> source_uri_prefix
```

## Methods

### #autodetect

    def autodetect() -> Boolean

Indicates if the schema and format options are detected
automatically.
**Returns**

- (Boolean)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url do |csv|
  csv.autodetect = true
end

csv_table.autodetect #=> true
```

### #autodetect=

    def autodetect=(new_autodetect)

Set whether to detect schema and format options automatically. Any
option specified explicitly will be honored.
**Parameter**

- **new_autodetect** (Boolean) --- New autodetect value
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url do |csv|
  csv.autodetect = true
end

csv_table.autodetect #=> true
```

### #avro?

    def avro?() -> Boolean

Whether the data format is "AVRO".
**Returns**

- (Boolean)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

avro_url = "gs://bucket/path/to/*.avro"
avro_table = bigquery.external avro_url

avro_table.format #=> "AVRO"
avro_table.avro? #=> true
```

### #backup?

    def backup?() -> Boolean

Whether the data format is "DATASTORE_BACKUP".
**Returns**

- (Boolean)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

backup_url = "gs://bucket/path/to/data.backup_info"
backup_table = bigquery.external backup_url

backup_table.format #=> "DATASTORE_BACKUP"
backup_table.backup? #=> true
```

### #bigtable?

    def bigtable?() -> Boolean

Whether the data format is "BIGTABLE".
**Returns**

- (Boolean)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

bigtable_url = "https://googleapis.com/bigtable/projects/..."
bigtable_table = bigquery.external bigtable_url

bigtable_table.format #=> "BIGTABLE"
bigtable_table.bigtable? #=> true
```

### #compression

    def compression() -> String

The compression type of the data source. Possible values include
`"GZIP"` and `nil`. The default value is `nil`. This setting is
ignored for Google Cloud Bigtable, Google Cloud Datastore backups
and Avro formats. Optional.
**Returns**

- (String)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url do |csv|
  csv.compression = "GZIP"
end

csv_table.compression #=> "GZIP"
```

### #compression=

    def compression=(new_compression)

Set the compression type of the data source. Possible values include
`"GZIP"` and `nil`. The default value is `nil`. This setting is
ignored for Google Cloud Bigtable, Google Cloud Datastore backups
and Avro formats. Optional.
**Parameter**

- **new_compression** (String) --- New compression value
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url do |csv|
  csv.compression = "GZIP"
end

csv_table.compression #=> "GZIP"
```

### #csv?

    def csv?() -> Boolean

Whether the data format is "CSV".
**Returns**

- (Boolean)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url

csv_table.format #=> "CSV"
csv_table.csv? #=> true
```

### #date_format

    def date_format() -> String, nil

Format used to parse DATE values. Supports SQL-style values. See
[date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
**Returns**

- (String, nil) --- The date format pattern. `nil` if not set.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
  ext.date_format = "YYYY-MM-DD"
end

external_data.date_format #=> "YYYY-MM-DD"
```

### #date_format=

    def date_format=(date_format)

Sets the format used to parse DATE values. Supports SQL-style
values. See
[date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
**Parameter**

- **date_format** (String, nil) --- The date format pattern. `nil` to unset.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
  ext.date_format = "YYYY-MM-DD"
end

external_data.date_format #=> "YYYY-MM-DD"
```

### #datetime_format

    def datetime_format() -> String, nil

Format used to parse DATETIME values. Supports SQL-style values. See
[date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
**Returns**

- (String, nil) --- The datetime format pattern. `nil` if not set.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
  ext.datetime_format = "YYYY-MM-DD HH24:MI:SS"
end

external_data.datetime_format #=> "YYYY-MM-DD HH24:MI:SS"
```

### #datetime_format=

    def datetime_format=(datetime_format)

Sets the format used to parse DATETIME values. Supports SQL-style
values. See
[date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
**Parameter**

- **datetime_format** (String, nil) --- The datetime format pattern. `nil` to unset.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
  ext.datetime_format = "YYYY-MM-DD HH24:MI:SS"
end

external_data.datetime_format #=> "YYYY-MM-DD HH24:MI:SS"
```

### #format

    def format() -> String

The data format. For CSV files, specify "CSV". For Google sheets,
specify "GOOGLE_SHEETS". For newline-delimited JSON, specify
"NEWLINE_DELIMITED_JSON". For Avro files, specify "AVRO". For Google
Cloud Datastore backups, specify "DATASTORE_BACKUP". \[Beta\] For
Google Cloud Bigtable, specify "BIGTABLE".
**Returns**

- (String)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url

csv_table.format #=> "CSV"
```

### #hive_partitioning?

    def hive_partitioning?() -> Boolean

Checks if hive partitioning options are set.


<br />

Not all storage formats support hive partitioning. Requesting hive partitioning on an unsupported format
will lead to an error. Currently supported types include: `avro`, `csv`, `json`, `orc` and `parquet`.
If your data is stored in ORC or Parquet on Cloud Storage, see [Querying columnar formats on Cloud
Storage](https://cloud.google.com/bigquery/pricing#columnar_formats_pricing).
**Returns**

- (Boolean) --- `true` when hive partitioning options are set, or `false` otherwise.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

gcs_uri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/*"
source_uri_prefix = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/"
external_data = bigquery.external gcs_uri, format: :parquet do |ext|
  ext.hive_partitioning_mode = :auto
  ext.hive_partitioning_require_partition_filter = true
  ext.hive_partitioning_source_uri_prefix = source_uri_prefix
end

external_data.hive_partitioning? #=> true
external_data.hive_partitioning_mode #=> "AUTO"
external_data.hive_partitioning_require_partition_filter? #=> true
external_data.hive_partitioning_source_uri_prefix #=> source_uri_prefix
```

### #hive_partitioning_mode

    def hive_partitioning_mode() -> String, nil

The mode of hive partitioning to use when reading data. The following modes are supported:

1. `AUTO`: automatically infer partition key name(s) and type(s).
2. `STRINGS`: automatically infer partition key name(s). All types are interpreted as strings.
3. `CUSTOM`: partition key schema is encoded in the source URI prefix.
**Returns**

- (String, nil) --- The mode of hive partitioning, or `nil` if not set.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

gcs_uri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/*"
source_uri_prefix = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/"
external_data = bigquery.external gcs_uri, format: :parquet do |ext|
  ext.hive_partitioning_mode = :auto
  ext.hive_partitioning_require_partition_filter = true
  ext.hive_partitioning_source_uri_prefix = source_uri_prefix
end

external_data.hive_partitioning? #=> true
external_data.hive_partitioning_mode #=> "AUTO"
external_data.hive_partitioning_require_partition_filter? #=> true
external_data.hive_partitioning_source_uri_prefix #=> source_uri_prefix
```

### #hive_partitioning_mode=

    def hive_partitioning_mode=(mode)

Sets the mode of hive partitioning to use when reading data. The following modes are supported:


1. `auto`: automatically infer partition key name(s) and type(s).
2. `strings`: automatically infer partition key name(s). All types are interpreted as strings.
3. `custom`: partition key schema is encoded in the source URI prefix.

Not all storage formats support hive partitioning. Requesting hive partitioning on an unsupported format
will lead to an error. Currently supported types include: `avro`, `csv`, `json`, `orc` and `parquet`.
If your data is stored in ORC or Parquet on Cloud Storage, see [Querying columnar formats on Cloud
Storage](https://cloud.google.com/bigquery/pricing#columnar_formats_pricing).

<br />

See [#format](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource#Google__Cloud__Bigquery__External__DataSource_format_instance_ "Google::Cloud::Bigquery::External::DataSource#format (method)"), [#hive_partitioning_require_partition_filter=](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource#Google__Cloud__Bigquery__External__DataSource_hive_partitioning_require_partition_filter__instance_ "Google::Cloud::Bigquery::External::DataSource#hive_partitioning_require_partition_filter= (method)") and [#hive_partitioning_source_uri_prefix=](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource#Google__Cloud__Bigquery__External__DataSource_hive_partitioning_source_uri_prefix__instance_ "Google::Cloud::Bigquery::External::DataSource#hive_partitioning_source_uri_prefix= (method)").
**Parameter**

- **mode** (String, Symbol) --- The mode of hive partitioning to use when reading data.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

gcs_uri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/*"
source_uri_prefix = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/"
external_data = bigquery.external gcs_uri, format: :parquet do |ext|
  ext.hive_partitioning_mode = :auto
  ext.hive_partitioning_require_partition_filter = true
  ext.hive_partitioning_source_uri_prefix = source_uri_prefix
end

external_data.hive_partitioning? #=> true
external_data.hive_partitioning_mode #=> "AUTO"
external_data.hive_partitioning_require_partition_filter? #=> true
external_data.hive_partitioning_source_uri_prefix #=> source_uri_prefix
```

### #hive_partitioning_require_partition_filter=

    def hive_partitioning_require_partition_filter=(require_partition_filter)

Sets whether queries over the table using this external data source require a partition filter
that can be used for partition elimination to be specified.


<br />

See [#format](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource#Google__Cloud__Bigquery__External__DataSource_format_instance_ "Google::Cloud::Bigquery::External::DataSource#format (method)"), [#hive_partitioning_mode=](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource#Google__Cloud__Bigquery__External__DataSource_hive_partitioning_mode__instance_ "Google::Cloud::Bigquery::External::DataSource#hive_partitioning_mode= (method)") and [#hive_partitioning_source_uri_prefix=](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource#Google__Cloud__Bigquery__External__DataSource_hive_partitioning_source_uri_prefix__instance_ "Google::Cloud::Bigquery::External::DataSource#hive_partitioning_source_uri_prefix= (method)").
**Parameter**

- **require_partition_filter** (Boolean) --- `true` if a partition filter must be specified, `false` otherwise.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

gcs_uri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/*"
source_uri_prefix = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/"
external_data = bigquery.external gcs_uri, format: :parquet do |ext|
  ext.hive_partitioning_mode = :auto
  ext.hive_partitioning_require_partition_filter = true
  ext.hive_partitioning_source_uri_prefix = source_uri_prefix
end

external_data.hive_partitioning? #=> true
external_data.hive_partitioning_mode #=> "AUTO"
external_data.hive_partitioning_require_partition_filter? #=> true
external_data.hive_partitioning_source_uri_prefix #=> source_uri_prefix
```

### #hive_partitioning_require_partition_filter?

    def hive_partitioning_require_partition_filter?() -> Boolean

Whether queries over the table using this external data source require a partition filter that can be used
for partition elimination to be specified. Note that this field should only be true when creating a
permanent external table or querying a temporary external table.
**Returns**

- (Boolean) --- `true` when queries over this table require a partition filter, or `false` otherwise.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

gcs_uri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/*"
source_uri_prefix = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/"
external_data = bigquery.external gcs_uri, format: :parquet do |ext|
  ext.hive_partitioning_mode = :auto
  ext.hive_partitioning_require_partition_filter = true
  ext.hive_partitioning_source_uri_prefix = source_uri_prefix
end

external_data.hive_partitioning? #=> true
external_data.hive_partitioning_mode #=> "AUTO"
external_data.hive_partitioning_require_partition_filter? #=> true
external_data.hive_partitioning_source_uri_prefix #=> source_uri_prefix
```

### #hive_partitioning_source_uri_prefix

    def hive_partitioning_source_uri_prefix() -> String, nil

The common prefix for all source uris when hive partition detection is requested. The prefix must end
immediately before the partition key encoding begins. For example, consider files following this data
layout:


`
gs://bucket/path_to_table/dt=2019-01-01/country=BR/id=7/file.avro
gs://bucket/path_to_table/dt=2018-12-31/country=CA/id=3/file.avro
`

<br />

When hive partitioning is requested with either `AUTO` or `STRINGS` mode, the common prefix can be either of
`gs://bucket/path_to_table` or `gs://bucket/path_to_table/` (trailing slash does not matter).
**Returns**

- (String, nil) --- The common prefix for all source uris, or `nil` if not set.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

gcs_uri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/*"
source_uri_prefix = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/"
external_data = bigquery.external gcs_uri, format: :parquet do |ext|
  ext.hive_partitioning_mode = :auto
  ext.hive_partitioning_require_partition_filter = true
  ext.hive_partitioning_source_uri_prefix = source_uri_prefix
end

external_data.hive_partitioning? #=> true
external_data.hive_partitioning_mode #=> "AUTO"
external_data.hive_partitioning_require_partition_filter? #=> true
external_data.hive_partitioning_source_uri_prefix #=> source_uri_prefix
```

### #hive_partitioning_source_uri_prefix=

    def hive_partitioning_source_uri_prefix=(source_uri_prefix)

Sets the common prefix for all source uris when hive partition detection is requested. The prefix must end
immediately before the partition key encoding begins. For example, consider files following this data
layout:


`
gs://bucket/path_to_table/dt=2019-01-01/country=BR/id=7/file.avro
gs://bucket/path_to_table/dt=2018-12-31/country=CA/id=3/file.avro
`

When hive partitioning is requested with either `AUTO` or `STRINGS` mode, the common prefix can be either of
`gs://bucket/path_to_table` or `gs://bucket/path_to_table/` (trailing slash does not matter).

<br />

See [#format](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource#Google__Cloud__Bigquery__External__DataSource_format_instance_ "Google::Cloud::Bigquery::External::DataSource#format (method)"), [#hive_partitioning_mode=](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource#Google__Cloud__Bigquery__External__DataSource_hive_partitioning_mode__instance_ "Google::Cloud::Bigquery::External::DataSource#hive_partitioning_mode= (method)") and [#hive_partitioning_require_partition_filter=](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-bigquery/latest/Google-Cloud-Bigquery-External-DataSource#Google__Cloud__Bigquery__External__DataSource_hive_partitioning_require_partition_filter__instance_ "Google::Cloud::Bigquery::External::DataSource#hive_partitioning_require_partition_filter= (method)").
**Parameter**

- **source_uri_prefix** (String) --- The common prefix for all source uris.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

gcs_uri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/*"
source_uri_prefix = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/"
external_data = bigquery.external gcs_uri, format: :parquet do |ext|
  ext.hive_partitioning_mode = :auto
  ext.hive_partitioning_require_partition_filter = true
  ext.hive_partitioning_source_uri_prefix = source_uri_prefix
end

external_data.hive_partitioning? #=> true
external_data.hive_partitioning_mode #=> "AUTO"
external_data.hive_partitioning_require_partition_filter? #=> true
external_data.hive_partitioning_source_uri_prefix #=> source_uri_prefix
```

### #ignore_unknown

    def ignore_unknown() -> Boolean

Indicates if BigQuery should allow extra values that are not
represented in the table schema. If `true`, the extra values are
ignored. If `false`, records with extra columns are treated as bad
records, and if there are too many bad records, an invalid error is
returned in the job result. The default value is `false`.


<br />

BigQuery treats trailing columns as an extra in `CSV`, named values
that don't match any column names in `JSON`. This setting is ignored
for Google Cloud Bigtable, Google Cloud Datastore backups and Avro
formats. Optional.
**Returns**

- (Boolean)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url do |csv|
  csv.ignore_unknown = true
end

csv_table.ignore_unknown #=> true
```

### #ignore_unknown=

    def ignore_unknown=(new_ignore_unknown)

Set whether BigQuery should allow extra values that are not
represented in the table schema. If `true`, the extra values are
ignored. If `false`, records with extra columns are treated as bad
records, and if there are too many bad records, an invalid error is
returned in the job result. The default value is `false`.


<br />

BigQuery treats trailing columns as an extra in `CSV`, named values
that don't match any column names in `JSON`. This setting is ignored
for Google Cloud Bigtable, Google Cloud Datastore backups and Avro
formats. Optional.
**Parameter**

- **new_ignore_unknown** (Boolean) --- New ignore_unknown value
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url do |csv|
  csv.ignore_unknown = true
end

csv_table.ignore_unknown #=> true
```

### #json?

    def json?() -> Boolean

Whether the data format is "NEWLINE_DELIMITED_JSON".
**Returns**

- (Boolean)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

json_url = "gs://bucket/path/to/data.json"
json_table = bigquery.external json_url

json_table.format #=> "NEWLINE_DELIMITED_JSON"
json_table.json? #=> true
```

### #max_bad_records

    def max_bad_records() -> Integer

The maximum number of bad records that BigQuery can ignore when
reading data. If the number of bad records exceeds this value, an
invalid error is returned in the job result. The default value is 0,
which requires that all records are valid. This setting is ignored
for Google Cloud Bigtable, Google Cloud Datastore backups and Avro
formats.
**Returns**

- (Integer)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url do |csv|
  csv.max_bad_records = 10
end

csv_table.max_bad_records #=> 10
```

### #max_bad_records=

    def max_bad_records=(new_max_bad_records)

Set the maximum number of bad records that BigQuery can ignore when
reading data. If the number of bad records exceeds this value, an
invalid error is returned in the job result. The default value is 0,
which requires that all records are valid. This setting is ignored
for Google Cloud Bigtable, Google Cloud Datastore backups and Avro
formats.
**Parameter**

- **new_max_bad_records** (Integer) --- New max_bad_records value
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url do |csv|
  csv.max_bad_records = 10
end

csv_table.max_bad_records #=> 10
```

### #orc?

    def orc?() -> Boolean

Whether the data format is "ORC".
**Returns**

- (Boolean)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

gcs_uri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/*"
source_uri_prefix = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/"
external_data = bigquery.external gcs_uri, format: :orc do |ext|
  ext.hive_partitioning_mode = :auto
  ext.hive_partitioning_source_uri_prefix = source_uri_prefix
end
external_data.format #=> "ORC"
external_data.orc? #=> true
```

### #parquet?

    def parquet?() -> Boolean

Whether the data format is "PARQUET".
**Returns**

- (Boolean)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

gcs_uri = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/*"
source_uri_prefix = "gs://cloud-samples-data/bigquery/hive-partitioning-samples/autolayout/"
external_data = bigquery.external gcs_uri, format: :parquet do |ext|
  ext.hive_partitioning_mode = :auto
  ext.hive_partitioning_source_uri_prefix = source_uri_prefix
end
external_data.format #=> "PARQUET"
external_data.parquet? #=> true
```

### #reference_file_schema_uri

    def reference_file_schema_uri() -> String, nil

The URI of a reference file with the table schema. This is enabled
for the following formats: `AVRO`, `PARQUET`, `ORC`.
**Returns**

- (String, nil) --- The URI. `nil` if not set.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.avro", format: :avro do |ext|
  ext.reference_file_schema_uri = "gs://bucket/path/to/schema.json"
end

external_data.reference_file_schema_uri #=> "gs://bucket/path/to/schema.json"
```

### #reference_file_schema_uri=

    def reference_file_schema_uri=(uri)

Sets the URI of a reference file with the table schema. This is
enabled for the following formats: `AVRO`, `PARQUET`, `ORC`.
**Parameter**

- **uri** (String, nil) --- The URI. `nil` to unset.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.avro", format: :avro do |ext|
  ext.reference_file_schema_uri = "gs://bucket/path/to/schema.json"
end

external_data.reference_file_schema_uri #=> "gs://bucket/path/to/schema.json"
```

### #sheets?

    def sheets?() -> Boolean

Whether the data format is "GOOGLE_SHEETS".
**Returns**

- (Boolean)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

sheets_url = "https://docs.google.com/spreadsheets/d/1234567980"
sheets_table = bigquery.external sheets_url

sheets_table.format #=> "GOOGLE_SHEETS"
sheets_table.sheets? #=> true
```

### #time_format

    def time_format() -> String, nil

Format used to parse TIME values. Supports SQL-style values. See
[date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
**Returns**

- (String, nil) --- The time format pattern. `nil` if not set.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
  ext.time_format = "HH24:MI:SS"
end

external_data.time_format #=> "HH24:MI:SS"
```

### #time_format=

    def time_format=(time_format)

Sets the format used to parse TIME values. Supports SQL-style See
[date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
values.
**Parameter**

- **time_format** (String, nil) --- The time format pattern. `nil` if not set.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
  ext.time_format = "HH24:MI:SS"
end

external_data.time_format #=> "HH24:MI:SS"
```

### #time_zone

    def time_zone() -> String, nil

Time zone used when parsing timestamp values that do not have specific
time zone information (e.g. `2024-04-20 12:34:56`). The expected format
is an IANA timezone string (e.g. `America/Los_Angeles`).
**Returns**

- (String, nil) --- The IANA time zone name. `nil` if not set.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
  ext.time_zone = "America/Los_Angeles"
end

external_data.time_zone #=> "America/Los_Angeles"
```

### #time_zone=

    def time_zone=(time_zone)

Sets the time zone used when parsing timestamp values that do not have
specific time zone information (e.g. `2024-04-20 12:34:56`). The expected
format is an IANA timezone string (e.g. `America/Los_Angeles`).
**Parameter**

- **time_zone** (String, nil) --- The IANA time zone name. `nil` to unset.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
  ext.time_zone = "America/Los_Angeles"
end

external_data.time_zone #=> "America/Los_Angeles"
```

### #timestamp_format

    def timestamp_format() -> String, nil

Format used to parse TIMESTAMP values. Supports SQL-style values. See
[date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
**Returns**

- (String, nil) --- The timestamp format pattern. `nil` if not set.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
  ext.timestamp_format = "YYYY-MM-DD HH24:MI:SS.FF3 TZH"
end

external_data.timestamp_format #=> "YYYY-MM-DD HH24:MI:SS.FF3 TZH"
```

### #timestamp_format=

    def timestamp_format=(timestamp_format)

Sets the format used to parse TIMESTAMP values. Supports SQL-style
values. See
[date and time formatting guide](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_date_time_as_string)
**Parameter**

- **timestamp_format** (String, nil) --- The timestamp format pattern. `nil` to unset.
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

external_data = bigquery.external "gs://bucket/path/to/data.csv" do |ext|
  ext.timestamp_format = "YYYY-MM-DD HH24:MI:SS.FF3 TZH"
end

external_data.timestamp_format #=> "YYYY-MM-DD HH24:MI:SS.FF3 TZH"
```

### #urls

    def urls() -> Array<String>

The fully-qualified URIs that point to your data in Google Cloud.
For Google Cloud Storage URIs: Each URI can contain one '*' wildcard
character and it must come after the 'bucket' name. Size limits
related to load jobs apply to external data sources. For Google
Cloud Bigtable URIs: Exactly one URI can be specified and it has be
a fully specified and valid HTTPS URL for a Google Cloud Bigtable
table. For Google Cloud Datastore backups, exactly one URI can be
specified, and it must end with '.backup_info'. Also, the '*'
wildcard character is not allowed.
**Returns**

- (Array\<String\>)
**Example**

```ruby
require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

csv_url = "gs://bucket/path/to/data.csv"
csv_table = bigquery.external csv_url

csv_table.urls #=> ["gs://bucket/path/to/data.csv"]
```