lance.LanceDataset.delete(predicate: str | 表达式)

从数据集中删除行。

这会将行标记为已删除,但不会从文件中物理移除它们。这样可以保持现有索引仍然有效。

Parameters:
predicate : str or pa.compute.Expression

用于选择要删除行的谓词。可以是SQL字符串或pyarrow表达式。

示例

>>> import lance
>>> import pyarrow as pa
>>> table = pa.table({"a": [1, 2, 3], "b": ["a", "b", "c"]})
>>> dataset = lance.write_dataset(table, "example")
>>> dataset.delete("a = 1 or b in ('a', 'b')")
>>> dataset.to_table()
pyarrow.Table
a: int64
b: string
----
a: [[3]]
b: [["c"]]