Class: AnalyticsOps::BigQuery::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/analytics_ops/bigquery/definition.rb,
sig/analytics_ops.rbs

Overview

Immutable, bounded result returned by the optional BigQuery adapter.

Constant Summary collapse

NAME =
/\A[A-Za-z][A-Za-z0-9_]{0,71}\z/
HEADER =
/\A[A-Za-z_][A-Za-z0-9_]{0,127}\z/
MAX_ROWS =
10_000
MAX_CELL_BYTES =
1_048_576

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, headers:, rows:, bytes_processed:, maximum_bytes_billed:) ⇒ Result

Returns a new instance of Result.



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/analytics_ops/bigquery/definition.rb', line 89

def initialize(name:, headers:, rows:, bytes_processed:, maximum_bytes_billed:)
  validate_name!(name)
  validate_headers!(headers)
  normalized_rows = validate_rows(rows, headers)
  validate_byte_counts!(bytes_processed, maximum_bytes_billed)

  @name = name.dup.freeze
  @headers = Canonical.immutable(headers)
  @rows = Canonical.immutable(normalized_rows)
  @bytes_processed = bytes_processed
  @maximum_bytes_billed = maximum_bytes_billed
  freeze
end

Instance Attribute Details

#bytes_processedInteger (readonly)

Returns the value of attribute bytes_processed.

Returns:

  • (Integer)


87
88
89
# File 'lib/analytics_ops/bigquery/definition.rb', line 87

def bytes_processed
  @bytes_processed
end

#headersArray[String] (readonly)

Returns the value of attribute headers.

Returns:

  • (Array[String])


87
88
89
# File 'lib/analytics_ops/bigquery/definition.rb', line 87

def headers
  @headers
end

#maximum_bytes_billedInteger (readonly)

Returns the value of attribute maximum_bytes_billed.

Returns:

  • (Integer)


87
88
89
# File 'lib/analytics_ops/bigquery/definition.rb', line 87

def maximum_bytes_billed
  @maximum_bytes_billed
end

#nameString (readonly)

Returns the value of attribute name.

Returns:

  • (String)


87
88
89
# File 'lib/analytics_ops/bigquery/definition.rb', line 87

def name
  @name
end

#rowsArray[record] (readonly)

Returns the value of attribute rows.

Returns:

  • (Array[record])


87
88
89
# File 'lib/analytics_ops/bigquery/definition.rb', line 87

def rows
  @rows
end

Instance Method Details

#to_hrecord

Returns:

  • (record)


103
104
105
106
107
108
109
110
111
112
113
# File 'lib/analytics_ops/bigquery/definition.rb', line 103

def to_h
  {
    "experimental" => true,
    "name" => name,
    "headers" => headers,
    "rows" => rows,
    "row_count" => rows.length,
    "bytes_processed" => bytes_processed,
    "maximum_bytes_billed" => maximum_bytes_billed
  }
end