Class: Dag::Table
Instance Attribute Summary collapse
-
#cluster_name ⇒ Object
readonly
Returns the value of attribute cluster_name.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#db_name ⇒ Object
readonly
Returns the value of attribute db_name.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#modified_at ⇒ Object
readonly
Returns the value of attribute modified_at.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Model
Class Method Summary collapse
Instance Method Summary collapse
- #current_schema ⇒ Object (also: #schema)
- #delete ⇒ Object
-
#initialize(api, cluster_name, db_name, params: {}) ⇒ Table
constructor
A new instance of Table.
- #update(schema: nil, format: nil, comment: nil) ⇒ Object
Constructor Details
#initialize(api, cluster_name, db_name, params: {}) ⇒ Table
Returns a new instance of Table.
3 4 5 6 7 8 |
# File 'lib/dag/client/model/table.rb', line 3 def initialize(api, cluster_name, db_name, params: {}) super(api) @cluster_name = cluster_name @db_name = db_name load_table_info(params) end |
Instance Attribute Details
#cluster_name ⇒ Object (readonly)
Returns the value of attribute cluster_name.
10 11 12 |
# File 'lib/dag/client/model/table.rb', line 10 def cluster_name @cluster_name end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
10 11 12 |
# File 'lib/dag/client/model/table.rb', line 10 def comment @comment end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
10 11 12 |
# File 'lib/dag/client/model/table.rb', line 10 def created_at @created_at end |
#db_name ⇒ Object (readonly)
Returns the value of attribute db_name.
10 11 12 |
# File 'lib/dag/client/model/table.rb', line 10 def db_name @db_name end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
10 11 12 |
# File 'lib/dag/client/model/table.rb', line 10 def format @format end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
10 11 12 |
# File 'lib/dag/client/model/table.rb', line 10 def location @location end |
#modified_at ⇒ Object (readonly)
Returns the value of attribute modified_at.
10 11 12 |
# File 'lib/dag/client/model/table.rb', line 10 def modified_at @modified_at end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/dag/client/model/table.rb', line 10 def name @name end |
Class Method Details
.json_agent_partition_keys?(partition) ⇒ Boolean
37 38 39 40 |
# File 'lib/dag/client/model/table.rb', line 37 def self.json_agent_partition_keys?(partition) (partition['name'] == 'date' && partition['type'] == 'string') || (partition['name'] == 'hour' && partition['type'] == 'string') end |
Instance Method Details
#current_schema ⇒ Object Also known as: schema
31 32 33 |
# File 'lib/dag/client/model/table.rb', line 31 def current_schema @columns.map { |c| "#{c['name']} #{c['type']}" }.join(", ") if @columns.present? end |
#delete ⇒ Object
27 28 29 |
# File 'lib/dag/client/model/table.rb', line 27 def delete @api.delete_table(@cluster_name, @db_name, @name) end |
#update(schema: nil, format: nil, comment: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dag/client/model/table.rb', line 12 def update(schema: nil, format: nil, comment: nil) parameters = { table: @name, comment: comment || @comment, format: format || @table_info['format'], schema: schema || current_schema, } @api.create_table(@cluster_name, @db_name, params: parameters) info = @api.table(@cluster_name, @db_name, @name) load_table_info(info) self end |