Class: DWH::TableStats

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_endDateTime

When a date column is passed to Adapters::Adapter#stats it returns the date of the last record in the table

Returns:

  • (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_startDateTime

Returns when a date column is passed to Adapters::Adapter#stats it will return date of first record in the table.

Returns:

  • (DateTime)

    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_countInteger

Returns total rows in table.

Returns:

  • (Integer)

    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_hHash

Hash of the stats attributes

Returns:

  • (Hash)

    of the 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