When testing database operations that modify schema, data, or metadata, always add comprehensive assertions to verify the expected state changes. Database operations often have side effects beyond the primary action, and tests should validate both the intended outcome and related system state.
Key verification patterns:
SHOW CREATE TABLE
or similar introspection queriesExample from schema evolution test:
# After schema modification
instance.query(f"ALTER TABLE {TABLE_NAME} MODIFY COLUMN x Int64;")
# Verify the schema change took effect
result = instance.query(f"SHOW CREATE TABLE {TABLE_NAME}")
assert "Int64" in result
Example from drop operations:
# After dropping table/replica
drop_iceberg_table(instance, TABLE_NAME)
# Verify data still exists if that's the expected behavior
files = get_table_files(TABLE_NAME)
assert len(files) > 0, "Drop should not delete user data"
This approach catches subtle bugs where operations appear to succeed but don’t have the expected side effects, ensuring database tests provide comprehensive coverage of system behavior.
Enter the URL of a public GitHub repository