-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e594d98
commit 8c9eeb2
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
This table was generated with the following code: | ||
|
||
```python | ||
import pyarrow as pa | ||
from pyiceberg.catalog import load_catalog | ||
from pyiceberg.schema import Schema | ||
from pyiceberg.types import NestedField, IntegerType, StringType | ||
catalog = load_catalog( | ||
"s3", | ||
**{ | ||
"type": "sql", | ||
"uri": "sqlite:///tests/data/iceberg/iceberg_catalog.db", | ||
"s3.endpoint": "http://localhost:9000", | ||
"s3.access-key-id": "minioadmin", | ||
"s3.secret-access-key": "minioadmin", | ||
"warehouse": "s3://seafowl-test-bucket/test-data/iceberg", | ||
}, | ||
) | ||
schema = Schema( | ||
NestedField(field_id=1, name='key', field_type=IntegerType(), required=False), | ||
NestedField(field_id=2, name='value', field_type=StringType(), required=False), | ||
) | ||
catalog.create_namespace_if_not_exists('default') | ||
iceberg_table = catalog.create_table_if_not_exists(identifier='default.iceberg_table_2', schema=schema) | ||
pa_table_data = pa.Table.from_pylist([ | ||
{'key': 1, 'value': 'one'}, | ||
{'key': 2, 'value': 'two'}, | ||
{'key': 3, 'value': 'three'}, | ||
{'key': 4, 'value': 'four'}, | ||
], schema=iceberg_table.schema().as_arrow()) | ||
iceberg_table.append(df=pa_table_data) | ||
``` |