lance.LanceDataset.update(更新: dict[str, str], where: str | None = None) UpdateResult

更新符合where条件的行的列值。

Parameters:
updates : dict of str to str

列名到SQL表达式的映射关系。

where : str, optional

一个SQL谓词,指示应更新哪些行。

Returns:

updates – 包含更新行数的字典。

Return type:

字典

示例

>>> import lance
>>> import pyarrow as pa
>>> table = pa.table({"a": [1, 2, 3], "b": ["a", "b", "c"]})
>>> dataset = lance.write_dataset(table, "example")
>>> update_stats = dataset.update(dict(a = 'a + 2'), where="b != 'a'")
>>> update_stats["num_updated_rows"] = 2
>>> dataset.to_table().to_pandas()
   a  b
0  1  a
1  4  b
2  5  c