Python API Quickstart #
Installation #
Iceberg python is currently in development, for development and testing purposes the best way to install the library is to perform the following steps:
git clone https://github.com/apache/iceberg.git
cd iceberg/python
pip install -e .
Testing #
Testing is done using tox. The config can be found in tox.ini
within the python directory of the iceberg project.
# simply run tox from within the python dir
tox
Examples #
Inspect Table Metadata #
from iceberg.hive import HiveTables
# instantiate Hive Tables
conf = {"hive.metastore.uris": 'thrift://{hms_host}:{hms_port}'}
tables = HiveTables(conf)
# load table
tbl = tables.load("iceberg_db.iceberg_test_table")
# inspect metadata
print(tbl.schema())
print(tbl.spec())
print(tbl.location())
# get table level record count
from pprint import pprint
pprint(int(tbl.current_snapshot().summary.get("total-records")))