Azure 数据资源管理器更新记录

发布于 2025-01-12 13:12:43 字数 264 浏览 5 评论 0原文

我是 Azure 数据资源管理器的新手,我想知道如何使用 C# 中的 microsoft .NET SDK 更新 Azure 数据资源管理器中的记录?

Microsoft 文档 真的很差

我们可以更新还是你只能替换一行或者你?

I am new to Azure data explorer and I am wondering how you can do update on a record in Azure data explorer using microsoft .NET SDK in C# ?

The Microsoft documentation is really poor

Can we update or you can replace a row only or you?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

微暖i 2025-01-19 13:12:43

您可以使用软删除 删除原始记录,然后追加/提取更新的记录。

请注意,这不是原子的,这意味着如果有人在软删除和追加操作之间查询表,他们既不会看到旧记录,也不会看到更新的记录。

You can use soft-delete to delete the original record, and then append/ingest the updated record.

Please note that this won't be atomic, meaning if someone queries the table between the soft-delete and the append operations, they won't see neither the old record, nor the updated record.

筱果果 2025-01-19 13:12:43

Azure 数据资源管理器中没有记录“更新”机制,即使“软删除”也会删除并替换该行。这对于一次性场景很有用,并且可能不值得用另一种语言实现,因为它不应该经常使用。正如软删除文档所述,如果您打算经常更新数据,Materialize 可能是更好的选择。

Materialize 需要更多的工作和抽象,如果您有一个非常大的表,并且依赖像 ingestion_time 这样的元数据信息来理解记录,那么通常是值得付出努力的。

在较小的表中(例如,小于一个演出),我建议使用简单的方法,将表替换为其自身的更新版本(只要确保如果您确实依赖于像 ingestion_time 这样的字段,则可以更新架构并将该数据扩展为字段供以后使用)。

您将需要查询整个表,实现仅隔离感兴趣的行(同时保留所有其他行)的逻辑,并执行扩展函数来修改该值。然后,替换(不追加)整个表。

例如:
.set-or-replace MyTable1 <|
我的表1
|扩展 In CorrectColumn = iif(In CorrectColumn == "in CorrectValue", "CorrectValue", In CorrectColumn)

或者,您可以将不变的相关数据和更新的数据放在两个表格结果中,并将它们进行并集以形成最终表格。

.set-or-replace MyTable1 <|
让更新行=
我的表1
|其中 Column1 =“错误值”
|扩展Column1 =“正确值”;
让非更新行=
我的表1
|其中 Column1 =“正确值”;
更新行
| union nonUpdatedRows

我更喜欢写入临时表,仔细检查数据质量,然后替换最终表。如果您正在批量工作并且希望在批量中途出现故障时最大程度地降低数据丢失的风险,这尤其有用

there is no record "update" mechanism in Azure Data Explorer, even the 'soft delete' removes and replaces the row. this is useful for one-off scenarios, and may not be worth implementing in another language since it should not be used frequently. as the soft delete documentation says, if you plan to update data often, materialize may be a better option.

materialize is a bit more work and abstract, generally being worth the effort if you have a very large table that relies on metadata information like ingestion_time to make sense of records.

in smaller tables (say, less than a gig) i recommend the simple approach of replacing the table with an updated version of itself (just make sure that if you do rely on fields like ingestion_time, you update the schema and extend that data as a field for later use).

You will need to query for the entire table, implement logic for isolating only the row(s) of interest (while retaining all others, and perform an extend function to modify that value. Then, replace (do not append) the entire table.

For example:
.set-or-replace MyTable1 <|
MyTable1
| extend IncorrectColumn = iif(IncorrectColumn == "incorrectValue", "CorrectValue", IncorrectColumn)

alternatively, you can have the unchanging relevant data and updated data in two tabular results, and perform a union on them to form the final table.

.set-or-replace MyTable1 <|
let updatedRows =
MyTable1
| where Column1 = "IncorrectValue"
| extend Column1 = "CorrectValue";
let nonUpdatedRows =
MyTable1
| where Column1 = "CorrectValue";
updatedRows
| union nonUpdatedRows

I prefer to write to a temp table, double check the data quality, then replace the final table. This is particularly useful if you're working in batches and want to minimize the risk of data loss if there's a failure halfway through your batches

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文