Class: Iceberg::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/iceberg/table.rb

Direct Known Subclasses

StaticTable

Instance Method Summary collapse

Constructor Details

#initialize(table, catalog) ⇒ Table

Returns a new instance of Table.



3
4
5
6
# File 'lib/iceberg/table.rb', line 3

def initialize(table, catalog)
  @table = table
  @catalog = catalog
end

Instance Method Details

#append(df) ⇒ Object



161
162
163
164
165
166
# File 'lib/iceberg/table.rb', line 161

def append(df)
  check_catalog
  df = ArrowRecordBatch.new(df, schema.arrow_c_schema) if df.is_a?(Array)
  @table = @table.append(df.arrow_c_stream, @catalog)
  nil
end

#current_schemaObject Also known as: schema



53
54
55
# File 'lib/iceberg/table.rb', line 53

def current_schema
  .current_schema
end

#current_schema_idObject Also known as: schema_id



58
59
60
# File 'lib/iceberg/table.rb', line 58

def current_schema_id
  .current_schema_id
end

#current_snapshotObject



95
96
97
# File 'lib/iceberg/table.rb', line 95

def current_snapshot
  .current_snapshot
end

#current_snapshot_idObject



99
100
101
# File 'lib/iceberg/table.rb', line 99

def current_snapshot_id
  .current_snapshot_id
end

#default_partition_specObject



71
72
73
# File 'lib/iceberg/table.rb', line 71

def default_partition_spec
  .default_partition_spec
end

#default_partition_spec_idObject



75
76
77
# File 'lib/iceberg/table.rb', line 75

def default_partition_spec_id
  .default_partition_spec_id
end

#default_sort_orderObject



107
108
109
# File 'lib/iceberg/table.rb', line 107

def default_sort_order
  .default_sort_order
end

#default_sort_order_idObject



111
112
113
# File 'lib/iceberg/table.rb', line 111

def default_sort_order_id
  .default_sort_order_id
end

#encryption_keysObject



135
136
137
# File 'lib/iceberg/table.rb', line 135

def encryption_keys
  .encryption_keys
end

#format_versionObject



12
13
14
# File 'lib/iceberg/table.rb', line 12

def format_version
  .format_version
end

#historyObject



87
88
89
# File 'lib/iceberg/table.rb', line 87

def history
  .history
end

#inspectObject

hide internal state



169
170
171
# File 'lib/iceberg/table.rb', line 169

def inspect
  to_s
end

#last_column_idObject



32
33
34
# File 'lib/iceberg/table.rb', line 32

def last_column_id
  .last_column_id
end

#last_partition_idObject



36
37
38
# File 'lib/iceberg/table.rb', line 36

def last_partition_id
  .last_partition_id
end

#last_sequence_numberObject



24
25
26
# File 'lib/iceberg/table.rb', line 24

def last_sequence_number
  .last_sequence_number
end

#last_updated_atObject



40
41
42
43
# File 'lib/iceberg/table.rb', line 40

def last_updated_at
  ms = .last_updated_ms
  Time.at(ms / 1000, ms % 1000, :millisecond)
end

#locationObject



20
21
22
# File 'lib/iceberg/table.rb', line 20

def location
  .location
end

#metadata_logObject



91
92
93
# File 'lib/iceberg/table.rb', line 91

def 
  .
end

#next_row_idObject



139
140
141
# File 'lib/iceberg/table.rb', line 139

def next_row_id
  .next_row_id
end

#next_sequence_numberObject



28
29
30
# File 'lib/iceberg/table.rb', line 28

def next_sequence_number
  .next_sequence_number
end

#partition_spec_by_id(partition_spec_id) ⇒ Object



67
68
69
# File 'lib/iceberg/table.rb', line 67

def partition_spec_by_id(partition_spec_id)
  .partition_spec_by_id(partition_spec_id)
end

#partition_specsObject



63
64
65
# File 'lib/iceberg/table.rb', line 63

def partition_specs
  .partition_specs
end

#partition_statisticsObject



123
124
125
# File 'lib/iceberg/table.rb', line 123

def partition_statistics
  .partition_statistics
end

#partition_statistics_for_snapshot(snapshot_id) ⇒ Object



131
132
133
# File 'lib/iceberg/table.rb', line 131

def partition_statistics_for_snapshot(snapshot_id)
  .partition_statistics_for_snapshot(snapshot_id)
end

#propertiesObject



115
116
117
# File 'lib/iceberg/table.rb', line 115

def properties
  .properties
end

#refreshObject



8
9
10
# File 'lib/iceberg/table.rb', line 8

def refresh
  @table = @catalog.load_table(@table.identifier)
end

#scan(snapshot_id: nil) ⇒ Object



143
144
145
# File 'lib/iceberg/table.rb', line 143

def scan(snapshot_id: nil)
  TableScan.new(@table.scan(snapshot_id), self)
end

#schema_by_id(schema_id) ⇒ Object



49
50
51
# File 'lib/iceberg/table.rb', line 49

def schema_by_id(schema_id)
  .schema_by_id(schema_id)
end

#schemasObject



45
46
47
# File 'lib/iceberg/table.rb', line 45

def schemas
  .schemas
end

#snapshot_by_id(snapshot_id) ⇒ Object



83
84
85
# File 'lib/iceberg/table.rb', line 83

def snapshot_by_id(snapshot_id)
  .snapshot_by_id(snapshot_id)
end

#snapshotsObject



79
80
81
# File 'lib/iceberg/table.rb', line 79

def snapshots
  .snapshots
end

#sort_ordersObject



103
104
105
# File 'lib/iceberg/table.rb', line 103

def sort_orders
  .sort_orders
end

#statisticsObject



119
120
121
# File 'lib/iceberg/table.rb', line 119

def statistics
  .statistics
end

#statistics_for_snapshot(snapshot_id) ⇒ Object



127
128
129
# File 'lib/iceberg/table.rb', line 127

def statistics_for_snapshot(snapshot_id)
  .statistics_for_snapshot(snapshot_id)
end

#to_a(snapshot_id: nil) ⇒ Object



147
148
149
# File 'lib/iceberg/table.rb', line 147

def to_a(snapshot_id: nil)
  scan(snapshot_id: snapshot_id).to_a
end

#to_polars(snapshot_id: nil, storage_options: nil) ⇒ Object



151
152
153
154
155
156
157
158
159
# File 'lib/iceberg/table.rb', line 151

def to_polars(snapshot_id: nil, storage_options: nil)
  require "polars-df"

  if Gem::Version.new(Polars::VERSION) < Gem::Version.new("0.26.1")
    raise "Requires polars-df >= 0.26.1"
  end

  Polars.scan_iceberg(self, snapshot_id:, storage_options:)
end

#uuidObject



16
17
18
# File 'lib/iceberg/table.rb', line 16

def uuid
  .uuid
end