| Create a namespace | CREATE NAMESPACE IF NOT EXISTS hms.db — required with HMS, implicit with type=hadoop |
| Create a table | CREATE TABLE hms.db.t (...) USING iceberg PARTITIONED BY (days(ts)) |
| Write rows | INSERT INTO hms.db.t VALUES (...) / INSERT INTO ... SELECT ... |
| Upsert | MERGE INTO hms.db.t t USING src s ON ... WHEN MATCHED ... WHEN NOT MATCHED ... |
| See commit history | SELECT * FROM hms.db.t.history |
| See every snapshot | SELECT * FROM hms.db.t.snapshots |
| See manifest files | SELECT * FROM hms.db.t.manifests |
| See data + delete files | SELECT * FROM hms.db.t.files — content: 0=data, 1=pos-delete, 2=eq-delete |
| See what a delete file actually deletes | SELECT file_path, pos FROM hms.db.t.position_deletes — one row per superseded row (see What is actually inside the delete file) |
| See partitions across specs | SELECT * FROM hms.db.t.partitions |
| Time travel by snapshot | SELECT * FROM hms.db.t VERSION AS OF <id> |
| Time travel by timestamp | SELECT * FROM hms.db.t TIMESTAMP AS OF '<ts>' |
| Roll back | CALL hms.system.rollback_to_snapshot('db.t', <id>) |
| Roll forward | CALL hms.system.set_current_snapshot('db.t', <id>) |
| Add/rename/widen/drop a column | ALTER TABLE hms.db.t ADD/RENAME/ALTER/DROP COLUMN ... |
| Change partitioning going forward | ALTER TABLE hms.db.t ADD/DROP PARTITION FIELD <transform>(col) |
| Stop a MERGE emitting small files | ALTER TABLE hms.db.t SET TBLPROPERTIES ('write.distribution-mode'='hash') (see Isn't three files a lot for two rows?) |
| Compact small files + resolve deletes | CALL hms.system.rewrite_data_files(table => 'db.t') |
| Compact manifests | CALL hms.system.rewrite_manifests('db.t') |
| Reclaim disk space | CALL hms.system.expire_snapshots(table => 'db.t', older_than => ..., retain_last => N) |
| Clean up abandoned files | CALL hms.system.remove_orphan_files(table => 'db.t') |
Find the live metadata.json | SELECT file FROM hms.db.t.metadata_log_entries ORDER BY timestamp DESC LIMIT 1 |
| See the pointer in Postgres | SELECT "PARAM_VALUE" FROM "TABLE_PARAMS" … WHERE "PARAM_KEY" = 'metadata_location' |
| Pin the session timezone | SET spark.sql.session.timeZone = 'UTC' — set it in cluster defaults, not per job (see The end-to-end contract: convert at the edges, never in the middle) |
| Get a wall-clock column, not an instant | declare it TIMESTAMP_NTZ — plain TIMESTAMP yields Iceberg timestamptz (see Read metadata.json straight, in Go, timestamptz does not store a timezone) |
| Swap lock for CAS | ALTER TABLE hms.db.t SET TBLPROPERTIES ('engine.hive.lock-enabled' = 'false') — HMS 4.0.0+ only |