Class: DeltaLake::TableAlterer

Inherits:
Object
  • Object
show all
Defined in:
lib/deltalake/table_alterer.rb

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ TableAlterer

Returns a new instance of TableAlterer.



3
4
5
# File 'lib/deltalake/table_alterer.rb', line 3

def initialize(table)
  @table = table
end

Instance Method Details

#add_columns(fields) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/deltalake/table_alterer.rb', line 20

def add_columns(fields)
  if fields.is_a?(DeltaLake::Field)
    fields = [fields]
  end

  @table._table.add_columns(
    fields
  )
end

#add_constraint(constraints) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/deltalake/table_alterer.rb', line 30

def add_constraint(constraints)
  if constraints.length > 1
    raise ArgumentError,
      "add_constraints is limited to a single constraint addition at once for now."
  end

  @table._table.add_constraints(
    constraints
  )
end

#add_feature(feature, allow_protocol_versions_increase: false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/deltalake/table_alterer.rb', line 7

def add_feature(
  feature,
  allow_protocol_versions_increase: false
)
  if !feature.is_a?(Array)
    feature = [feature]
  end
  @table._table.add_feature(
    feature,
    allow_protocol_versions_increase
  )
end

#drop_constraint(name, raise_if_not_exists: true) ⇒ Object



41
42
43
44
45
46
# File 'lib/deltalake/table_alterer.rb', line 41

def drop_constraint(name, raise_if_not_exists: true)
  @table._table.drop_constraints(
    name,
    raise_if_not_exists
  )
end

#set_table_properties(properties, raise_if_not_exists: true) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/deltalake/table_alterer.rb', line 48

def set_table_properties(
  properties,
  raise_if_not_exists: true
)
  @table._table.set_table_properties(
    properties,
    raise_if_not_exists
  )
end