The order history becomes two tables in the booknest namespace, mirroring Analytical SQL and Data Warehouses's orders and order_items. Orders are partitioned with the months transform, giving 18 partitions without a partition column; order lines need no partitioning at this size.
-- BookNest's order tables in the lake catalog (Iceberg format version 2).
CREATE NAMESPACE IF NOT EXISTS booknest;
CREATE TABLE booknest.orders (
order_id BIGINT NOT NULL,
customer_id INT,
order_ts TIMESTAMP, -- Iceberg timestamptz, stored in UTC
channel STRING,
status STRING,
coupon STRING,
discount DECIMAL(9,2),
total DECIMAL(10,2))
USING iceberg
PARTITIONED BY (months(order_ts)) -- hidden partitioning: no extra column
TBLPROPERTIES ('write.delete.mode' = 'merge-on-read');
CREATE TABLE booknest.order_items (
order_id BIGINT NOT NULL,
line_no INT,
book_id INT,
qty INT,
unit_price DECIMAL(9,2))
USING iceberg;Spark 129 's TIMESTAMP maps to Iceberg 129 's timestamptz (UTC microseconds), and money stays DECIMAL. The helper demos/ch08/iceberg/run_sql.py runs such files statement by statement with lake.py.