.replace extents 命令

適用於: ✅Azure 數據總管

此命令會在特定資料庫內容內的單一交易中卸除和移動範圍。 此命令會從目的地數據表卸除任何指定的範圍,並將指定的範圍從源數據表移至目的地數據表。

注意

數據分區稱為 範圍,所有命令都會使用「範圍」或「範圍」做為同義字。 如需範圍的詳細資訊,請參閱 範圍(數據分區)概觀

權限

您必須至少有 來源和目的地數據表的數據表管理員 許可權。

限制

  • 來源和目的地數據表都必須位於內容資料庫中。
  • ExtentsToDropQuery指定的所有範圍都應該屬於目的地數據表。
  • 源數據表中的所有數據行應該都存在於具有相同名稱和數據類型的目的地數據表中。
  • 如果目的地數據表是具體化檢視源數據表,命令可能會失敗,因為具體化檢視無法處理移動範圍中的記錄。 如需詳細數據, 請參閱具體化檢視限制 頁面。 您可以在移動命令期間設定新的擷取時間,解決此錯誤。 請參閱setNewIngestionTime支持的屬性

語法

.replace[async] extents table in DestinationTableName [ with(PropertyName = PropertyValue [, ...]] <|{)ExtentsToDropQuery},{ExtentsToMoveQuery}

深入瞭解 語法慣例

參數

姓名 類型​​ 必要 描述
async string 如果指定,命令會以異步方式執行。
DestinationTableName string ✔️ 要移動範圍之數據表的名稱。
FromDate datetime 查詢視窗開始日期。
ToDate datetime 查詢窗口結束日期。
PropertyNamePropertyValue string 一或多個 支持的屬性
ExtentsToDropQuery string ✔️ 此查詢的結果必須包含 ExtentId 數據行,其中包含要從目的地數據表移除的範圍標識碼。
ExtentsToMoveQuery string ✔️ 此查詢的結果必須包含 ExtentIdTableName 數據行,其中包含源數據表和要移至目的地數據表的範圍標識元。

支援的屬性

屬性名稱 類型 必要 描述
setNewIngestionTime bool 如果設定為 true,則會將新的 擷取時間 指派給移動範圍中的所有記錄。 當相依於 資料庫數據指標的工作負載處理記錄時,這非常有用,例如 具體化檢視連續數據匯出
extentCreatedOnFrom datetime ✔️ 套用在此時間點之後所建立的範圍。
extentCreatedOnTo datetime ✔️ 適用於在此時間點之前建立的範圍。

注意

為了提升效能,請將 extentCreatedOnFrom 和 extentCreatedOnTo 參數設定為最小的可能範圍。

傳回

當命令以同步方式執行時,會傳回具有下列架構的數據表。

輸出參數 類型 描述
OriginalExtentId string 源數據表中已移至目的地數據表之原始範圍的唯一標識碼 (GUID),或卸除之目的地數據表中的範圍。
ResultExtentId string 結果範圍的唯一標識碼 (GUID) 會從源數據表移至目的地數據表。 如果從目的地數據表卸除範圍,則為空白。 失敗時:「失敗」。
詳細資料 string 如果作業失敗,則包含失敗詳細數據。

當命令以異步方式執行時,會傳回作業標識碼 (GUID)。 使用 .show operations 命令監視作業的狀態,並使用 .show 作業詳細數據命令擷取成功執行的結果。

注意

如果 ExtentsToDropQuery 查詢傳回的範圍不存在於目的地數據表中,此命令將會失敗。 如果在執行 replace 命令之前合併範圍,就可能會發生這種情況。 若要確定遺漏範圍上的命令失敗,請檢查查詢是否傳回預期的ExtentId。 如果卸除的範圍不存在於數據表 MyOtherTable 中,第一個範例將會失敗。 不過,即使卸除的範圍不存在,第二個範例還是會成功,因為要卸除的查詢不會傳回任何範圍標識符。

範例

從兩個數據表移動指定建立時間範圍中的所有範圍

將指定建立時間範圍中的所有範圍從兩個特定資料表 (MyTable1MyTable2) 移至資料表 MyOtherTable,然後卸除以drop-by:MyTag標記的所有範圍MyOtherTable

.replace extents in table MyOtherTable with (extentCreatedOnFrom=datetime(2023-03-10), extentCreatedOnTo=datetime(2023-03-12)) <|
    {
        .show table MyOtherTable extents where tags has 'drop-by:MyTag'
    },
    {
        .show tables (MyTable1,MyTable2) extents
    }

範例輸出

OriginalExtentId ResultExtentId 詳細資料
e133f050-a1e2-4dad-8552-1f5cf47cab69 0d96ab2d-9dd2-4d2c-a45e-b24c65aa6687
cdbeb35b-87ea-499f-b545-defbae091b57 a90a303c-8a14-4207-8f35-d8ea94ca45be
4fcb4598-9a31-4614-903c-0c67c286da8c 97aafea1-59ff-4312-b06b-08f42187872f
2dfdef64-62a3-4950-a130-96b5b1083b5a 0fb7f3da-5e28-4f09-a000-e62eb41592df

將指定建立時間範圍中的所有範圍從一個數據表移至另一個數據表,卸除特定範圍

將指定建立時間範圍中的所有範圍從一個特定資料表 (MyTable1) 移至資料表 MyOtherTable,然後依標識元卸除 中的 MyOtherTable特定範圍:

.replace extents in table MyOtherTable with (extentCreatedOnFrom=datetime(2023-03-10), extentCreatedOnTo=datetime(2023-03-12)) <|
    {
        print ExtentId = "2cca5844-8f0d-454e-bdad-299e978be5df"
    },
    {
        .show table MyTable1 extents 
    }
.replace extents in table MyOtherTable with (extentCreatedOnFrom=datetime(2023-03-10), extentCreatedOnTo=datetime(2023-03-12)) <|
    {
        .show table MyOtherTable extents
        | where ExtentId == guid(2cca5844-8f0d-454e-bdad-299e978be5df) 
    },
    {
        .show table MyTable1 extents 
    }

實作等冪邏輯

實作等冪邏輯,讓 Kusto 只有在有範圍從數據表移至數據表t_dest時,才會從數據表t_destt_source卸除範圍:

.replace async extents in table t_dest with (extentCreatedOnFrom=datetime(2023-03-10), extentCreatedOnTo=datetime(2023-03-12)) <|
{
    let any_extents_to_move = toscalar( 
        t_source
        | where extent_tags() has 'drop-by:blue'
        | summarize count() > 0
    );
    let extents_to_drop =
        t_dest
        | where any_extents_to_move and extent_tags() has 'drop-by:blue'
        | summarize by ExtentId = extent_id()
    ;
    extents_to_drop
},
{
    let extents_to_move = 
        t_source
        | where extent_tags() has 'drop-by:blue'
        | summarize by ExtentId = extent_id(), TableName = 't_source'
    ;
    extents_to_move
}