class Dag::TableCollection

Attributes

cluster_name[R]

Public Class Methods

new(api, cluster_name, db_name) click to toggle source
Calls superclass method Dag::Model::new
# File lib/dag/client/model/table_collection.rb, line 8
def initialize(api, cluster_name, db_name)
  super(api)

  @cluster_name = cluster_name
  @db_name = db_name
end

Public Instance Methods

create(table: '', format: nil, schema: nil, comment: nil) click to toggle source

parameters ==

  • table - table name

  • format - 'csv' or 'tsv' or 'json' or 'json_agent'

  • <tt>schema/tt> - schema

  • comment - comment

# File lib/dag/client/model/table_collection.rb, line 34
def create(table: '', format: nil, schema: nil, comment: nil)
  params = {
    table: table,
    schema: schema,
    create_api: true
  }
  params.merge!({ format: format }) if format
  params.merge!({ comment: comment }) if comment

  @api.create_table(@cluster_name, @db_name, params: params)
  table_info = @api.table(@cluster_name, @db_name, table)
  Dag::Table.new(@api, @cluster_name, @db_name, params: table_info)
end
each() { |table(api, cluster_name, db_name, params: table_info)| ... } click to toggle source
# File lib/dag/client/model/table_collection.rb, line 15
def each
  marker = nil
  truncated = false
  begin
    table_info_list = @api.table_info_list(@cluster_name, @db_name, make_options(marker))
    table_info_list['tables'].each do |table_info|
      yield Dag::Table.new(@api, @cluster_name, @db_name, params: table_info)
    end
    truncated = table_info_list['isTruncated']
    marker = table_info_list['nextMarker']
  end while truncated
end

Private Instance Methods

make_options(marker = nil) click to toggle source
# File lib/dag/client/model/table_collection.rb, line 50
def make_options(marker = nil)
  options = { max: 100 }

  if marker
    options = options.merge(marker: marker)
  end

  options
end