| <!doctype html><html lang=en dir=ltr> |
| <head> |
| <meta charset=utf-8> |
| <meta name=viewport content="width=device-width,initial-scale=1"> |
| <meta name=description content="Evolution # Iceberg supports in-place table evolution. You can evolve a table schema just like SQL – even in nested structures – or change partition layout when data volume changes. Iceberg does not require costly distractions, like rewriting table data or migrating to a new table. |
| For example, Hive table partitioning cannot change so moving from a daily partition layout to an hourly partition layout requires a new table. And because queries are dependent on partitions, queries must be rewritten for the new table."> |
| <meta name=theme-color content="#FFFFFF"> |
| <meta name=color-scheme content="light dark"><meta property="og:title" content> |
| <meta property="og:description" content="Evolution # Iceberg supports in-place table evolution. You can evolve a table schema just like SQL – even in nested structures – or change partition layout when data volume changes. Iceberg does not require costly distractions, like rewriting table data or migrating to a new table. |
| For example, Hive table partitioning cannot change so moving from a daily partition layout to an hourly partition layout requires a new table. And because queries are dependent on partitions, queries must be rewritten for the new table."> |
| <meta property="og:type" content="article"> |
| <meta property="og:url" content="https://iceberg.apache.org/docs/FixSparkArtifactVersion/evolution/"><meta property="article:section" content="docs"> |
| <title>Evolution | Apache Iceberg</title> |
| <link rel=manifest href=/docs/FixSparkArtifactVersion/manifest.json> |
| <link rel=icon href=/docs/FixSparkArtifactVersion/favicon.png type=image/x-icon> |
| <link rel=stylesheet href=/docs/FixSparkArtifactVersion/book.min.179e158d24f3ef709534173fd8b1c1e541a4fa3e23c1b5d8e887464c58949cc9.css integrity="sha256-F54VjSTz73CVNBc/2LHB5UGk+j4jwbXY6IdGTFiUnMk=" crossorigin=anonymous> |
| <script defer src=/docs/FixSparkArtifactVersion/flexsearch.min.js></script> |
| <script defer src=/docs/FixSparkArtifactVersion/en.search.min.22e67e1125667c60fd7b9b24ba8c036274712b6ce8b2ee4cf165beead757bc10.js integrity="sha256-IuZ+ESVmfGD9e5skuowDYnRxK2zosu5M8WW+6tdXvBA=" crossorigin=anonymous></script> |
| </head> |
| <body dir=ltr> |
| <input type=checkbox class="hidden toggle" id=menu-control> |
| <input type=checkbox class="hidden toggle" id=toc-control> |
| <main class="container flex"> |
| <aside class=book-menu> |
| <div class=book-menu-content> |
| <nav> |
| <h2 class=book-brand> |
| <a class="flex align-center" href=/docs/FixSparkArtifactVersion/../../><img src=/docs/FixSparkArtifactVersion/img/iceberg-logo-icon.png alt=Logo><span>Apache Iceberg</span> |
| </a> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../releases> |
| <img id=version-shield src=https://img.shields.io/badge/version-FixSparkArtifactVersion-blue alt> |
| </a> |
| </h2> |
| <div class=book-search> |
| <input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/> |
| <div class="book-search-spinner hidden"></div> |
| <ul id=book-search-results></ul> |
| <a href=https://github.com/apache/iceberg target=_blank> |
| <img src=https://iceberg.apache.org/docs/FixSparkArtifactVersion/img/GitHub-Mark.png target=_blank class=top-external-icon> |
| </a> |
| <a href=https://join.slack.com/t/apache-iceberg/shared_invite/zt-tlv0zjz6-jGJEkHfb1~heMCJA3Uycrg target=_blank> |
| <img src=https://iceberg.apache.org/docs/FixSparkArtifactVersion/img/Slack_Mark_Web.png target=_blank class=top-external-icon> |
| </a> |
| </div> |
| <ul> |
| <li class=book-section-flats> |
| <span> |
| <i class="fa fa-table fa-fw"></i> |
| Tables</span> |
| <ul> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/configuration/> |
| Configuration</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/evolution/ class=active> |
| Evolution</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/maintenance/> |
| Maintenance</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/partitioning/> |
| Partitioning</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/performance/> |
| Performance</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/reliability/> |
| Reliability</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/schemas/> |
| Schemas</a> |
| </li> |
| </ul> |
| </li> |
| <li class=book-section-flats> |
| <span> |
| <i class="fa fa-star-o fa-fw"></i> |
| Spark</span> |
| <ul> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/getting-started/> |
| Getting Started</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/spark-configuration/> |
| Configuration</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/spark-ddl/> |
| DDL</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/spark-procedures/> |
| Procedures</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/spark-queries/> |
| Queries</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/spark-structured-streaming/> |
| Structured Streaming</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/spark-writes/> |
| Writes</a> |
| </li> |
| </ul> |
| </li> |
| <li class=book-section-flats> |
| <span> |
| <img src=https://iceberg.apache.org/docs/FixSparkArtifactVersion/img/flink-logo.png class="navigation-icon fa-fw">Flink</span> |
| <ul> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/flink/> |
| Getting Started</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/flink-connector/> |
| Flink Connector</a> |
| </li> |
| </ul> |
| </li> |
| <li class=book-section-flats> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/hive/> |
| <img src=https://iceberg.apache.org/docs/FixSparkArtifactVersion/img/../img/hive-logo.png class="navigation-icon fa-fw">Hive</a> |
| <ul> |
| </ul> |
| </li> |
| <li> |
| <a href=https://trino.io/docs/current/connector/iceberg.html target=_blank> |
| <img src=https://iceberg.apache.org/docs/FixSparkArtifactVersion/img/../img/trino-logo.png class="navigation-icon fa-fw"> |
| Trino |
| </a> |
| </li> |
| <li> |
| <a href=https://prestodb.io/docs/current/connector/iceberg.html target=_blank> |
| <img src=https://iceberg.apache.org/docs/FixSparkArtifactVersion/img/../img/prestodb-logo.png class="navigation-icon fa-fw"> |
| Presto |
| </a> |
| </li> |
| <li> |
| <a href=https://docs.dremio.com/data-formats/apache-iceberg/ target=_blank> |
| <img src=https://iceberg.apache.org/docs/FixSparkArtifactVersion/img/../img/dremio-logo.png class="navigation-icon fa-fw"> |
| Dremio |
| </a> |
| </li> |
| <li> |
| <a href=https://docs.aws.amazon.com/athena/latest/ug/querying-iceberg.html target=_blank> |
| <img src=https://iceberg.apache.org/docs/FixSparkArtifactVersion/img/../img/athena-logo.png class="navigation-icon fa-fw"> |
| Amazon Athena |
| </a> |
| </li> |
| <li> |
| <a href=https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-iceberg-create-cluster.html target=_blank> |
| <img src=https://iceberg.apache.org/docs/FixSparkArtifactVersion/img/../img/emr-logo.png class="navigation-icon fa-fw"> |
| Amazon EMR |
| </a> |
| </li> |
| <li class=book-section-collapsed> |
| <input type=checkbox id=section-56605d8e971a871885e28ee5142728bf class=toggle> |
| <label for=section-56605d8e971a871885e28ee5142728bf class="flex justify-between"> |
| <a role=button> |
| <i class="fa fa-handshake-o fa-fw"></i> |
| Integrations</a> |
| </label> |
| <ul> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/aws/> |
| AWS</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/jdbc/> |
| JDBC</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/nessie/> |
| Nessie</a> |
| </li> |
| </ul> |
| </li> |
| <li class=book-section-collapsed> |
| <input type=checkbox id=section-bf7b3283e3790c00c8caaa140299052b class=toggle> |
| <label for=section-bf7b3283e3790c00c8caaa140299052b class="flex justify-between"> |
| <a role=button> |
| <i class="fa fa-connectdevelop fa-fw"></i> |
| API</a> |
| </label> |
| <ul> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/java-api-quickstart/> |
| Java Quickstart</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/api/> |
| Java API</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/custom-catalog/> |
| Java Custom Catalog</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../javadoc/FixSparkArtifactVersion> |
| Javadocs |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/python-quickstart/> |
| Python Quickstart</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/python-api-intro/> |
| Python API</a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/python-feature-support/> |
| Python Feature Support</a> |
| </li> |
| </ul> |
| </li> |
| <li class=book-section-collapsed> |
| <input type=checkbox id=section-7e66f1754ca5d93e20ecdc89df5b8b28 class=toggle> |
| <label for=section-7e66f1754ca5d93e20ecdc89df5b8b28 class="flex justify-between"> |
| <a role=button> |
| <i class="fa fa-users fa-fw"></i> |
| Community</a> |
| </label> |
| <ul> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../../blogs> |
| Blogs |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../../community> |
| Join |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../../talks> |
| Talks |
| </a> |
| </li> |
| </ul> |
| </li> |
| <li class=book-section-collapsed> |
| <input type=checkbox id=section-87dda23e9104fe3231cee3bc88a2d754 class=toggle> |
| <label for=section-87dda23e9104fe3231cee3bc88a2d754 class="flex justify-between"> |
| <a role=button> |
| <i class="fa fa-object-ungroup fa-fw"></i> |
| Format</a> |
| </label> |
| <ul> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../../spec> |
| Spec |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../../terms> |
| Terms |
| </a> |
| </li> |
| </ul> |
| </li> |
| <li class=book-section-collapsed> |
| <input type=checkbox id=section-2e5d3f5f142758d8dd368e9c281dd08e class=toggle> |
| <label for=section-2e5d3f5f142758d8dd368e9c281dd08e class="flex justify-between"> |
| <a role=button> |
| <i class="fa fa-wrench fa-fw"></i> |
| Project</a> |
| </label> |
| <ul> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../../how-to-release> |
| How to Release |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../../roadmap> |
| Roadmap |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../../security> |
| Security |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../../trademarks> |
| Trademarks |
| </a> |
| </li> |
| </ul> |
| </li> |
| <li class=book-section-collapsed> |
| <input type=checkbox id=section-4ddb27a8612bc8118c0b36386905d332 class=toggle> |
| <label for=section-4ddb27a8612bc8118c0b36386905d332 class="flex justify-between"> |
| <a role=button> |
| <i class="fa fa-code-fork fa-fw"></i> |
| Releases</a> |
| </label> |
| <ul> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../latest> |
| Latest |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../0.13.0> |
| 0.13.0 |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../0.12.1> |
| 0.12.1 |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://iceberg.apache.org/docs/FixSparkArtifactVersion/../../../releases> |
| Release Notes |
| </a> |
| </li> |
| </ul> |
| </li> |
| <li class=book-section-collapsed> |
| <input type=checkbox id=section-296746d27808aa768e500824aaf2adea class=toggle> |
| <label for=section-296746d27808aa768e500824aaf2adea class="flex justify-between"> |
| <a role=button> |
| <img src=https://iceberg.apache.org/docs/FixSparkArtifactVersion/img/../img/asf.png class="navigation-icon fa-fw">ASF</a> |
| </label> |
| <ul> |
| <li class=navigation-icon-pad> |
| <a href=https://www.apache.org/licenses/ target=_blank> |
| <i class="fa fa-external-link fa-fw"></i> |
| License |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://www.apache.org/security/ target=_blank> |
| <i class="fa fa-external-link fa-fw"></i> |
| Security |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://www.apache.org/foundation/thanks.html target=_blank> |
| <i class="fa fa-external-link fa-fw"></i> |
| Sponsors |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://www.apache.org/foundation/sponsorship.html target=_blank> |
| <i class="fa fa-external-link fa-fw"></i> |
| Donate |
| </a> |
| </li> |
| <li class=navigation-icon-pad> |
| <a href=https://www.apache.org/events/current-event.html target=_blank> |
| <i class="fa fa-external-link fa-fw"></i> |
| Events |
| </a> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </nav> |
| <script>(function(){var a=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(b){localStorage.setItem("menu.scrollTop",a.scrollTop)}),a.scrollTop=localStorage.getItem("menu.scrollTop")})()</script> |
| </div> |
| </aside> |
| <div class=book-page> |
| <header class=book-header> |
| <div class="flex align-center justify-between"> |
| <link rel=stylesheet href=/docs/FixSparkArtifactVersion/fontawesome/css/font-awesome.min.css> |
| <label for=menu-control> |
| <img src=/docs/FixSparkArtifactVersion/svg/menu.svg class=book-icon alt=Menu> |
| </label> |
| <strong>Evolution</strong> |
| <label for=toc-control> |
| <img src=/docs/FixSparkArtifactVersion/svg/toc.svg class=book-icon alt="Table of Contents"> |
| </label> |
| </div> |
| <aside class="hidden clearfix"> |
| <nav id=TableOfContents> |
| <ul> |
| <li><a href=#schema-evolution>Schema evolution</a> |
| <ul> |
| <li><a href=#correctness>Correctness</a></li> |
| </ul> |
| </li> |
| <li><a href=#partition-evolution>Partition evolution</a></li> |
| <li><a href=#sort-order-evolution>Sort order evolution</a></li> |
| </ul> |
| </nav> |
| </aside> |
| </header> |
| <article class=markdown> |
| <h1 id=evolution> |
| Evolution |
| <a class=anchor href=#evolution>#</a> |
| </h1> |
| <p>Iceberg supports <strong>in-place table evolution</strong>. You can <a href=#schema-evolution>evolve a table schema</a> just like SQL – even in nested structures – or <a href=#partition-evolution>change partition layout</a> when data volume changes. Iceberg does not require costly distractions, like rewriting table data or migrating to a new table.</p> |
| <p>For example, Hive table partitioning cannot change so moving from a daily partition layout to an hourly partition layout requires a new table. And because queries are dependent on partitions, queries must be rewritten for the new table. In some cases, even changes as simple as renaming a column are either not supported, or can cause <a href=#correctness>data correctness</a> problems.</p> |
| <h2 id=schema-evolution> |
| Schema evolution |
| <a class=anchor href=#schema-evolution>#</a> |
| </h2> |
| <p>Iceberg supports the following schema evolution changes:</p> |
| <ul> |
| <li><strong>Add</strong> – add a new column to the table or to a nested struct</li> |
| <li><strong>Drop</strong> – remove an existing column from the table or a nested struct</li> |
| <li><strong>Rename</strong> – rename an existing column or field in a nested struct</li> |
| <li><strong>Update</strong> – widen the type of a column, struct field, map key, map value, or list element</li> |
| <li><strong>Reorder</strong> – change the order of columns or fields in a nested struct</li> |
| </ul> |
| <p>Iceberg schema updates are <strong>metadata changes</strong>, so no data files need to be rewritten to perform the update.</p> |
| <p>Note that map keys do not support adding or dropping struct fields that would change equality.</p> |
| <h3 id=correctness> |
| Correctness |
| <a class=anchor href=#correctness>#</a> |
| </h3> |
| <p>Iceberg guarantees that <strong>schema evolution changes are independent and free of side-effects</strong>, without rewriting files:</p> |
| <ol> |
| <li>Added columns never read existing values from another column.</li> |
| <li>Dropping a column or field does not change the values in any other column.</li> |
| <li>Updating a column or field does not change values in any other column.</li> |
| <li>Changing the order of columns or fields in a struct does not change the values associated with a column or field name.</li> |
| </ol> |
| <p>Iceberg uses unique IDs to track each column in a table. When you add a column, it is assigned a new ID so existing data is never used by mistake.</p> |
| <ul> |
| <li>Formats that track columns by name can inadvertently un-delete a column if a name is reused, which violates #1.</li> |
| <li>Formats that track columns by position cannot delete columns without changing the names that are used for each column, which violates #2.</li> |
| </ul> |
| <h2 id=partition-evolution> |
| Partition evolution |
| <a class=anchor href=#partition-evolution>#</a> |
| </h2> |
| <p>Iceberg table partitioning can be updated in an existing table because queries do not reference partition values directly.</p> |
| <p>When you evolve a partition spec, the old data written with an earlier spec remains unchanged. New data is written using the new spec in a new layout. Metadata for each of the partition versions is kept separately. Because of this, when you start writing queries, you get split planning. This is where each partition layout plans files separately using the filter it derives for that specific partition layout. Here’s a visual representation of a contrived example:</p> |
| <p><img src=../img/partition-spec-evolution.png alt="Partition evolution diagram"> |
| <em>The data for 2008 is partitioned by month. Starting from 2009 the table is updated so that the data is instead partitioned by day. Both partitioning layouts are able to coexist in the same table.</em></p> |
| <p>Iceberg uses <a href=../partitioning>hidden partitioning</a>, so you don’t <em>need</em> to write queries for a specific partition layout to be fast. Instead, you can write queries that select the data you need, and Iceberg automatically prunes out files that don’t contain matching data.</p> |
| <p>Partition evolution is a metadata operation and does not eagerly rewrite files.</p> |
| <p>Iceberg’s Java table API provides <code>updateSpec</code> API to update partition spec. |
| For example, the following code could be used to update the partition spec to add a new partition field that places <code>id</code> column values into 8 buckets and remove an existing partition field <code>category</code>:</p> |
| <div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-java data-lang=java>Table sampleTable <span style=color:#f92672>=</span> <span style=color:#f92672>...;</span> |
| sampleTable<span style=color:#f92672>.</span><span style=color:#a6e22e>updateSpec</span><span style=color:#f92672>()</span> |
| <span style=color:#f92672>.</span><span style=color:#a6e22e>addField</span><span style=color:#f92672>(</span>bucket<span style=color:#f92672>(</span><span style=color:#e6db74>"id"</span><span style=color:#f92672>,</span> 8<span style=color:#f92672>))</span> |
| <span style=color:#f92672>.</span><span style=color:#a6e22e>removeField</span><span style=color:#f92672>(</span><span style=color:#e6db74>"category"</span><span style=color:#f92672>)</span> |
| <span style=color:#f92672>.</span><span style=color:#a6e22e>commit</span><span style=color:#f92672>();</span> |
| </code></pre></div><p>Spark supports updating partition spec through its <code>ALTER TABLE</code> SQL statement, see more details in <a href=../spark-ddl/#alter-table--add-partition-field>Spark SQL</a>.</p> |
| <h2 id=sort-order-evolution> |
| Sort order evolution |
| <a class=anchor href=#sort-order-evolution>#</a> |
| </h2> |
| <p>Similar to partition spec, Iceberg sort order can also be updated in an existing table. |
| When you evolve a sort order, the old data written with an earlier order remains unchanged. |
| Engines can always choose to write data in the latest sort order or unsorted when sorting is prohibitively expensive.</p> |
| <p>Iceberg’s Java table API provides <code>replaceSortOrder</code> API to update partition spec. |
| For example, the following code could be used to create a new sort order |
| with <code>id</code> column sorted in ascending order with nulls last, |
| and <code>category</code> column sorted in descending order with nulls first:</p> |
| <div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-java data-lang=java>Table sampleTable <span style=color:#f92672>=</span> <span style=color:#f92672>...;</span> |
| sampleTable<span style=color:#f92672>.</span><span style=color:#a6e22e>replaceSortOrder</span><span style=color:#f92672>()</span> |
| <span style=color:#f92672>.</span><span style=color:#a6e22e>asc</span><span style=color:#f92672>(</span><span style=color:#e6db74>"id"</span><span style=color:#f92672>,</span> NullOrder<span style=color:#f92672>.</span><span style=color:#a6e22e>NULLS_LAST</span><span style=color:#f92672>)</span> |
| <span style=color:#f92672>.</span><span style=color:#a6e22e>dec</span><span style=color:#f92672>(</span><span style=color:#e6db74>"category"</span><span style=color:#f92672>,</span> NullOrder<span style=color:#f92672>.</span><span style=color:#a6e22e>NULL_FIRST</span><span style=color:#f92672>)</span> |
| <span style=color:#f92672>.</span><span style=color:#a6e22e>commit</span><span style=color:#f92672>();</span> |
| </code></pre></div><p>Spark supports updating sort order through its <code>ALTER TABLE</code> SQL statement, see more details in <a href=../spark-ddl/#alter-table--write-ordered-by>Spark SQL</a>.</p> |
| </article> |
| <footer class=book-footer> |
| <div class="flex flex-wrap justify-between"> |
| </div> |
| <script>(function(){function a(c){const a=window.getSelection(),b=document.createRange();b.selectNodeContents(c),a.removeAllRanges(),a.addRange(b)}document.querySelectorAll("pre code").forEach(b=>{b.addEventListener("click",function(c){a(b.parentElement),navigator.clipboard&&navigator.clipboard.writeText(b.parentElement.textContent)})})})()</script> |
| </footer> |
| <div class=book-comments> |
| </div> |
| <label for=menu-control class="hidden book-menu-overlay"></label> |
| </div> |
| <aside class=book-toc> |
| <div class=book-toc-content> |
| <nav id=TableOfContents> |
| <ul> |
| <li><a href=#schema-evolution>Schema evolution</a> |
| <ul> |
| <li><a href=#correctness>Correctness</a></li> |
| </ul> |
| </li> |
| <li><a href=#partition-evolution>Partition evolution</a></li> |
| <li><a href=#sort-order-evolution>Sort order evolution</a></li> |
| </ul> |
| </nav> |
| </div> |
| </aside> |
| </main> |
| </body> |
| </html> |