Class: ActiveRecord::ConnectionAdapters::HiveColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/active_record/connection_adapters/hive_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, default, sql_type, partition) ⇒ HiveColumn

Returns a new instance of HiveColumn.



19
20
21
22
# File 'lib/active_record/connection_adapters/hive_adapter.rb', line 19

def initialize(name, default, sql_type, partition)
  super(name, default, sql_type)
  @partition = partition
end

Instance Method Details

#extract_default(default) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/active_record/connection_adapters/hive_adapter.rb', line 28

def extract_default(default)
  case [type, default]
  when [:date, 'current_date'] then return default
  when [:datetime, 'current_time'] then return default
  end
  super
end

#partition?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/active_record/connection_adapters/hive_adapter.rb', line 24

def partition?
  @partition
end

#realized_defaultObject



36
37
38
39
40
41
42
43
# File 'lib/active_record/connection_adapters/hive_adapter.rb', line 36

def realized_default
  # returns realized value of defaults
  case [type, default]
  when [:date, 'current_date'] then Date.today
  when [:datetime, 'current_time'] then DateTime.now
  else default
  end
end