<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Partition</id>
	<title>Partition - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Partition"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Partition&amp;action=history"/>
	<updated>2026-12-06T00:07:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://openlakehouse.io/w/index.php?title=Partition&amp;diff=72&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@9783fe6</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Partition&amp;diff=72&amp;oldid=prev"/>
		<updated>2026-11-22T21:29:55Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@9783fe6&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox concept&lt;br /&gt;
| name            = Partition&lt;br /&gt;
| field           = Data engineering&lt;br /&gt;
| key_parts       = Spark partitions, table partitions (Hive-style, Iceberg, Delta Lake), Kafka topic partitions&lt;br /&gt;
| implementations = [[Apache Spark]], [[Apache Iceberg]], [[Delta Lake]], [[Apache Kafka]]&lt;br /&gt;
| related         = [[Shuffle]], [[Executor]], [[Predicate pushdown]], [[Small files problem]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-22|the v4.3.0 tag of apache/spark (docs and PySpark source), a run on a Spark 4.3.1-SNAPSHOT build, the Apache Iceberg 1.12.0 spec and partitioning docs, the Delta Lake protocol at v4.4.1 and the clustering docs, and the Apache Kafka 4.4 introduction}}&lt;br /&gt;
&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;partition&amp;#039;&amp;#039;&amp;#039; is a subset of a dataset that a system stores or processes as one unit. In a lakehouse the word has several distinct meanings, depending on whether it refers to how an engine splits work, how a table lays out files, or how a message log splits a topic. An [[Apache Spark]] partition is a slice of data processed by one task. A table partition in Hive, [[Apache Iceberg]] or [[Delta Lake]] is a group of files that share partition values. An [[Apache Kafka]] partition is an ordered log inside a topic. These meanings interact (a Spark job reads table partitions into Spark partitions, and a Kafka source maps topic partitions to Spark partitions), but they are not the same thing.&lt;br /&gt;
&lt;br /&gt;
== Spark in-memory partition ==&lt;br /&gt;
{{Main|Apache Spark}}&lt;br /&gt;
In Spark, a partition is a piece of an RDD or DataFrame, and Spark runs one task for each partition.&amp;lt;ref name=&amp;quot;rddguide&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/rdd-programming-guide.html |title=RDD Programming Guide (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; The number of partitions therefore sets how much parallel work a stage can do on the cluster&amp;#039;s [[executor]]s. When Spark reads files, it packs at most &amp;lt;code&amp;gt;spark.sql.files.maxPartitionBytes&amp;lt;/code&amp;gt; (default 128 MB) into one partition; after a join or aggregation, it uses &amp;lt;code&amp;gt;spark.sql.shuffle.partitions&amp;lt;/code&amp;gt; (default 200) partitions, which adaptive query execution can coalesce at runtime.&amp;lt;ref name=&amp;quot;perf&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/sql-performance-tuning.html |title=Performance Tuning (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Two DataFrame methods change the number of partitions. &amp;lt;code&amp;gt;repartition&amp;lt;/code&amp;gt; hash-partitions the data and always causes a [[shuffle]].&amp;lt;ref name=&amp;quot;repartition&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/api/python/reference/pyspark.sql/api/pyspark.sql.DataFrame.repartition.html |title=pyspark.sql.DataFrame.repartition (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;rddguide&amp;quot; /&amp;gt; &amp;lt;code&amp;gt;coalesce&amp;lt;/code&amp;gt; only reduces the number of partitions and creates a narrow dependency without a shuffle: going from 1,000 partitions to 100, each new partition claims 10 old ones.&amp;lt;ref name=&amp;quot;coalesce&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/api/python/reference/pyspark.sql/api/pyspark.sql.DataFrame.coalesce.html |title=pyspark.sql.DataFrame.coalesce (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pyspark.sql import functions as F&lt;br /&gt;
&lt;br /&gt;
df = spark.range(0, 1_000_000)&lt;br /&gt;
wide = df.repartition(8, &amp;quot;id&amp;quot;)   # shuffle into 8 hash partitions&lt;br /&gt;
narrow = wide.coalesce(2)        # merge into 2 partitions, no new shuffle&lt;br /&gt;
&lt;br /&gt;
narrow.select(F.spark_partition_id()).distinct().count()   # 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A Spark partition exists only while a job runs. It is not stored, and it is unrelated to the directory layout of the table being read, except that file and partition layout influence how Spark splits its input.&lt;br /&gt;
&lt;br /&gt;
== Hive-style table partitioning ==&lt;br /&gt;
Hive-style partitioning stores a table&amp;#039;s files in directories named after partition column values, such as &amp;lt;code&amp;gt;gender=male/country=US/&amp;lt;/code&amp;gt;. The partition values are encoded in the path of each directory. Spark&amp;#039;s built-in file sources discover this layout automatically and add the partition columns to the schema.&amp;lt;ref name=&amp;quot;parquet&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/sql-data-sources-parquet.html#partition-discovery |title=Parquet Files: Partition Discovery (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Queries skip directories only when they filter on the partition column itself. In Hive, a table partitioned by &amp;lt;code&amp;gt;event_date&amp;lt;/code&amp;gt; has an explicit &amp;lt;code&amp;gt;event_date&amp;lt;/code&amp;gt; column, and a query without an &amp;lt;code&amp;gt;event_date&amp;lt;/code&amp;gt; filter scans every file, even when it filters on the timestamp that the date was derived from.&amp;lt;ref name=&amp;quot;icebergpart&amp;quot;&amp;gt;{{Cite web |url=https://iceberg.apache.org/docs/latest/partitioning/ |title=Partitioning (Apache Iceberg 1.12.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Very fine partitioning also produces many small files; see [[small files problem]].&lt;br /&gt;
&lt;br /&gt;
== Apache Iceberg hidden partitioning and partition evolution ==&lt;br /&gt;
{{Main|Apache Iceberg}}&lt;br /&gt;
Iceberg uses &amp;#039;&amp;#039;&amp;#039;hidden partitioning&amp;#039;&amp;#039;&amp;#039;. A partition spec derives partition values from table columns through transforms such as &amp;lt;code&amp;gt;identity&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bucket[N]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;truncate[W]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;year&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;month&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;day&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;hour&amp;lt;/code&amp;gt;. Because the table records the transform, Iceberg turns a filter on the source column into a partition filter, and users do not have to add partition predicates to their queries.&amp;lt;ref name=&amp;quot;ispec&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/iceberg/blob/apache-iceberg-1.12.0/format/spec.md |title=Iceberg Table Spec (apache-iceberg-1.12.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;icebergpart&amp;quot; /&amp;gt; Partition values are stored in manifests for each data file, not taken from directory names.&amp;lt;ref name=&amp;quot;ispec&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Iceberg also supports &amp;#039;&amp;#039;&amp;#039;partition evolution&amp;#039;&amp;#039;&amp;#039;: a table&amp;#039;s partitioning can change by adding, removing, renaming or reordering partition fields. Each change creates a new partition spec, and files written under an older spec keep it; at scan time, Iceberg converts filters using the spec each manifest was written with.&amp;lt;ref name=&amp;quot;ispec&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Delta Lake partitioning and liquid clustering ==&lt;br /&gt;
{{Main|Delta Lake}}&lt;br /&gt;
A [[Delta Lake]] table can have partition columns, recorded in the table metadata. The transaction log stores each file&amp;#039;s partition values, and readers must take the values from the log. The reference implementation writes files into Hive-style &amp;lt;code&amp;gt;column=value&amp;lt;/code&amp;gt; directories, but the protocol says this layout only follows convention and is not required.&amp;lt;ref name=&amp;quot;dproto&amp;quot;&amp;gt;{{Cite web |url=https://github.com/delta-io/delta/blob/v4.4.1/PROTOCOL.md |title=Delta Transaction Log Protocol (v4.4.1) |publisher=Delta Lake |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Liquid clustering&amp;#039;&amp;#039;&amp;#039; is Delta Lake&amp;#039;s alternative to partitioning and &amp;lt;code&amp;gt;ZORDER&amp;lt;/code&amp;gt;. A table declares clustering columns with &amp;lt;code&amp;gt;CLUSTER BY&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;OPTIMIZE&amp;lt;/code&amp;gt; clusters the data incrementally, and the clustering columns can be changed later with &amp;lt;code&amp;gt;ALTER TABLE&amp;lt;/code&amp;gt; without rewriting existing data. Clustering cannot be combined with partitioning or &amp;lt;code&amp;gt;ZORDER&amp;lt;/code&amp;gt; on the same table. It is available from Delta Lake 3.1.0, and the preview flag was removed in 3.2.&amp;lt;ref name=&amp;quot;dcluster&amp;quot;&amp;gt;{{Cite web |url=https://docs.delta.io/delta-clustering/ |title=Use liquid clustering for Delta tables |publisher=Delta Lake |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; The protocol requires writers of clustered tables to record per-file statistics for the clustering columns, which readers use for data skipping.&amp;lt;ref name=&amp;quot;dproto&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Apache Kafka topic partitions ==&lt;br /&gt;
A Kafka topic is split into partitions spread over brokers. Events with the same key go to the same partition, consumers read each partition in the order its events were written, and replication works per partition.&amp;lt;ref name=&amp;quot;kafka&amp;quot;&amp;gt;{{Cite web |url=https://kafka.apache.org/44/getting-started/introduction/ |title=Introduction (Apache Kafka 4.4) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt; Ordering is guaranteed within a partition, not across a topic.&lt;br /&gt;
&lt;br /&gt;
When [[Structured Streaming]] reads from Kafka, Spark by default maps each Kafka topic partition to one Spark partition. The &amp;lt;code&amp;gt;minPartitions&amp;lt;/code&amp;gt; option asks Spark to split large Kafka partitions into more Spark partitions.&amp;lt;ref name=&amp;quot;sskafka&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/streaming/structured-streaming-kafka-integration.html |title=Structured Streaming + Kafka Integration Guide (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-22}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Which partition am I looking at? ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Meaning !! Where it lives !! Lifetime !! Who decides it !! Changed by&lt;br /&gt;
|-&lt;br /&gt;
| Spark partition&lt;br /&gt;
| Memory and local disk of executors&lt;br /&gt;
| One job or stage&lt;br /&gt;
| Spark (file split size, shuffle partitions, AQE) or the user&lt;br /&gt;
| &amp;lt;code&amp;gt;repartition&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;coalesce&amp;lt;/code&amp;gt;, SQL hints&amp;lt;ref name=&amp;quot;perf&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Hive-style table partition&lt;br /&gt;
| Directory names in storage (&amp;lt;code&amp;gt;col=value/&amp;lt;/code&amp;gt;)&lt;br /&gt;
| Permanent, part of the table&lt;br /&gt;
| Table author (partition columns)&lt;br /&gt;
| Writing the data into a new directory layout&lt;br /&gt;
|-&lt;br /&gt;
| Iceberg partition&lt;br /&gt;
| Partition tuples in manifests, derived by transforms&lt;br /&gt;
| Permanent, per partition spec&lt;br /&gt;
| Table author (partition spec)&lt;br /&gt;
| Partition evolution; old files keep their spec&amp;lt;ref name=&amp;quot;ispec&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Delta Lake partition or cluster&lt;br /&gt;
| Partition values or statistics in the transaction log&lt;br /&gt;
| Permanent&lt;br /&gt;
| Table author (&amp;lt;code&amp;gt;PARTITIONED BY&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;CLUSTER BY&amp;lt;/code&amp;gt;)&lt;br /&gt;
| Clustering columns via &amp;lt;code&amp;gt;ALTER TABLE&amp;lt;/code&amp;gt;&amp;lt;ref name=&amp;quot;dcluster&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Kafka topic partition&lt;br /&gt;
| Brokers&lt;br /&gt;
| Lifetime of the topic&lt;br /&gt;
| Topic configuration; the event key decides which partition an event goes to&amp;lt;ref name=&amp;quot;kafka&amp;quot; /&amp;gt;&lt;br /&gt;
| Kafka topic administration&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Shuffle]]&lt;br /&gt;
* [[Executor]]&lt;br /&gt;
* [[Predicate pushdown]]&lt;br /&gt;
* [[Open table format]]&lt;br /&gt;
* [[Small files problem]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Navbox open lakehouse}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;br /&gt;
[[Category:Glossary terms]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>