Class: DWH::TableStats
- Inherits:
-
Object
- Object
- DWH::TableStats
- Defined in:
- lib/dwh/table_stats.rb
Overview
TableStats is returned when calling Adapter#stat. This currently ust provide basic stats, but could be enhanced in the future to provide more introspection on the table. For examples, indexes and partition settings. Cardinality of various columns etc.
Instance Attribute Summary collapse
-
#date_end ⇒ DateTime
When a date column is passed to Adapters::Adapter#stats it returns the date of the last record in the table.
-
#date_start ⇒ DateTime
When a date column is passed to Adapters::Adapter#stats it will return date of first record in the table.
-
#row_count ⇒ Integer
Total rows in table.
Instance Method Summary collapse
-
#initialize(row_count: nil, date_start: nil, date_end: nil) ⇒ TableStats
constructor
A new instance of TableStats.
-
#to_h ⇒ Hash
Hash of the stats attributes.
Constructor Details
#initialize(row_count: nil, date_start: nil, date_end: nil) ⇒ TableStats
Returns a new instance of TableStats.
20 21 22 23 24 |
# File 'lib/dwh/table_stats.rb', line 20 def initialize(row_count: nil, date_start: nil, date_end: nil) @row_count = row_count.nil? ? 0 : row_count.to_i @date_start = parse_date(date_start) @date_end = parse_date(date_end) end |
Instance Attribute Details
#date_end ⇒ DateTime
When a date column is passed to Adapters::Adapter#stats it returns the date of the last record in the table
18 19 20 |
# File 'lib/dwh/table_stats.rb', line 18 def date_end @date_end end |
#date_start ⇒ DateTime
Returns when a date column is passed to Adapters::Adapter#stats it will return date of first record in the table.
14 15 16 |
# File 'lib/dwh/table_stats.rb', line 14 def date_start @date_start end |
#row_count ⇒ Integer
Returns total rows in table.
10 11 12 |
# File 'lib/dwh/table_stats.rb', line 10 def row_count @row_count end |
Instance Method Details
#to_h ⇒ Hash
Hash of the stats attributes
28 29 30 31 32 33 34 |
# File 'lib/dwh/table_stats.rb', line 28 def to_h { row_count: row_count, date_start: date_start, date_end: date_end } end |