添加和重命名列而无需重写文件

阅读约需 42分钟 分钟,8节中含4个示例。

版次 2026.11.10 示例于 2026年11月20日 通过 39个示例中有39个通过 变化内容

AI 翻译。由人工以英文核验。 我们如何制作图书

译自英文版图书,版次 2026.11.10。 阅读原文

读完本章,你将能够为已有数据的表添加一列,在 Iceberg 中重命名一列而无需重写其数据文件,并能说明为什么在 Delta Lake 中重命名列等于重写整张表。

wiki.pageviews_hourly 写入最初三个小时的数据之后,收到了两项请求。这张表保存了 Wikimedia 六个小时的页面浏览量的每小时计数,数据由第一章加载,因此每项变更都作用于一张已有数据的表。第一项请求要求增加一个血缘列:每一行都应记录是哪次每小时加载写入了它,这样一次有问题的加载就可以追溯到它所写入的行。表需要这样一列,而表中已有的行是在这一列出现之前写入的。第二项是命名修正。仪表盘把标题列称为 article_title,而表中称它为 page_title,这是转储文件所用的名称。对于每项变更,问题都是一样的:在变更之前写入的文件会怎样?

原则上,模式变更属于元数据变更。数据文件留在原处,格式在其元数据中记录新增或重命名的列。旧文件是否仍能被正确读取,取决于该格式如何在文件内部定位一列。按名称定位列的格式,在名称改变时会遇到麻烦;按不会改变的标识定位列的格式则不会。本章说明每种格式分别属于哪一类,每项变更的代价是什么,以及所固定版本的 Delta Lake 库无法完成哪一项变更。

列按 ID 跟踪

最近一次修改见于版次 2026.11.10

数据文件保存若干列的值,表的模式(schema)则说明每个值属于哪一列。将二者对应起来,最简单的办法是按名称匹配。在名称不变时,这种办法可行;一旦名称改变,模式中就会出现一个旧文件里没有的列名,读取器只能猜测旧值属于哪一列。

读取器按名称匹配,却找不到旧名称对应的列,这时只有两种糟糕的选择:让查询失败,或者悄悄地把该列填充为 null。第二种是更隐蔽的失败,仪表盘可能连续数周显示这样的结果,却无人察觉。我们认为悄无声息的 null 是更严重的失败,这是一种判断,而不是实测的结果。按标识匹配可以避免这两种情况,因为无论名称如何变化,列都保有自己的标识。

Iceberg 在创建列时为每一列分配一个整数字段 ID,并按该 ID 匹配列。名称只是一个可以更改的标签,Iceberg 规范指出,重命名字段“必须更改名称,但不得更改字段 ID”[1]。读取器打开旧文件时,按字段 ID 匹配每一列。如果文件中没有某个字段的值,规范的投影规则会先检查两种此处不适用的情形,即恒等分区值和名称映射;随后,若该字段设置了 initial-default,则返回该值,其余情况一律返回 null [1]。规范为带默认值添加的列定义了 initial-default。本章没有设置默认值,因此新增的列在所有旧行中读取为 null。

这些 ID 可以亲自查看。Iceberg 表的模式列出每个字段及其 ID,重命名一节中的示例会打印某一列在重命名前后的 ID。想知道重命名是否保留了列的标识,就应检查这个 ID。

Delta Lake 的出发点不同。它的表模式为每一列命名,读取器按名称匹配。Delta Lake 协议定义了一项可选的列映射特性,把文件中的名称与读取者看到的名称区分开来:每一列都有一个存放在文件中的物理名称,读取者使用的名称是显示名称,可以更改而不触及文件。协议指出,列映射支持“重命名和删除列,而无需重写全部数据”[2]。某个具体的库版本是否做到这一点,则是另一个问题。关于 Delta Lake 的一节针对固定的版本回答了这个问题。

**工作准则:**对于 Iceberg 的列,应预期它在重命名后保留数据,因为读取器按字段 ID 匹配。对于 Delta Lake 的列,除非开启了列映射,否则应预期它按名称匹配。依赖重命名之前,先在表的副本上测试,并在事后读回列名进行核对。

这部分尚未翻译,因此以英文显示。

Add load_batch after three hours

最近一次修改见于版次 2026.11.10

The first change is the one the case needs first: a column that does not exist in the files already written. In a pipeline, that happens on an ordinary day. The pipeline starts stamping each load with its number, and the table already holds rows that predate the stamp. The setup writes the first three hours, each as its own commit, so the table holds three snapshots and three data files. An Iceberg snapshot is the table's state after a commit that changes data. Each append in this chapter adds one, and a schema change adds none.

In pyiceberg 0.12.0, you add a column inside a schema update. The call takes the name and the type, and the table assigns the field ID:

with table.update_schema() as update:
    update.add_column("load_batch", IntegerType())

To see what the add does to rows already on disk, commit hours 00 to 02, add the column, and append hours 03 to 05, each stamped with its hour number in load_batch. Counting rows by hour of the day splits the table at the add: hours 00 to 02 were written before it, and hours 03 to 05 after. Each hour is one write, so the split is also the split by load.

add-column-to-existing-files.py Python 3.12.15 · deltalake 1.6.6 · duckdb 2.0.0 · pyarrow 26.0.1 · pyiceberg 0.12.0 通过
"""Adds load_batch to a table that already holds three hours, in Iceberg and then in Delta Lake, and counts the nulls on each side of the add.Read the four "with load_batch null" lines, which show the rows before the add and the rows after it in each format."""import pyarrow as pafrom deltalake import DeltaTable, write_deltalakefrom deltalake.schema import Field, PrimitiveTypefrom pyiceberg.types import IntegerTypefrom lib.lakehouse import ICEBERG_ID, delta_file_count, iceberg_file_count, new_warehouse, read_cut_hour, read_delta, split_nullsdef stamp(rows, hour):    """Return one hourly load with load_batch set to that load's hour number."""    # int32 is the width IntegerType stores, so the Arrow column matches the Iceberg field    return rows.append_column("load_batch", pa.array([hour] * rows.num_rows, type=pa.int32()))with new_warehouse() as wh:    # the schema comes from hour 0, which has no load_batch yet    table = wh.catalog.create_table(ICEBERG_ID, schema=read_cut_hour(0).schema)    for hour in range(3):  # hours 00 to 02, each one commit, all written before the add        table.append(read_cut_hour(hour))    print(f"iceberg snapshots before the add: {len(table.snapshots())}")    print(f"iceberg data files before the add: {iceberg_file_count(table)}")    with table.update_schema() as update:        update.add_column("load_batch", IntegerType())    print(f"iceberg snapshots after the add: {len(table.snapshots())}")    print(f"iceberg data files after the add: {iceberg_file_count(table)}")    for hour in range(3, 6):  # hours 03 to 05, written after the add        table.append(stamp(read_cut_hour(hour), hour))    iceberg_rows = table.scan().to_arrow()    print(f"iceberg rows in the table: {iceberg_rows.num_rows}")    # the split is at 3, the first hour written after the add    split_nulls(wh.con, iceberg_rows, "iceberg", "load_batch", 3, sides=("written before the add", "written after the add"))    path = f"{wh.root}/delta/pageviews_hourly"    for hour in range(3):  # hours 00 to 02, appended as three versions before the add        write_deltalake(path, read_cut_hour(hour), mode="append")    print(f"delta version before the add: {DeltaTable(path).version()}")    print(f"delta data files before the add: {delta_file_count(DeltaTable(path))}")    DeltaTable(path).alter.add_columns([Field("load_batch", PrimitiveType("integer"))])    print(f"delta version after the add: {DeltaTable(path).version()}")    print(f"delta data files after the add: {delta_file_count(DeltaTable(path))}")    for hour in range(3, 6):  # hours 03 to 05, written after the add        write_deltalake(path, stamp(read_cut_hour(hour), hour), mode="append")    delta_rows = read_delta(path)    print(f"delta rows in the table: {delta_rows.num_rows}")    # the same split as the Iceberg half, at 3    split_nulls(wh.con, delta_rows, "delta", "load_batch", 3, sides=("written before the add", "written after the add"))
输出python add-column-to-existing-files.py
iceberg snapshots before the add: 3
iceberg data files before the add: 3
iceberg snapshots after the add: 3
iceberg data files after the add: 3
iceberg rows in the table: 2999
iceberg rows written before the add: 1499
iceberg rows written before the add with load_batch null: 1499
iceberg rows written after the add: 1500
iceberg rows written after the add with load_batch null: 0
delta version before the add: 2
delta data files before the add: 3
delta version after the add: 3
delta data files after the add: 3
delta rows in the table: 2999
delta rows written before the add: 1499
delta rows written before the add with load_batch null: 1499
delta rows written after the add: 1500
delta rows written after the add with load_batch null: 0

The add changes the metadata and no data file. The snapshot count stays at 3 across the schema change, and the table keeps its 3 data files.

The 1499 rows written before the add all read null for load_batch, and 0 of the 1500 rows written after it are null. The table holds 2999 rows in all.

Delta Lake, at deltalake 1.6.6, adds a column through its alter object. The call takes a field, and the table's version goes up by one:

DeltaTable(path).alter.add_columns([Field("load_batch", PrimitiveType("integer"))])

The Delta half follows the same sequence: three early hours as three appends, the add, then hours 03 to 05. The first write is version 0, and every version number this chapter prints is Delta's real one. The version moves from 2 to 3, and the table keeps its 3 data files.

Before the add there are 1499 rows, all null for load_batch. Once the three later appends are in, the table has 2999 rows, and 0 of the 1500 rows written after the add are null. This table has no column mapping, a point the Delta Lake rename section returns to.

Both formats give the same result for this case. The old rows stay as they were written, and the column reads as null for them. The writer did not have to touch a single old file. The two halves hold the same row counts and the same null counts, so a disagreement between them would point at a reader, not at the data.

Working rule: Add a column with the format's own call, and never by rewriting the files. Expect the rows written before the add to read null for the column, and check that they do.

这部分尚未翻译,因此以英文显示。

Old files read as null

最近一次修改见于版次 2026.11.7

A null in an added column can look like missing data, and a reader who sees it may assume the old files are wrong. They are not. The old files hold the values the pipeline wrote, and the column they lack is filled on read. The rule the reader follows is the one the columns section describes: with no initial-default, no value for the field means null.

That makes the null count a useful check. Count the nulls by hour, as the add example does, and they show the pattern to expect: every row written before the add is null, and no row written after it is. Iceberg has 1499 nulls among its 1499 earlier rows, and Delta Lake has 1499 among its 1499.

If a count falls outside that pattern, a writer sent a different set of columns, or sent the column with nulls, and the cause is in the pipeline, not in the format. Look at the writer for the rows that break the pattern before you query the column, because a query over a column that is partly null will return an answer that looks reasonable.

Working rule: After an add, count nulls in the added column by hour of the day, where each hour is one write. Rows written before the add should be null, and rows written after it should not be. Any other pattern means a writer sent a different set of columns, or sent nulls in the column, so find that writer before you trust the column.

这部分尚未翻译,因此以英文显示。

Rename a column by its ID without rewriting files

最近一次修改见于版次 2026.11.7

With the field ID in place, a rename is one call in Iceberg. The call changes the name the schema reports, and keeps the ID:

with table.update_schema() as update:
    update.rename_column("page_title", "article_title")

To check that the ID survives, write three hours, read the field ID of page_title, rename the column and read the ID again. The example also counts data files on both sides and queries DuckDB under the new name.

rename-by-id.py Python 3.12.15 · deltalake 1.6.6 · duckdb 2.0.0 · pyarrow 26.0.1 · pyiceberg 0.12.0 通过
"""Renames a column in an Iceberg table and reads the old files back under the new name.Read the field ID lines, the data file lines and the non-null count, which show what the rename kept."""import pyarrow as pafrom lib.lakehouse import (    ICEBERG_ID,    iceberg_file_count,    new_warehouse,    read_cut_hour,    scan_arrow,    snapshot_labels,    sql_rows,)with new_warehouse() as wh:    table = wh.catalog.create_table(ICEBERG_ID, schema=read_cut_hour(0).schema)    for hour in range(3):        table.append(read_cut_hour(hour))    before = table.schema().find_field("page_title").field_id  # the ID is what the reader matches on, not the name    print(f"page_title field ID before the rename: {before}")    print(f"data files before the rename: {iceberg_file_count(table)}")    with table.update_schema() as update:        update.rename_column("page_title", "article_title")    print(f"article_title field ID after the rename: {table.schema().find_field('article_title').field_id}")    print(f"data files after the rename: {iceberg_file_count(table)}")    rows = scan_arrow(table)    print(f"rows: {rows.num_rows}")    # count(column) leaves out nulls, so this counts the rows that have a value under the new name    count = sql_rows(wh.con, "SELECT count(article_title) FROM t", t=rows)[0][0]    print(f"article_title not null: {count}")    labels = snapshot_labels([snapshot.snapshot_id for snapshot in table.snapshots()])    first = table.snapshots()[0].snapshot_id  # the first snapshot, written before the rename    print(f"{labels[first]} columns: {', '.join(scan_arrow(table, snapshot_id=first).column_names)}")
输出python rename-by-id.py
page_title field ID before the rename: 3
data files before the rename: 3
article_title field ID after the rename: 3
data files after the rename: 3
rows: 1499
article_title not null: 1499
snapshot 1 columns: hour_utc, domain_code, page_title, views, response_bytes

The rename keeps the field ID. page_title has ID 3 before the call, and article_title has ID 3 after it.

The data file count is 3 before the call and 3 after it, so no file was rewritten. The DuckDB query counts 1499 non-null article_title values out of 1499 rows. Every row counts, including the rows written under page_title, because the reader matches the files by ID and reads them under the new name.

The dashboards need the name, and the table does not have to be rewritten to give it to them. The data stays as it was written, and the next read sees the renamed column. The run also prints the first snapshot's columns, which are hour_utc, domain_code, page_title, views and response_bytes. A snapshot reads with the schema it was written with, so an older snapshot still reports the old name. Chapter 2 covers reading older snapshots in general, and the point here is narrower: a rename does not reach back into the history.

The cost comparison is what makes this the right call for Iceberg. A rename that keeps the ID touches the metadata and nothing else, so its cost does not grow with the size of the table. The same rename done by copying the table costs one read and one write of every row. The section on Delta Lake shows what that copy costs in that format.

Working rule: Rename an Iceberg column when its name is wrong, and check the field ID before and after the call. The field ID must be the same, and the data file count must not change. Tell every reader of the table about the rename, because the current schema has only article_title, and an older snapshot still has page_title.

Delta Lake 在此版本下没有重命名

最近一次修改见于版次 2026.11.7

在 Delta Lake 中,同样的重命名在此版本下没有对应的调用。在 deltalake 1.6.6 中,Delta Lake 的表变更对象没有重命名方法,其方法列在该软件包中 [3]。看起来像重命名的是 set_column_metadata,因为它接受一个字段元数据字典,而且没有任何机制阻止你传入 name 键。传入 name 时,调用不会报错返回。无论表是否启用列映射,它都不会重命名任何内容,这正是本节要展示的陷阱。

该陷阱先创建一个启用了列映射的表,这是协议规定的重命名途径,然后发出该调用:

DeltaTable(path).alter.set_column_metadata("page_title", {"name": "article_title"})
delta-rename-trap.py Python 3.12.15 · deltalake 1.6.6 · duckdb 2.0.0 · pyarrow 26.0.1 · pyiceberg 0.12.0 通过
"""Calls set_column_metadata with a name key on a Delta Lake table with column mapping on, then reads the names back and queriesunder the new name. The columns read back line and the binder error are the lines to read."""from deltalake import DeltaTable, write_deltalakefrom lib.lakehouse import new_warehouse, read_cut_hour, read_delta, safe_error, sql_rowswith new_warehouse() as wh:    path = f"{wh.root}/delta/pageviews_hourly"    # column mapping on: the protocol's route to a rename, which this release does not offer as a call    write_deltalake(path, read_cut_hour(0),                    configuration={"delta.columnMapping.mode": "name"})    print(f"version before the rename: {DeltaTable(path).version()}")    # the call raises nothing and writes a commit, so the names read back below are the only check    DeltaTable(path).alter.set_column_metadata("page_title", {"name": "article_title"})    print("set_column_metadata returned")    table = DeltaTable(path)    print(f"version after the rename: {table.version()}")    page = next(field for field in table.schema().fields if field.name == "page_title")    # the name key the call wrote into the field's metadata, which the reader does not use for the column name    print(f"name in page_title metadata after the rename: {page.metadata['name']}")    print(f"columns read back: {', '.join(read_delta(path).column_names)}")    try:        sql_rows(wh.con, "SELECT article_title FROM t", t=read_delta(path))    except Exception as exc:        print(safe_error(exc, wh))
输出python delta-rename-trap.py
version before the rename: 0
set_column_metadata returned
version after the rename: 1
name in page_title metadata after the rename: article_title
columns read back: hour_utc, domain_code, page_title, views, response_bytes
BinderException: Binder Error: Referenced column "article_title" not found in FROM clause!
Candidate bindings: "page_title", "domain_code", "hour_utc", "views", "response_bytes"

LINE 1: SELECT article_title FROM t
               ^^^^^^^^^^^^^

调用返回后,表的版本从 0 变为 1,因此库写入了一次提交。name 键出现在字段的元数据中。但该列仍然是 page_title:通过库读回的列名是 hour_utc、domain_code、page_title、views 和 response_bytes。DuckDB 查询请求 article_title 时会失败,并抛出 BinderException,错误信息在它可以绑定的列中列出了 page_title。

陷阱在于,这个调用看起来像重命名,而且像重命名一样成功。返回值中没有任何内容表明名称未变,只有读取列名才能看到真实情况。

在此版本下,列映射也不能提供重命名。该陷阱的表将 delta.columnMapping.mode 设为 name,调用仍然没有改变任何名称。协议中关于列映射的一节描述了重命名 [2],但 deltalake 1.6.6 没有执行重命名的调用。

delta-rename-by-rewrite.py Python 3.12.15 · deltalake 1.6.6 · duckdb 2.0.0 · pyarrow 26.0.1 · pyiceberg 0.12.0 通过
"""Renames a Delta Lake column by overwriting the table with renamed data and schema, then reads the version before the rewrite back.Compare the two columns lines: the version before the rewrite, and the version the rewrite makes."""from deltalake import DeltaTable, write_deltalakefrom lib.lakehouse import new_warehouse, read_cut_hour, read_deltawith new_warehouse() as wh:    path = f"{wh.root}/delta/pageviews_hourly"    for hour in range(3):        write_deltalake(path, read_cut_hour(hour), mode="append")    print(f"data files before the rewrite: {len(DeltaTable(path).file_uris())}")    before = DeltaTable(path).version()  # read first, so the old version can be read back after the rewrite    print(f"version before the rewrite: {before}")    print(f"columns before the rewrite: {', '.join(read_delta(path, version=before).column_names)}")    # the new names, in the table's column order: only the third one changes    renamed = read_delta(path).rename_columns(["hour_utc", "domain_code", "article_title", "views", "response_bytes"])    # replace the data and the schema together, in one commit, so readers of the new version see both at once    write_deltalake(path, renamed, mode="overwrite", schema_mode="overwrite")    print(f"data files after the rewrite: {len(DeltaTable(path).file_uris())}")    after = DeltaTable(path).version()    print(f"version after the rewrite: {after}")    print(f"columns after the rewrite: {', '.join(read_delta(path).column_names)}")    print(f"rows after the rewrite: {read_delta(path).num_rows}")
输出python delta-rename-by-rewrite.py
data files before the rewrite: 3
version before the rewrite: 2
columns before the rewrite: hour_utc, domain_code, page_title, views, response_bytes
data files after the rewrite: 1
version after the rewrite: 3
columns after the rewrite: hour_utc, domain_code, article_title, views, response_bytes
rows after the rewrite: 1499

在此版本下,要得到新名称,办法是重写。重写示例通过库读取整张表,在内存中重命名该列,再用 mode="overwrite" 和 schema_mode="overwrite" 把结果写回,二者会同时替换数据和模式。重写前表有 3 个数据文件,重写后有 1 个。重写生成了版本 3,该版本读出的列名为 article_title,其中有 1499 行。

重写的代价与表的大小成正比,因为每一行都要被重新读取并重新写入。这里的表很小,但拥有数百万行的生产表要付出同样的逐行代价,因此团队应把重写当作一项单独的作业来规划。重写之前的版本 2 读出的列名仍然是 page_title,示例也会打印这一点。因此,重写只改变当前版本,旧版本保留写入时的名称。在执行重写之前,先列出按名称请求该列的读取方。切换在一次提交中完成,所以当前版本的所有读取方会在同一时刻切换,而固定在旧版本上的作业仍使用旧名称。应让这些作业与读取方一同迁移,并在迁移完成之前记录被重写替换的版本号。

工作准则: 在创建表时就确定 Delta Lake 的列名,因为在此版本下,事后重命名就是重写整张表。不要用 set_column_metadata 重命名列:它会改变版本和元数据,而列仍保留原名。在任何模式变更之后,都要像陷阱示例那样通过库读回列名,并在查询依赖这些列名之前加以核对。

生产环境中会出什么问题

最近一次修改见于版次 2026.11.7

模式变更悄无声息地失败,比报错失败更常见,而下面每一种失败都有可以观察的迹象。

先看空操作式的重命名。set_column_metadata 调用成功,历史中出现了一次提交,但列仍然沿用旧名称。失败在第一次使用 article_title 的查询中显现:DuckDB 查询失败,并抛出 BinderException。定时作业若运行这样的查询,会在变更后的第一次运行时失败,因此错误出现的时间与其原因很接近。

接下来是历史中的过期名称。重写会让当前版本使用名称 article_title,但更早的版本保留写入时所用的名称,重写示例就说明了这一点:版本 2 读到的仍是 page_title。Iceberg 快照的情形相同:第一个快照报告的仍是 page_title。若查询按 article_title 读取更早的版本或快照,会发现没有这样的列。按版本号或快照号读取时,需要使用当时有效的名称,因此固定了版本号的作业,同时也固定了它的模式。

第三是看起来像数据缺失的空值。新增的列在添加之前写入的每一行中都读作空值。该列的空值计数是正确的,只有当它偏离添加示例所示的前后模式时,才属于故障。应按小时统计空值,如添加示例所做的那样,并调查任何打破该模式的行。

最后是不会出现在快照列表中的模式变更。Iceberg 的添加列和重命名列操作都没有改变快照数量,文件数量也未变。通过统计快照数量来查找模式变更的工具会漏掉它们。需要了解发生了什么变化时,应比较模式本身,即按字段 ID 和名称比较。

工作准则: 任何模式变更之后,在下游查询运行之前做三件事:通过库读回列名;按小时统计每个新增列中的空值数量,其中每个小时对应一次写入;将模式(而不是快照数量)与此次变更的预期效果进行比较。

本章的决定

本节的表格针对本章中的各项变更,将两种格式并列比较。每个单元格都来自本章的一个示例。

变更 Iceberg Delta Lake
添加列 可行。旧行读取为 null,快照数量保持为 3 可行。旧行读取为 null,版本号加一
重命名列 可行。字段 ID 保持不变,不重写任何数据文件 没有重命名调用。set_column_metadata 会提交,但不改变任何名称;只有重写才能得到新名称
读取较早的快照或版本 显示旧名称 显示旧名称
  • 在两种格式中,都可以向已有数据的表添加列。旧行读取该列时为 null,添加示例给出了按小时统计的数量,可以印证这一规律。我们推荐这种做法,而不是复制整张表,因为它不会写入任何旧文件。
  • 使用 rename_column 重命名 Iceberg 列,并检查其字段 ID 在前后是否一致。对于任何名称有误的 Iceberg 列,我们都推荐这种做法,因为它的代价与表的大小无关。
  • 在创建表时就选定 Delta Lake 的列名。在固定的版本上,Delta Lake 中的重命名等于重写整张表,名称有误时需要按这一代价来规划。
  • 不要用 set_column_metadata 重命名 Delta Lake 列。该调用会成功,但不会改变名称。
  • 在此固定版本上,不要指望用列映射来完成重命名。该库没有执行重命名的调用,因此开启映射并不能带来重命名。
  • 每次变更模式之后,在两种格式中都要回读列名,然后再让查询依赖这些列名。

这部分尚未翻译,因此以英文显示。

Sources

最近一次修改见于版次 2026.11.7
  1. Apache Iceberg Table Spec, Schema Evolution (Column Projection), https://iceberg.apache.org/spec/, read Nov 6, 2026. Quoted: "Renaming an existing field must change the name, but not the field ID." The null rule, which the text paraphrases, is in the same section.
  2. Delta Transaction Log Protocol, Column Mapping section, tag v4.4.1, https://raw.githubusercontent.com/delta-io/delta/v4.4.1/PROTOCOL.md, read Nov 6, 2026. Quoted: "the renaming and dropping of columns without having to rewrite all the data."
  3. deltalake 1.6.6, the methods of DeltaTable.alter in the installed package: add_columns, add_constraint, add_feature, drop_column_not_null, drop_constraint, set_column_metadata, set_table_description, set_table_name and set_table_properties. None renames a column. To list them, run dir(DeltaTable(path).alter).

本章,在本版次中

版次 2026.11.10示例于 2026年11月20日 通过本章 4个示例 个示例中有 4 个通过

译自英文版图书,版次 2026.11.10。

引用本节

格式

每种格式均引用英文原书,本译本以其为准。

每种格式都会注明该版次。其链接会打开当前版次,节标题处会说明该节文本最后一次修改的时间。访问日期和检索日期即为您打开此页的当天。

本页内容

第 3 章,共 10 章: 添加和重命名列而无需重写文件

  1. 列按 ID 跟踪
  2. Add load_batch after three hours
  3. Old files read as null
  4. Rename a column by its ID without rewriting files
  5. Delta Lake 在此版本下没有重命名
  6. 生产环境中会出什么问题
  7. 本章的决定
  8. Sources

返回顶部全部章节