iceberg 0.7.0 → 0.10.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 452b2f477561e9894d22491c7bfe1b3c190bd274b8917a600dfc23a10a43c4ec
4
+ data.tar.gz: 2bf0605e64ba9b669f773c27890658b752cfeb34f760ad938d82649e8f876fd8
5
+ SHA512:
6
+ metadata.gz: a24216c94e5d499992bd631555cf2ef9608ae88717105d4414daedea914432636f9fa8b5989ec58fb3ba3abad67203190dfc51cea06c6b5d8412a87c8e80af60
7
+ data.tar.gz: 66400c803eec1455dfc210e0918272da0688ab6a4638fdcd0b94dea1436978cf556f04c5ac4cb585c4dfceaad203a16b8f73066f99111a8c13db8b0657bab9c5
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.10.0 (2025-08-27)
2
+
3
+ - First release
data/LICENSE.txt CHANGED
@@ -1,20 +1,202 @@
1
- Copyright (c) 2011 stellard
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/NOTICE.txt ADDED
@@ -0,0 +1,14 @@
1
+
2
+ Apache Iceberg
3
+ Copyright 2017-2025 The Apache Software Foundation
4
+
5
+ This product includes software developed at
6
+ The Apache Software Foundation (http://www.apache.org/).
7
+
8
+ --------------------------------------------------------------------------------
9
+
10
+ Apache Iceberg Rust
11
+ Copyright 2023-2024 The Apache Software Foundation
12
+
13
+ This product includes software developed at
14
+ The Apache Software Foundation (http://www.apache.org/).
data/README.md ADDED
@@ -0,0 +1,211 @@
1
+ # Iceberg Ruby
2
+
3
+ [Apache Iceberg](https://iceberg.apache.org/) for Ruby
4
+
5
+ [![Build Status](https://github.com/ankane/iceberg-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/iceberg-ruby/actions)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application’s Gemfile:
10
+
11
+ ```ruby
12
+ gem "iceberg"
13
+ ```
14
+
15
+ ## Getting Started
16
+
17
+ Create a client for an Iceberg catalog
18
+
19
+ ```ruby
20
+ catalog = Iceberg::RestCatalog.new(uri: "http://localhost:8181")
21
+ ```
22
+
23
+ Create a namespace
24
+
25
+ ```ruby
26
+ catalog.create_namespace("main")
27
+ ```
28
+
29
+ Create a table
30
+
31
+ ```ruby
32
+ catalog.create_table("main.events") do |t|
33
+ t.bigint "id"
34
+ t.float "value"
35
+ end
36
+ ```
37
+
38
+ Or
39
+
40
+ ```ruby
41
+ df = Polars::DataFrame.new({"id" => [1, 2], "value" => [3.0, 4.0]})
42
+ table = catalog.create_table("main.events", schema: df.schema)
43
+ table.append(df)
44
+ ```
45
+
46
+ Load a table
47
+
48
+ ```ruby
49
+ table = catalog.load_table("main.events")
50
+ ```
51
+
52
+ Query a table
53
+
54
+ ```ruby
55
+ table.to_polars.collect
56
+ ```
57
+
58
+ ## Catalog Types
59
+
60
+ ### REST
61
+
62
+ ```ruby
63
+ Iceberg::RestCatalog.new(
64
+ uri: "http://localhost:8181"
65
+ )
66
+ ```
67
+
68
+ ### SQL
69
+
70
+ ```ruby
71
+ Iceberg::SqlCatalog.new(
72
+ uri: "postgres://localhost:5432/iceberg",
73
+ warehouse: "s3://my-bucket"
74
+ )
75
+ ```
76
+
77
+ ### Memory
78
+
79
+ ```ruby
80
+ Iceberg::MemoryCatalog.new(
81
+ warehouse: "/tmp/warehouse"
82
+ )
83
+ ```
84
+
85
+ ## Reference
86
+
87
+ ### Namespaces
88
+
89
+ List namespaces
90
+
91
+ ```ruby
92
+ catalog.list_namespaces
93
+ ```
94
+
95
+ Create a namespace
96
+
97
+ ```ruby
98
+ catalog.create_namespace("main")
99
+ ```
100
+
101
+ Check if a namespace exists
102
+
103
+ ```ruby
104
+ catalog.namespace_exists?("main")
105
+ ```
106
+
107
+ Get the properties of a namespace
108
+
109
+ ```ruby
110
+ catalog.namespace_properties("main")
111
+ ```
112
+
113
+ Update a namespace
114
+
115
+ ```ruby
116
+ catalog.update_namespace("main", properties: {})
117
+ ```
118
+
119
+ Drop a namespace
120
+
121
+ ```ruby
122
+ catalog.drop_namespace("main")
123
+ ```
124
+
125
+ ### Tables
126
+
127
+ List tables
128
+
129
+ ```ruby
130
+ catalog.list_tables("main")
131
+ ```
132
+
133
+ Create a table
134
+
135
+ ```ruby
136
+ catalog.create_table("main.events") do |t|
137
+ t.integer "id"
138
+ t.float "value"
139
+ end
140
+ ```
141
+
142
+ Load a table
143
+
144
+ ```ruby
145
+ catalog.load_table("main.events")
146
+ ```
147
+
148
+ Check if a table exists
149
+
150
+ ```ruby
151
+ catalog.table_exists?("main.events")
152
+ ```
153
+
154
+ Rename a table
155
+
156
+ ```ruby
157
+ catalog.rename_table("main.events", "main.events2")
158
+ ```
159
+
160
+ Register a table
161
+
162
+ ```ruby
163
+ catalog.register_table("main.events", "metadata.json")
164
+ ```
165
+
166
+ Drop a table
167
+
168
+ ```ruby
169
+ catalog.drop_table("main.events")
170
+ ```
171
+
172
+ ### Static Tables
173
+
174
+ Load a static table
175
+
176
+ ```ruby
177
+ Iceberg::StaticTable.new("metadata.json")
178
+ ```
179
+
180
+ ## History
181
+
182
+ View the [changelog](https://github.com/ankane/iceberg-ruby/blob/master/CHANGELOG.md)
183
+
184
+ ## Contributing
185
+
186
+ Everyone is encouraged to help improve this project. Here are a few ways you can help:
187
+
188
+ - [Report bugs](https://github.com/ankane/iceberg-ruby/issues)
189
+ - Fix bugs and [submit pull requests](https://github.com/ankane/iceberg-ruby/pulls)
190
+ - Write, clarify, or fix documentation
191
+ - Suggest or add new features
192
+
193
+ To get started with development:
194
+
195
+ ```sh
196
+ git clone https://github.com/ankane/iceberg-ruby.git
197
+ cd iceberg-ruby
198
+ bundle install
199
+ bundle exec rake compile
200
+
201
+ # memory catalog
202
+ bundle exec rake test:memory
203
+
204
+ # REST catalog
205
+ docker run -p 8181:8181 apache/iceberg-rest-fixture
206
+ bundle exec rake test:rest
207
+
208
+ # SQL catalog
209
+ createdb iceberg_ruby_test
210
+ bundle exec rake test:sql
211
+ ```
@@ -0,0 +1,4 @@
1
+ require "mkmf"
2
+ require "rb_sys/mkmf"
3
+
4
+ create_rust_makefile("iceberg/iceberg")
@@ -0,0 +1,102 @@
1
+ module Iceberg
2
+ class Catalog
3
+ def list_namespaces(parent = nil)
4
+ @catalog.list_namespaces(parent)
5
+ end
6
+
7
+ def create_namespace(namespace, properties: {})
8
+ @catalog.create_namespace(namespace, properties)
9
+ end
10
+
11
+ def namespace_exists?(namespace)
12
+ @catalog.namespace_exists?(namespace)
13
+ end
14
+
15
+ def namespace_properties(namespace)
16
+ @catalog.namespace_properties(namespace)
17
+ end
18
+
19
+ def update_namespace(namespace, properties:)
20
+ @catalog.update_namespace(namespace, properties)
21
+ end
22
+
23
+ def drop_namespace(namespace, if_exists: nil)
24
+ @catalog.drop_namespace(namespace)
25
+ rescue Error => e
26
+ if !if_exists || (e.message != "Tried to drop a namespace that does not exist" && !e.message.include?("No such namespace"))
27
+ raise e
28
+ end
29
+ nil
30
+ end
31
+
32
+ def list_tables(namespace)
33
+ @catalog.list_tables(namespace)
34
+ end
35
+
36
+ def create_table(table_name, schema: nil, location: nil)
37
+ if !schema.nil? && block_given?
38
+ raise ArgumentError, "Must pass schema or block"
39
+ end
40
+
41
+ if block_given?
42
+ table_definition = TableDefinition.new
43
+ yield table_definition
44
+ schema = Schema.new(table_definition.fields)
45
+ elsif schema.is_a?(Hash)
46
+ fields =
47
+ schema.map.with_index do |(k, v), i|
48
+ {
49
+ id: i + 1,
50
+ name: k.is_a?(Symbol) ? k.to_s : k,
51
+ type: v,
52
+ required: false
53
+ }
54
+ end
55
+ schema = Schema.new(fields)
56
+ elsif schema.nil?
57
+ schema = Schema.new([])
58
+ end
59
+
60
+ Table.new(@catalog.create_table(table_name, schema, location), @catalog)
61
+ end
62
+
63
+ def load_table(table_name)
64
+ Table.new(@catalog.load_table(table_name), @catalog)
65
+ end
66
+
67
+ def drop_table(table_name, if_exists: nil)
68
+ @catalog.drop_table(table_name)
69
+ rescue Error => e
70
+ if !if_exists || (e.message != "Tried to drop a table that does not exist" && !e.message.include?("No such table"))
71
+ raise e
72
+ end
73
+ nil
74
+ end
75
+
76
+ def table_exists?(table_name)
77
+ @catalog.table_exists?(table_name)
78
+ rescue NamespaceNotFoundError
79
+ false
80
+ end
81
+
82
+ def rename_table(table_name, new_name)
83
+ @catalog.rename_table(table_name, new_name)
84
+ end
85
+
86
+ def register_table(table_name, metadata_location)
87
+ @catalog.register_table(table_name, metadata_location)
88
+ end
89
+
90
+ def query(sql)
91
+ # requires datafusion feature
92
+ raise Todo unless @catalog.respond_to?(:query)
93
+
94
+ @catalog.query(sql)
95
+ end
96
+
97
+ # hide internal state
98
+ def inspect
99
+ to_s
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,11 @@
1
+ module Iceberg
2
+ class GlueCatalog < Catalog
3
+ # warehouse is URI of S3 storage bucket
4
+ def initialize(warehouse:)
5
+ # requires glue feature
6
+ raise Error, "Feature not enabled" unless RbCatalog.respond_to?(:new_glue)
7
+
8
+ @catalog = RbCatalog.new_glue(warehouse)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ module Iceberg
2
+ class MemoryCatalog < Catalog
3
+ # warehouse is default storage location
4
+ def initialize(warehouse: nil)
5
+ @catalog = RbCatalog.new_memory(warehouse)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Iceberg
2
+ class RestCatalog < Catalog
3
+ # warehouse is passed to REST server
4
+ def initialize(uri:, warehouse: nil, properties: {})
5
+ @catalog = RbCatalog.new_rest(uri, warehouse, properties)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module Iceberg
2
+ class Schema
3
+ attr_reader :fields, :schema_id
4
+
5
+ def initialize(fields, schema_id: nil)
6
+ @fields = fields
7
+ @schema_id = schema_id
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module Iceberg
2
+ class SqlCatalog < Catalog
3
+ # warehouse is default storage location
4
+ # name is stored in SQL table
5
+ def initialize(uri:, warehouse:, name: "main", properties: {})
6
+ @catalog = RbCatalog.new_sql(uri, warehouse, name, properties)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module Iceberg
2
+ class StaticTable < Table
3
+ def initialize(metadata_location)
4
+ table = RbTable.from_metadata_file(metadata_location)
5
+ super(table, nil)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,150 @@
1
+ module Iceberg
2
+ class Table
3
+ def initialize(table, catalog)
4
+ @table = table
5
+ @catalog = catalog
6
+ end
7
+
8
+ def format_version
9
+ @table.format_version
10
+ end
11
+
12
+ def uuid
13
+ @table.uuid
14
+ end
15
+
16
+ def location
17
+ @table.location
18
+ end
19
+
20
+ def last_sequence_number
21
+ @table.last_sequence_number
22
+ end
23
+
24
+ def next_sequence_number
25
+ @table.next_sequence_number
26
+ end
27
+
28
+ def last_column_id
29
+ @table.last_column_id
30
+ end
31
+
32
+ def last_partition_id
33
+ @table.last_partition_id
34
+ end
35
+
36
+ def schemas
37
+ @table.schemas
38
+ end
39
+
40
+ def schema_by_id(schema_id)
41
+ @table.schema_by_id(schema_id)
42
+ end
43
+
44
+ def current_schema
45
+ @table.current_schema
46
+ end
47
+ alias_method :schema, :current_schema
48
+
49
+ def current_schema_id
50
+ @table.current_schema_id
51
+ end
52
+ alias_method :schema_id, :current_schema_id
53
+
54
+ def default_partition_spec_id
55
+ @table.default_partition_spec_id
56
+ end
57
+
58
+ def snapshots
59
+ @table.snapshots
60
+ end
61
+
62
+ def snapshot_by_id(snapshot_id)
63
+ @table.snapshot_by_id(snapshot_id)
64
+ end
65
+
66
+ def history
67
+ @table.history
68
+ end
69
+
70
+ def metadata_log
71
+ @table.metadata_log
72
+ end
73
+
74
+ def current_snapshot
75
+ @table.current_snapshot
76
+ end
77
+
78
+ def current_snapshot_id
79
+ @table.current_snapshot_id
80
+ end
81
+
82
+ def properties
83
+ @table.properties
84
+ end
85
+
86
+ def to_polars
87
+ require "polars-df"
88
+
89
+ files = @table.plan_files
90
+ if files.empty?
91
+ schema =
92
+ current_schema.fields.to_h do |field|
93
+ dtype =
94
+ case field[:type]
95
+ when "int"
96
+ Polars::Int32
97
+ when "long"
98
+ Polars::Int64
99
+ when "double"
100
+ Polars::Float64
101
+ when "string"
102
+ Polars::String
103
+ when "timestamp"
104
+ Polars::Datetime
105
+ else
106
+ raise Todo
107
+ end
108
+
109
+ [field[:name], dtype]
110
+ end
111
+
112
+ Polars::LazyFrame.new(schema: schema)
113
+ else
114
+ sources = files.map { |v| v[:data_file_path] }
115
+
116
+ deletion_files = [
117
+ "iceberg-position-delete",
118
+ files.map.with_index
119
+ .select { |v, i| v[:deletes].any? }
120
+ .to_h { |v, i| [i, v[:deletes].map { |d| d[:file_path] }] }
121
+ ]
122
+
123
+ Polars.scan_parquet(
124
+ sources,
125
+ # TODO storage options
126
+ # TODO cast_options
127
+ # TODO allow_missing_columns, extra_columns, _column_mapping
128
+ _deletion_files: deletion_files
129
+ )
130
+ end
131
+ end
132
+
133
+ def append(df)
134
+ check_catalog
135
+
136
+ @table = @table.append(df.arrow_c_stream, @catalog)
137
+ end
138
+
139
+ # hide internal state
140
+ def inspect
141
+ to_s
142
+ end
143
+
144
+ private
145
+
146
+ def check_catalog
147
+ raise Error, "Read-only table" if @catalog.nil?
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,37 @@
1
+ module Iceberg
2
+ class TableDefinition
3
+ TYPES = %w[
4
+ boolean int long float double date timestamp timestamptz string uuid binary
5
+ ]
6
+
7
+ TYPE_ALIASES = {
8
+ "integer" => "int",
9
+ "bigint" => "long"
10
+ }
11
+
12
+ attr_reader :fields
13
+
14
+ def initialize
15
+ @fields = []
16
+ end
17
+
18
+ (TYPES + TYPE_ALIASES.keys).each do |type|
19
+ define_method type do |name, **options|
20
+ column(name, type, **options)
21
+ end
22
+ end
23
+
24
+ def column(name, type, null: true, default: nil, comment: nil)
25
+ type = type.to_s
26
+ @fields << {
27
+ id: @fields.size + 1,
28
+ name: name.to_s,
29
+ type: TYPE_ALIASES.fetch(type, type),
30
+ required: !null,
31
+ doc: comment,
32
+ # no need for initial default (and not supported until v3)
33
+ write_default: default
34
+ }
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module Iceberg
2
+ VERSION = "0.10.0"
3
+ end
data/lib/iceberg.rb CHANGED
@@ -0,0 +1,36 @@
1
+ # ext
2
+ begin
3
+ require "iceberg/#{RUBY_VERSION.to_f}/iceberg"
4
+ rescue LoadError
5
+ require "iceberg/iceberg"
6
+ end
7
+
8
+ # modules
9
+ require_relative "iceberg/catalog"
10
+ require_relative "iceberg/schema"
11
+ require_relative "iceberg/table"
12
+ require_relative "iceberg/static_table"
13
+ require_relative "iceberg/table_definition"
14
+ require_relative "iceberg/version"
15
+
16
+ # catalogs
17
+ require_relative "iceberg/glue_catalog"
18
+ require_relative "iceberg/memory_catalog"
19
+ require_relative "iceberg/rest_catalog"
20
+ require_relative "iceberg/sql_catalog"
21
+
22
+ module Iceberg
23
+ class Error < StandardError; end
24
+ class InvalidDataError < Error; end
25
+ class NamespaceAlreadyExistsError < Error; end
26
+ class NamespaceNotFoundError < Error; end
27
+ class TableAlreadyExistsError < Error; end
28
+ class TableNotFoundError < Error; end
29
+ class UnsupportedFeatureError < Error; end
30
+
31
+ class Todo < Error
32
+ def message
33
+ "not implemented yet"
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,136 +1,69 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: iceberg
3
- version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 0
10
- version: 0.7.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.0
11
5
  platform: ruby
12
- authors:
13
- - stellard
14
- autorequire:
6
+ authors:
7
+ - Andrew Kane
15
8
  bindir: bin
16
9
  cert_chain: []
17
-
18
- date: 2011-08-03 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
22
- none: false
23
- requirements:
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rb_sys
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
24
16
  - - ">="
25
- - !ruby/object:Gem::Version
26
- hash: 3
27
- segments:
28
- - 0
29
- version: "0"
30
- version_requirements: *id001
31
- type: :development
32
- name: shoulda
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
33
20
  prerelease: false
34
- - !ruby/object:Gem::Dependency
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- none: false
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- hash: 23
41
- segments:
42
- - 1
43
- - 0
44
- - 0
45
- version: 1.0.0
46
- version_requirements: *id002
47
- type: :development
48
- name: bundler
49
- prerelease: false
50
- - !ruby/object:Gem::Dependency
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- hash: 7
57
- segments:
58
- - 1
59
- - 5
60
- - 2
61
- version: 1.5.2
62
- version_requirements: *id003
63
- type: :development
64
- name: jeweler
65
- prerelease: false
66
- - !ruby/object:Gem::Dependency
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
70
23
  - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- version_requirements: *id004
77
- type: :development
78
- name: rcov
79
- prerelease: false
80
- description: just a placeholder for now until public release
81
- email: scott.ellard@gmail.com
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ email: andrew@ankane.org
82
27
  executables: []
83
-
84
- extensions: []
85
-
86
- extra_rdoc_files:
87
- - LICENSE.txt
88
- - README.rdoc
89
- files:
90
- - .document
91
- - Gemfile
92
- - Gemfile.lock
28
+ extensions:
29
+ - ext/iceberg/extconf.rb
30
+ extra_rdoc_files: []
31
+ files:
32
+ - CHANGELOG.md
93
33
  - LICENSE.txt
94
- - README.rdoc
95
- - Rakefile
96
- - VERSION
97
- - iceberg.gemspec
34
+ - NOTICE.txt
35
+ - README.md
36
+ - ext/iceberg/extconf.rb
98
37
  - lib/iceberg.rb
99
- - test/helper.rb
100
- - test/test_iceberg.rb
101
- homepage: http://github.com/stellard/iceberg
102
- licenses:
103
- - MIT
104
- post_install_message:
38
+ - lib/iceberg/catalog.rb
39
+ - lib/iceberg/glue_catalog.rb
40
+ - lib/iceberg/memory_catalog.rb
41
+ - lib/iceberg/rest_catalog.rb
42
+ - lib/iceberg/schema.rb
43
+ - lib/iceberg/sql_catalog.rb
44
+ - lib/iceberg/static_table.rb
45
+ - lib/iceberg/table.rb
46
+ - lib/iceberg/table_definition.rb
47
+ - lib/iceberg/version.rb
48
+ homepage: https://github.com/ankane/iceberg-ruby
49
+ licenses:
50
+ - Apache-2.0
51
+ metadata: {}
105
52
  rdoc_options: []
106
-
107
- require_paths:
53
+ require_paths:
108
54
  - lib
109
- required_ruby_version: !ruby/object:Gem::Requirement
110
- none: false
111
- requirements:
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
112
57
  - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
116
- - 0
117
- version: "0"
118
- required_rubygems_version: !ruby/object:Gem::Requirement
119
- none: false
120
- requirements:
58
+ - !ruby/object:Gem::Version
59
+ version: '3.2'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
121
62
  - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 3
124
- segments:
125
- - 0
126
- version: "0"
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
127
65
  requirements: []
128
-
129
- rubyforge_project:
130
- rubygems_version: 1.8.5
131
- signing_key:
132
- specification_version: 3
133
- summary: just a placeholder for now until public release
134
- test_files:
135
- - test/helper.rb
136
- - test/test_iceberg.rb
66
+ rubygems_version: 3.6.9
67
+ specification_version: 4
68
+ summary: Apache Iceberg for Ruby
69
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
-
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem "shoulda", ">= 0"
10
- gem "bundler", "~> 1.0.0"
11
- gem "jeweler", "~> 1.5.2"
12
- gem "rcov", ">= 0"
13
- end
data/Gemfile.lock DELETED
@@ -1,20 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- git (1.2.5)
5
- jeweler (1.5.2)
6
- bundler (~> 1.0.0)
7
- git (>= 1.2.5)
8
- rake
9
- rake (0.9.2)
10
- rcov (0.9.9)
11
- shoulda (2.11.3)
12
-
13
- PLATFORMS
14
- ruby
15
-
16
- DEPENDENCIES
17
- bundler (~> 1.0.0)
18
- jeweler (~> 1.5.2)
19
- rcov
20
- shoulda
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = iceberg
2
-
3
- Description goes here.
4
-
5
- == Contributing to iceberg
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2011 stellard. See LICENSE.txt for
18
- further details.
19
-
data/Rakefile DELETED
@@ -1,53 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
11
-
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
- gem.name = "iceberg"
16
- gem.homepage = "http://github.com/stellard/iceberg"
17
- gem.license = "MIT"
18
- gem.summary = %Q{just a placeholder for now until public release}
19
- gem.description = %Q{just a placeholder for now until public release}
20
- gem.email = "scott.ellard@gmail.com"
21
- gem.authors = ["stellard"]
22
- # Include your dependencies below. Runtime dependencies are required when using your gem,
23
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
- # gem.add_development_dependency 'rspec', '> 1.2.3'
26
- end
27
- Jeweler::RubygemsDotOrgTasks.new
28
-
29
- require 'rake/testtask'
30
- Rake::TestTask.new(:test) do |test|
31
- test.libs << 'lib' << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
34
- end
35
-
36
- require 'rcov/rcovtask'
37
- Rcov::RcovTask.new do |test|
38
- test.libs << 'test'
39
- test.pattern = 'test/**/test_*.rb'
40
- test.verbose = true
41
- end
42
-
43
- task :default => :test
44
-
45
- require 'rake/rdoctask'
46
- Rake::RDocTask.new do |rdoc|
47
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
-
49
- rdoc.rdoc_dir = 'rdoc'
50
- rdoc.title = "iceberg #{version}"
51
- rdoc.rdoc_files.include('README*')
52
- rdoc.rdoc_files.include('lib/**/*.rb')
53
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.7.0
data/iceberg.gemspec DELETED
@@ -1,63 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{iceberg}
8
- s.version = "0.7.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{stellard}]
12
- s.date = %q{2011-08-03}
13
- s.description = %q{just a placeholder for now until public release}
14
- s.email = %q{scott.ellard@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE.txt",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "iceberg.gemspec",
28
- "lib/iceberg.rb",
29
- "test/helper.rb",
30
- "test/test_iceberg.rb"
31
- ]
32
- s.homepage = %q{http://github.com/stellard/iceberg}
33
- s.licenses = [%q{MIT}]
34
- s.require_paths = [%q{lib}]
35
- s.rubygems_version = %q{1.8.5}
36
- s.summary = %q{just a placeholder for now until public release}
37
- s.test_files = [
38
- "test/helper.rb",
39
- "test/test_iceberg.rb"
40
- ]
41
-
42
- if s.respond_to? :specification_version then
43
- s.specification_version = 3
44
-
45
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
- s.add_development_dependency(%q<shoulda>, [">= 0"])
47
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
48
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
49
- s.add_development_dependency(%q<rcov>, [">= 0"])
50
- else
51
- s.add_dependency(%q<shoulda>, [">= 0"])
52
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
53
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
54
- s.add_dependency(%q<rcov>, [">= 0"])
55
- end
56
- else
57
- s.add_dependency(%q<shoulda>, [">= 0"])
58
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
60
- s.add_dependency(%q<rcov>, [">= 0"])
61
- end
62
- end
63
-
data/test/helper.rb DELETED
@@ -1,18 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'test/unit'
11
- require 'shoulda'
12
-
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
15
- require 'iceberg'
16
-
17
- class Test::Unit::TestCase
18
- end
data/test/test_iceberg.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestIceberg < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end