iceberg 0.10.1 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c46a82a7b9d4d9fff982a5b2f0c1f7afe35190be0ce6d10e10bb11aa640bffc
4
- data.tar.gz: 96d07d2411575116317865ad03bc7ed2ec46afbb578214959a275c16704f8d8f
3
+ metadata.gz: 7443be13c19060405062932a96a353db0d5fdff69ad5be7de60dcd3deae6a45d
4
+ data.tar.gz: 9376cc574876fd5f8c2c79ef9a068e7ad830487b55ccd8e2196e913ca2f8d913
5
5
  SHA512:
6
- metadata.gz: 6daf12d51dd4a08a16df8c8d69a4f9afff30d8dcf0285214d41427d025065e3c1b9be072d588dd1a5db310c9189c73fd37a7b0fbc698af36007585d5cfc847a2
7
- data.tar.gz: 12e6a28918d367c4fdeec801bd0c16b8dc2eb3c18b6c9411d6281dc01aa378411cea70168f927c6571075b09e79a0bec6d1012e816d6acea4e9b7e1ba8573e6b
6
+ metadata.gz: fae6a6a7bab2379d7fd21c927ae4f6e16031cac672affa5a672e89c18804b4589f5224ab1a8f4236a24617a7f613b061d526a82c856b2f84c3d360e57494af4d
7
+ data.tar.gz: 037dc08db1baff438de69bd3722277017bd8cdd3208ba0a2390e7f0f58df48866a61bcc1d98fabe6579261d429956367e75ed263b7faf3ed37bad1b3ea7ac99b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.10.2 (2025-08-28)
2
+
3
+ - Added precompiled gems
4
+
1
5
  ## 0.10.1 (2025-08-27)
2
6
 
3
7
  - Added `if_not_exists` option to `create_namespace` method
data/Cargo.lock CHANGED
@@ -2814,7 +2814,7 @@ dependencies = [
2814
2814
 
2815
2815
  [[package]]
2816
2816
  name = "iceberg"
2817
- version = "0.10.1"
2817
+ version = "0.10.2"
2818
2818
  dependencies = [
2819
2819
  "arrow-array",
2820
2820
  "arrow-schema",
data/README.md CHANGED
@@ -12,8 +12,6 @@ Add this line to your application’s Gemfile:
12
12
  gem "iceberg"
13
13
  ```
14
14
 
15
- It can take around 5 minutes to compile the gem.
16
-
17
15
  ## Getting Started
18
16
 
19
17
  Create a client for an Iceberg catalog
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "iceberg"
3
- version = "0.10.1"
3
+ version = "0.10.2"
4
4
  license = "Apache-2.0"
5
5
  authors = ["Andrew Kane <andrew@ankane.org>"]
6
6
  edition = "2024"
@@ -122,6 +122,7 @@ fn init(ruby: &Ruby) -> RbResult<()> {
122
122
 
123
123
  let class = module.define_class("RbTableScan", ruby.class_object())?;
124
124
  class.define_method("plan_files", method!(RbTableScan::plan_files, 0))?;
125
+ class.define_method("snapshot", method!(RbTableScan::snapshot, 0))?;
125
126
 
126
127
  Ok(())
127
128
  }
@@ -1,11 +1,12 @@
1
1
  use futures::TryStreamExt;
2
2
  use iceberg::scan::TableScan;
3
- use magnus::{RArray, Ruby};
3
+ use magnus::{RArray, Ruby, Value};
4
4
  use std::cell::RefCell;
5
5
 
6
6
  use crate::RbResult;
7
7
  use crate::error::to_rb_err;
8
8
  use crate::runtime::runtime;
9
+ use crate::utils::rb_snapshot;
9
10
 
10
11
  #[magnus::wrap(class = "Iceberg::RbTableScan")]
11
12
  pub struct RbTableScan {
@@ -44,4 +45,11 @@ impl RbTableScan {
44
45
  }
45
46
  Ok(files)
46
47
  }
48
+
49
+ pub fn snapshot(ruby: &Ruby, rb_self: &Self) -> RbResult<Option<Value>> {
50
+ match rb_self.scan.borrow().snapshot() {
51
+ Some(s) => Ok(Some(rb_snapshot(ruby, s)?)),
52
+ None => Ok(None),
53
+ }
54
+ }
47
55
  }
@@ -145,21 +145,21 @@ impl RbTable {
145
145
  pub fn schemas(ruby: &Ruby, rb_self: &Self) -> RbResult<RArray> {
146
146
  let schemas = ruby.ary_new();
147
147
  for s in rb_self.table.borrow().metadata().schemas_iter() {
148
- schemas.push(rb_schema(s)?)?;
148
+ schemas.push(rb_schema(ruby, s)?)?;
149
149
  }
150
150
  Ok(schemas)
151
151
  }
152
152
 
153
- pub fn schema_by_id(&self, schema_id: i32) -> RbResult<Option<Value>> {
154
- let schema = match self.table.borrow().metadata().schema_by_id(schema_id) {
155
- Some(s) => Some(rb_schema(s)?),
153
+ pub fn schema_by_id(ruby: &Ruby, rb_self: &Self, schema_id: i32) -> RbResult<Option<Value>> {
154
+ let schema = match rb_self.table.borrow().metadata().schema_by_id(schema_id) {
155
+ Some(s) => Some(rb_schema(ruby, s)?),
156
156
  None => None,
157
157
  };
158
158
  Ok(schema)
159
159
  }
160
160
 
161
- pub fn current_schema(&self) -> RbResult<Value> {
162
- rb_schema(self.table.borrow().metadata().current_schema())
161
+ pub fn current_schema(ruby: &Ruby, rb_self: &Self) -> RbResult<Value> {
162
+ rb_schema(ruby, rb_self.table.borrow().metadata().current_schema())
163
163
  }
164
164
 
165
165
  pub fn current_schema_id(&self) -> i32 {
@@ -198,14 +198,23 @@ impl RbTable {
198
198
  pub fn snapshots(ruby: &Ruby, rb_self: &Self) -> RbResult<RArray> {
199
199
  let snapshots = ruby.ary_new();
200
200
  for s in rb_self.table.borrow().metadata().snapshots() {
201
- snapshots.push(rb_snapshot(s)?)?;
201
+ snapshots.push(rb_snapshot(ruby, s)?)?;
202
202
  }
203
203
  Ok(snapshots)
204
204
  }
205
205
 
206
- pub fn snapshot_by_id(&self, snapshot_id: i64) -> RbResult<Option<Value>> {
207
- let snapshot = match self.table.borrow().metadata().snapshot_by_id(snapshot_id) {
208
- Some(s) => Some(rb_snapshot(s)?),
206
+ pub fn snapshot_by_id(
207
+ ruby: &Ruby,
208
+ rb_self: &Self,
209
+ snapshot_id: i64,
210
+ ) -> RbResult<Option<Value>> {
211
+ let snapshot = match rb_self
212
+ .table
213
+ .borrow()
214
+ .metadata()
215
+ .snapshot_by_id(snapshot_id)
216
+ {
217
+ Some(s) => Some(rb_snapshot(ruby, s)?),
209
218
  None => None,
210
219
  };
211
220
  Ok(snapshot)
@@ -236,9 +245,9 @@ impl RbTable {
236
245
  Ok(metadata_logs)
237
246
  }
238
247
 
239
- pub fn current_snapshot(&self) -> RbResult<Option<Value>> {
240
- let snapshot = match self.table.borrow().metadata().current_snapshot() {
241
- Some(s) => Some(rb_snapshot(s)?),
248
+ pub fn current_snapshot(ruby: &Ruby, rb_self: &Self) -> RbResult<Option<Value>> {
249
+ let snapshot = match rb_self.table.borrow().metadata().current_snapshot() {
250
+ Some(s) => Some(rb_snapshot(ruby, s)?),
242
251
  None => None,
243
252
  };
244
253
  Ok(snapshot)
@@ -248,9 +257,18 @@ impl RbTable {
248
257
  self.table.borrow().metadata().current_snapshot_id()
249
258
  }
250
259
 
251
- pub fn snapshot_for_ref(&self, ref_name: String) -> RbResult<Option<Value>> {
252
- let snapshot = match self.table.borrow().metadata().snapshot_for_ref(&ref_name) {
253
- Some(s) => Some(rb_snapshot(s)?),
260
+ pub fn snapshot_for_ref(
261
+ ruby: &Ruby,
262
+ rb_self: &Self,
263
+ ref_name: String,
264
+ ) -> RbResult<Option<Value>> {
265
+ let snapshot = match rb_self
266
+ .table
267
+ .borrow()
268
+ .metadata()
269
+ .snapshot_for_ref(&ref_name)
270
+ {
271
+ Some(s) => Some(rb_snapshot(ruby, s)?),
254
272
  None => None,
255
273
  };
256
274
  Ok(snapshot)
@@ -146,8 +146,7 @@ fn default_value(ob: Value, field_type: &Type) -> RbResult<Option<Literal>> {
146
146
  Ok(Some(lit))
147
147
  }
148
148
 
149
- pub fn rb_schema(schema: &Schema) -> RbResult<Value> {
150
- let ruby = Ruby::get().unwrap();
149
+ pub fn rb_schema(ruby: &Ruby, schema: &Schema) -> RbResult<Value> {
151
150
  let fields = ruby.ary_new();
152
151
  for f in schema.as_struct().fields() {
153
152
  let field = ruby.hash_new();
@@ -182,10 +181,10 @@ pub fn rb_schema(schema: &Schema) -> RbResult<Value> {
182
181
 
183
182
  field.aset(ruby.to_symbol("required"), f.required)?;
184
183
 
185
- let initial_default = f.initial_default.as_ref().map(rb_literal);
184
+ let initial_default = f.initial_default.as_ref().map(|v| rb_literal(ruby, v));
186
185
  field.aset(ruby.to_symbol("initial_default"), initial_default)?;
187
186
 
188
- let write_default = f.write_default.as_ref().map(rb_literal);
187
+ let write_default = f.write_default.as_ref().map(|v| rb_literal(ruby, v));
189
188
  field.aset(ruby.to_symbol("write_default"), write_default)?;
190
189
 
191
190
  field.aset(
@@ -205,8 +204,20 @@ pub fn rb_schema(schema: &Schema) -> RbResult<Value> {
205
204
  .funcall("new", (fields, kwargs!("schema_id" => schema_id)))
206
205
  }
207
206
 
208
- pub fn rb_snapshot(_snapshot: &Snapshot) -> RbResult<Value> {
209
- todo!();
207
+ pub fn rb_snapshot(ruby: &Ruby, snapshot: &Snapshot) -> RbResult<Value> {
208
+ let rb_snapshot = ruby.hash_new();
209
+ rb_snapshot.aset(ruby.to_symbol("snapshot_id"), snapshot.snapshot_id())?;
210
+ rb_snapshot.aset(
211
+ ruby.to_symbol("parent_snapshot_id"),
212
+ snapshot.parent_snapshot_id(),
213
+ )?;
214
+ rb_snapshot.aset(
215
+ ruby.to_symbol("sequence_number"),
216
+ snapshot.sequence_number(),
217
+ )?;
218
+ rb_snapshot.aset(ruby.to_symbol("manifest_list"), snapshot.manifest_list())?;
219
+ rb_snapshot.aset(ruby.to_symbol("schema_id"), snapshot.schema_id())?;
220
+ Ok(rb_snapshot.as_value())
210
221
  }
211
222
 
212
223
  pub fn rb_partition_spec(_partition_spec: &PartitionSpec) -> RbResult<Value> {
@@ -227,15 +238,14 @@ pub fn rb_partition_statistics_file(
227
238
  todo!();
228
239
  }
229
240
 
230
- pub fn rb_literal(literal: &Literal) -> Value {
231
- let ruby = Ruby::get().unwrap();
241
+ pub fn rb_literal(ruby: &Ruby, literal: &Literal) -> Value {
232
242
  match literal {
233
243
  Literal::Primitive(pl) => match pl {
234
- PrimitiveLiteral::Boolean(v) => v.into_value_with(&ruby),
235
- PrimitiveLiteral::Int(v) => v.into_value_with(&ruby),
236
- PrimitiveLiteral::Long(v) => v.into_value_with(&ruby),
237
- PrimitiveLiteral::Float(v) => v.into_value_with(&ruby),
238
- PrimitiveLiteral::Double(v) => v.into_value_with(&ruby),
244
+ PrimitiveLiteral::Boolean(v) => v.into_value_with(ruby),
245
+ PrimitiveLiteral::Int(v) => v.into_value_with(ruby),
246
+ PrimitiveLiteral::Long(v) => v.into_value_with(ruby),
247
+ PrimitiveLiteral::Float(v) => v.into_value_with(ruby),
248
+ PrimitiveLiteral::Double(v) => v.into_value_with(ruby),
239
249
  PrimitiveLiteral::String(v) => ruby.str_new(v).as_value(),
240
250
  PrimitiveLiteral::Binary(v) => ruby.str_from_slice(v).as_value(),
241
251
  _ => todo!(),
data/lib/iceberg/table.rb CHANGED
@@ -90,6 +90,7 @@ module Iceberg
90
90
  if files.empty?
91
91
  # TODO improve
92
92
  schema =
93
+ # TODO use schema from snapshot_id
93
94
  current_schema.fields.to_h do |field|
94
95
  dtype =
95
96
  case field[:type]
@@ -1,3 +1,3 @@
1
1
  module Iceberg
2
- VERSION = "0.10.1"
2
+ VERSION = "0.10.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iceberg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane