"In IAM authentication, instead of using a password to authenticate against the [service], you create an authentication token that you include with your ... request. These tokens can be generated outside the [service] using AWS Signature Version 4(SigV4) and can be used in place of regular authentication." [1]
Monday, January 12, 2026
The Federation: AWS Glue
Thursday, October 23, 2025
Exactly Once Semantics in Iceberg/Kafka
Wednesday, September 17, 2025
Configuring Polaris for Azure
- tenantId. You can find this by running az account show --query tenantId.
- multiTenantAppName. This is the Application (client) ID that was generated when the app was created. You can see it in Microsoft Entra ID -> App Registrations -> All Applications in the Azure portal or using the CLI: az ad app list, find your app with the name you created above and use its appId.
- consentUrl. I'm not entirely sure what this is but can be generated with APPID=$(az ad app list --display-name "MyMultiTenantApp" --query "[0].appId" -o tsv) && echo "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=$APPID&response_type=code&redirect_uri=http://localhost:3000/redirect&response_mode=query&scope=https://graph.microsoft.com/.default&state=12345"
Sunday, August 3, 2025
Iceberg Distributions
| write.distribution-mode | Number of files | Notes |
| "hash" | p | df.writeTo(tableName).append() |
| "hash", sorted DataFrame | p | ...TBLPROPERTIES ('sort-order' = 'partitionField ASC NULLS FIRST'... |
| "hash", sorted table | p | df.sort("partitionField").writeTo(tableName).append() |
| "hash", sorted table but only one value for partitionField | 1 | because p=1; assumes the size of the data to write is < write.spark.advisory-partition-size-bytes. Otherwise multiple files are written (Spark 3.5). |
| "none" | d * p | df.writeTo(tableName).append() |
| "none", sorted DataFrame | p | df.sort("partitionField").writeTo(tableName).append() |
| "none", sorted table | d * p | ...TBLPROPERTIES ('sort-order' = 'partitionField ASC NULLS FIRST'... |
| "none", sorted table but only one value for partitionField | d | because p=1 |
"Fanout writer is better in all cases. We were silly. The memory requirements were tiny IMHO. Without fanout, you need to presort within the task but that ends up being way more expensive (and memory intesive) IMHO. In the latest versions @Anton Okolnychyi removed the local sort requirements if fanout is enabled, so I would recommend fanout always be enabled and especially if you are using distribution mode is none."
Saturday, May 31, 2025
Iceberg and Kafka Connect
"A task is a thread that performs the actual sourcing or sinking of data.
The number of tasks per connector is determined by the implementation of the connector...
For sink connectors, the number of tasks should be equal to the number of partitions of the topic. The task distribution among workers is determined by task rebalance which is a very similar process to Kafka consumer group rebalance."
"there should only be one task assigned partition 0 of the first topic, so elect that one the leader" [Commiter in Iceberg code].
Saturday, May 17, 2025
DevOps lessons from Polaris and Iceberg
Friday, March 28, 2025
Iceberg Tidbits
run rewrite firstexpire secondyou don't need to run remove_orphans unless something broke [Discord]
- rewrite_data_files puts all the data in as few a number of files as possible.
- expire_snapshots then deletes any files that are surplus.
To clarify, Remove Orphan Files is only for cleaning up files from failed writes or compactions that failed in a way that the process could not clean up.Inside of Remove orphan files are 2 expensive remote steps
- Listing everything in the directories owned by the table
- Join of that list with metadata file paths
Then the list of files to delete is brought back to the driver where deletes are preformed [Discord]
Saturday, December 21, 2024
Debugging Polaris in Docker
Michael Colladoit's going to be both, so you shouldn't really use it in that scenario. The Polaris server is going to read/write metadata.json files in its own container's file system and the spark notebook will read/write data files in its own container's filesystem, so... [Discord]
Friday, September 27, 2024
Running Iceberg Catalogs in a test suite
Russell SpitzerThis isn't actually defined anywhere. So at the moment we are kind of in a wild west, the Spark implementation deletes absolutely everything. I believe for Trino it just sends the request to the catalog and it's up to the catalog to decide. So for Spark "no", and it explicitly sends a drop table request to the rest catalog without a purge flag.
Sunday, July 21, 2024
Hive for an Iceberg test suite
Cannot write into v1 table: `spark_catalog`.`database`.`spark_file_test_writeto`.
"Now V2 Predicate function pushdown is allowed (or at least should be coming soon) but for that you must use the datasource functions and not the spark wones" [Slack]"Best practice for partitions is partition by low cardinality and sort for high cardanality. This may reduce the level of partitions you need" [Slack]
So, I tried creating the table with:
ERROR | o.a.h.h.metastore.RetryingHMSHandler - MetaException(message:Unable to update transaction database java.sql.SQLSyntaxErrorException: Table/View 'NEXT_LOCK_ID' does not exist.
Sunday, June 16, 2024
First look at the Unity Catalog
Sunday, March 24, 2024
Iceberg locks and catalogs
Although Hadoop Meta Store is used for most Spark implementations, it's not recommended for Iceberg. HMS does not support retries and deconflicting commits.
"HadoopCatalog has a number of drawbacks and we strongly discourage it for production use. There are certain features like rename and drop that may not be safe depending on the storage layer and you may also require a lock manager to get atomic behavior. JdbcCatalog is a much better alternative for the backing catalog." [Iceberg Slack]
Iceberg comes with a DynamoDb (AWS) implementation of the lock manager. Looking at the code, it appears that acquiring the lock uses an optimistic strategy. You can tell DynamoDB to put a row in the table iff it doesn't exist already. If it does, the underlying AWS library throws a software.amazon.awssdk.services.dynamodb.model.ConditionalCheckFailedException. There's a test for this in the AWS module here. It needs an AWS account to run.
"This is necessary for a file system-based catalog to ensure atomic transaction in storages like S3 that do not provide file write mutual exclusion." [Iceberg docs] This is a sentiment echoed in this blog.
The issue is the rename, not the data transfer. "Each object transfer is atomic. That is, either a whole file is transferred, or none of it is. But the directory structure is not atomic and a failure can cause mv to fail mid-way." [AWS Questions]
In the old world of HDFS, Spark would write its output to a temporary directory then atomically rename that directory to that of the final destination. However, S3 is not a file system but a blob store and the notion of a directory is just that: notional. When we change a "directory's" name, all the files in a directory need to be renamed one-by-one and renaming all the files Spark outputs is not atomic in S3. Implementations that talk to their own file system must implement Hadoop's OutputCommitter and Spark will call these when preparing to write etc.
The only mention of the lock manager in "Apache Iceberg: The Definitive Guide" is:
"If you are using AWS Glue 3.0 with Iceberg 0.13.1, you must also set the additional configurations for using the Amazon DynamoDB lock manager to ensure atomic transactions. AWS Glue 4.0, on the other hand, uses optimistic locking by default."
which is a bit too cryptic for me apparently because Glue 4.0 has a different version of Iceberg that uses optimistic locking [Discourse].
Catalogs
Catalogs "allows [Iceberg] to ensure consistency with multiple readers and writers and discover what tables are available in the environment... the primary high level requirement for a catalog implementation to work as an Iceberg catalog is to map a table path (e.g., “db1.table1”) to the file path of the metadata file that has the table’s current state."
The Catalogs are:
- Hadoop. Note that Hadoop is used loosely. "Note anytime you use a distributed file system (or something that looks like one) to store the current metadata pointer, the catalog used is actually called the 'hadoop' catalog." [1] The most important potential downside of this Catalog is "It requires the file system to provide a file/object rename operation that is atomic to prevent data loss when concurrent writes occur." And there are others. "A Hadoop catalog doesn’t need to connect to a Hive MetaStore, but can only be used with HDFS or similar file systems that support atomic rename. Concurrent writes with a Hadoop catalog are not safe with a local FS or S3." [Iceberg docs]
- Hive. Apart from running an additional process (unlike the Hadoop catalog), "It requires the file system to provide a file/object rename operation that is atomic to prevent data loss when concurrent writes occur." [1]
- AWS Glue. "Like the Hive catalog, it does not support multi-table transactions" [1]
- Nessie gives a Git-like experience for data lakes but the two main disadvantages are that you must run the infrastructure yourself (like Hive) and it's not compatible with all engines.
- REST is by nature simple, is implementation agnostic and "the REST catalog supports multi- table transactions" "REST Catalog is actually a protocol with a client implementation in the library. There are examples of how to adapt that protocol to different catalog backends (like HMS or JDBC)... The REST protocol allows for advanced features that other catalogs cannot support, but that doesn't mean all of those features will be available for every REST implementation" [Slack]
- JDBC is near ubiquitous but "it doesn’t support multi-table transactions". "With JDBC the database does the locking, so no external lock manager is required" [Slack]
So, which should you use? From contributor, Daniel Weeks in Slack:
"If you're not using HMS currently, I would suggest going with JdbcCatalog, which you can also use directly or with a REST frontend... I would strongly suggest using JDBC Catalog unless there's something specific you need. HMS is built for hive and iceberg is not hive. There is both a lot of completely and baggage that comes with hive. For example, if you change the table scheme directly in hive, it does not change the schema in your iceberg table. Same with setting table properties. JDBC is super lightweight and native to iceberg, so if you don't have hive, I would avoid using it.
"There are multiple projects that are starting to adopt REST and I expect that only to grow, but that doesn't mean you necessarily need it right now. The main thing to think about is using multiple catalogs (not limit yourself to a single one). You can use JDBC directly now (most engines support it), but you can always add a REST frontend later. They can co-exist and REST can even proxy to your JDBC backend"
[1] "Apache Iceberg: The Definitive Guide"
Thursday, January 11, 2024
Hilbert Curves
When you want to cluster data together over multiple dimensions, you can use Z-Order. But a better algorithm is the Hilbert Curve, a fractal that makes a best attempt to keep adjacent points together in a 1-dimensional space.
From DataBrick's Liquid Cluster design doc we get this graphical representation of what it looks like:
![]() |
| Dotted line squares represent files |
![]() |
| Z-ordering. Lines indicate contiguous data. Colours indicate different files. |
![]() |
| A Hilbert curve over sparse data |
![]() |
| A Hilbert curve over sparse data |
![]() |
| Z-Order over a similar sparse space |
Thursday, November 9, 2023
Z-order
Z-ordering is an optimization technique in big data that allows faster access since similar data lives together. We discuss the algorithm that defines what is similar here.
Imagine a logical grid where all the values of one column run across the top and all the values from another run down the side. If we were to sort this data, every datum can be placed somewhere in that grid.
Now, if the squares of the grid were mapped to files and all the data in each cell were to live in those files, we have made searching much easier as we now know the subset of files in which it may live. We've essentially sorted in not just one dimension but two (although we can do higher).
This can be especially useful when we want to sort the data but don't know exactly what to sort on - a common connundrum when dealing with events. Say we have event_time, insert_time and update_time. Which do we choose? We could sort the data three times, each time on one column but this is impractical with huge data sets. Enter z-order.
Note that the Z-Order really needs 2 or more columns on which to act. Only one column is the degenerate case. "Zorder/Hilbert etc on a single dimension are just a hierarchal sort" [Russell Spitzer on Slack].
(This is a good article about z-ordering from the perspective of Apache Iceberg.)
For an example in Delta Lake, we can see this code that creates a data set with columns c1, c2 and c3 whose values are [x, 99-x, x+50 mod 100] for x [0, 99]. After z-ordering it, these numbers are split into 4 different files. Generating a graphic illustrates how the data points are distributed over those files:
The idea behind how we calculate which cell a datum falls into is best described here on Wikipedia. But, in brief, the binary representation of the data points is interleaved to give a z-value per tuple. In our example, I see a [0, 99, 50] mapped to the byte array [0, 0, 0, 0, 0, 0, 0, 0, 0, 9, -112, 26].I took a look at the Delta Lake code here where a Spark Column object is created that wraps a DL InterleaveBits type which in turn is a subclass of Spark's Catalyst Expression type. This executes on Spark's InternalRow, that is, the raw data on the executors.
The reason the code is doing this is to add a column with which we can repartition the data with the SQL CAST(interleavebits(rangepartitionid(c1), rangepartitionid(c2), rangepartitionid(c3)) AS STRING). The rangepartitionid keyword is part of the Delta Lake machinery.
Using this z-order value (plus a random key), the DataFrame the Delta code now calls repartitionByRange which samples the data [SO] and breaks it into discrete ranges.
Given the interleaving of the columns c1, c2 and c3 their order has minimal impact on the z-value so it's no surprise to see nearby data clustering into the same files, as we can see in the graphic. In fact, if you look at the DataFrame during the repartition process:
+---+---+---+-------------------------------------------+
| c1| c2| c3|c7b6b480-c678-4686-aa99-283988606159-rpKey1|
+---+---+---+-------------------------------------------+
| 0| 99| 50| \t�|
| 1| 98| 51| \t�|
| 2| 97| 52| \t�b|
| 3| 96| 53| \t�e|
| 4| 95| 54| \b��|
| 5| 94| 55| \b��|
| 6| 93| 56| \b��|
| 7| 92| 57| \b��|
| 8| 91| 58| \b�|
| 9| 90| 59| \b�|
| 10| 89| 60| \b�b|
| 11| 88| 61| \b�e|
| 12| 87| 62| \b��|
| 13| 86| 63| \b��|
| 14| 85| 64| \f)�|
| 15| 84| 65| \f)�|
| 16| 83| 66| \f`|
| 17| 82| 67| \f`|
| 18| 81| 68| \f`b|
| 19| 80| 69| \f`e|
+---+---+---+-------------------------------------------+
you can see the slowly changing values by which things are partitioned (column c7b6b480-c678-4686-aa99-283988606159-rpKey1 - a random name so it doesn't clash with other column names. It's dropped immediately after the call to repartitionByRange)
Sunday, June 25, 2023
I've got a fever, and the only prescription is MOR COW (bell)
Apache Iceberg deals with updates in two different ways:
- Merge on read
- Copy on write
What are these strategies? To illustrate, I've some BDD code that writes and updates 20 rows of data using both MOR and COW. (There's an interesting article at Dremio about this topic but some of the code is Dremio specific).
Simply put, copy-on-write replaces the entire parquet file if a single row in updated.
In merge-on-read, a file containing only the updated data (and a file saying which row was affected) are written. It is the reader that needs to reconcile the data.
The two strategies are for different audiences. COW makes writes slow and reads fast. MOR makes reads slow and writes fast.
Focussing on the more complex of the two strategies, MOR, we see that it creates four new files compared to COW's two. This maps to two different parquet files (as each parquet file in both strategies has a .crc file that holds its metadata). One file contains the updated data, the other a textual reference to the original file containing the original data. No files are deleted and the original parquet file remains the same. No data is redundant.
Iceberg has other means of storing the delete data other than position in the file. It also can check equality. However, this appears to be not supported by Spark at the moment.
(BTW, the title of this post refers to this SNL sketch).





