Class BigQueryInsertRow (2.2.0)

public sealed class BigQueryInsertRow : IEnumerable

A row used for streaming data insertion.

Inheritance

Object > BigQueryInsertRow

Implements

IEnumerable

Namespace

Google.Cloud.BigQuery.V2

Assembly

Google.Cloud.BigQuery.V2.dll

Remarks

This is effectively a dictionary where each key is the field name (a string) and the value is the corresponding value for that field. Supported value types:

  • System.Boolean
  • System.Int16
  • System.UInt16
  • System.Int32
  • System.UInt32
  • System.Int64
  • System.Float
  • System.Double
  • System.String
  • System.DateTime
  • System.DateTimeOffset
  • System.TimeSpan
  • Google.Cloud.BigQuery.V2.BigQueryNumeric
  • Google.Cloud.BigQuery.V2.BigQueryGeography
  • A Google.Cloud.BigQuery.V2.InsertRow (for record/struct fields)
  • Any IReadOnlyList<T> of one of the above types (for repeated fields). This includes arrays and List<T> values.

Note that all integer types are stored as System.Int64, and all floating point types are stored as System.Double.

DateTimeOffset values are converted to UTC and treated as timestamp. The handling of DateTime values depends on the Kind: values with a Kind of Local are rejected; values with a Kind of UTC are treated as timestamps; values with a Kind of Unspecified are treated as civil datetime values. All values are stored with a precision of a microsecond.

TimeSpan values must be non-negative and less than 24 hours, used to represent a time-of-day.

Although date values are retrieved as System.DateTime, they must be inserted as string values, in the format "yyyy-MM-dd".

BigQueryInsertRow is used for record/struct fields for convenience, but only the InsertId of the top-level row is relevant.

Null elements within repeated fields are prohibited. This is validated client-side when the row is inserted; validating when a value is added to the row would be ineffective as the values could change before insertion.

Constructors

BigQueryInsertRow()

public BigQueryInsertRow()

Constructs an empty row with no insert ID.

BigQueryInsertRow(String)

public BigQueryInsertRow(string insertId)

Constructs an empty row with the specified insert ID.

Parameter
NameDescription
insertIdString

Insert ID used for deduplication. May be null.

Properties

InsertId

public string InsertId { get; set; }

To help ensure data consistency, you can supply an InsertId for each inserted row. BigQuery remembers this ID for at least one minute. If you try to stream the same set of rows within that time period and the insertId property is set, BigQuery uses the property to de-duplicate your data on a best effort basis. By default if no ID is specified, one will be generated to allow de-duplicating efforts if insert operations need to be retried. You can allow empty InsertId by setting AllowEmptyInsertIds to true. This will allow for faster row inserts at the expense of possible record duplication if the operation needs to be retried. See https://cloud.google.com/bigquery/quotas#streaming_inserts for more information.

Property Value
TypeDescription
String

Item[String]

public object this[string name] { get; set; }

Accesses a field in the row by name.

Parameter
NameDescription
nameString

The name of the field to access. Must be a valid BigQuery field name.

Property Value
TypeDescription
Object

The value associated with name.

Exceptions
TypeDescription
KeyNotFoundException

The row does not have a key with the given name.

Methods

Add(IDictionary<String, Object>)

public void Add(IDictionary<string, object> fields)

Adds all the values in the specified dictionary to the row.

Parameter
NameDescription
fieldsIDictionary<String, Object>

The fields to add to the row. Must not be null.

Remarks

This being named Add rather than AddRange allows it to be specified in a collection initializer, which can be useful to provide a set of common fields and then some extra values.

Add(String, Object)

public void Add(string key, object value)

Adds a single field value to the row.

Parameters
NameDescription
keyString

The name of the field. Must be a valid BigQuery field name.

valueObject

The value for the field, which must be null or one of the supported types.

Explicit Interface Implementations

IEnumerable.GetEnumerator()

IEnumerator IEnumerable.GetEnumerator()

Returns an enumerator over the fields in this insert row. This method is only provided in order to implement IEnumerable, to permit collection initializers.

Returns
TypeDescription
IEnumerator

An enumerator over the fields in this insert row.