Share via


Partitions 物件 (TMSL)

適用于:SQL Server 2016 和更新版本的 Analysis Services Azure Analysis Services Fabric/Power BI Premium

定義資料表資料列集的資料分割或邏輯分割。 分割區包含用於匯入資料的Power Query M 或 SQL 查詢、模型化環境中的範例資料,或作為透過 DirectQuery 傳遞查詢執行的完整資料查詢。

資料分割上的屬性會決定資料表的資料來源。 在物件階層中,資料分割的父物件是資料表物件。

物件定義

所有物件都有一組通用的屬性,包括名稱、類型、描述、屬性集合和批註。 資料分割 物件也有下列屬性。

類型
資料分割的類型。 有效值為數值,並包含下列專案:

  • 查詢 (1) – 此分割區中的資料是藉由對 DataSource執行查詢來擷取。 DataSource必須是 model.bim 檔案中定義的資料來源。

  • 計算 (2) – 此分割區中的資料會藉由執行匯出運算式來填入。

  • 無 (3) – 此分割區中的資料會藉由將資料列集推送至伺服器作為重新整理作業的一部分來填入。

mode
定義資料分割的查詢模式。 有效值為 importDirectQuery預設 (繼承) 。 這是必要的值。

Description
匯入 指出針對儲存匯入資料的記憶體內部分析引擎發出查詢要求。
DirectQuery 將查詢執行傳遞至外部關係資料庫。 DirectQuery 模式會使用分割區來提供模型設計期間所使用的範例資料。 在生產伺服器上部署時,您應該切換回 [完整資料] 檢視。 回想一下,DirectQuery 模式需要每個資料表一個資料分割,每個模型都需要一個資料來源。
預設值 如果您想要在模型或資料庫層級上,將模式切換為較高的物件樹狀結構,請設定此設定。 當您選擇預設值時,查詢模式會是匯入或 DirectQuery。

來源
識別要查詢的資料位置。 有效值為 query、calculatednone。 這是必要的值。

描述
用於匯入模式,其中資料會載入並儲存在記憶體中。
查詢 針對 DirectQuery 模式,這是針對模型 DataSource中指定的關係資料庫執行的 SQL 查詢。 請參閱 DataSources 物件 (TMSL)
計算 匯出資料表是從建立資料表時所指定的運算式來源。 此運算式會被視為為匯出資料表建立的資料分割來源。

dataview
針對 DirectQuery 資料分割,其他 dataView 屬性會進一步指定擷取資料的查詢是範例或完整資料集。 有效值為 完整範例預設 (繼承) 。 如前所述,範例只會在資料模型化和測試期間使用。

使用方式

分割區物件用於 Alter 命令 (TMSL) Create 命令 (TMSL) CreateOrReplace 命令 (TMSL ) 、 Delete 命令 (TMSL ) 、 Refresh 命令 (TMSL) MergePartitions 命令 (TMSL)

建立、取代或改變數據分割物件時,請指定物件定義的所有讀寫屬性。 省略讀寫屬性會被視為刪除。 讀寫屬性包括名稱、描述、模式和來源。

範例

範例 1 - 資料表的簡單分割結構, (不是事實資料表) 。

"partitions": [  
          {  
            "name": "Customer",  
            "source": {  
              "query": "SELECT [dbo].[Customer].* FROM [dbo].[Customer]",  
              "dataSource": "SqlServer localhost FoodmartDB"  
            }  
]  

範例 2 - 資料分割事實資料通常是以 WHERE 子句為基礎,該子句會針對相同資料表的資料建立非重迭的資料分割。

"partitions": [  
          {  
            "name": "sales_fact_2015",  
            "source": {  
              "query": "SELECT [dbo].[sales_fact_2015].* FROM [dbo].[sales_fact_2015] WHERE [dbo].[sales_fact_2015].[Quarter]=4",                                                                                          
              "dataSource": "SqlServer localhost FoodmartDB"  
            },  
          }  
        ]  

範例 3 - 以 DAX 運算式為基礎的匯出資料表。

"partitions": [  
          {  
            "name": "CalcTable1",  
            "source": {  
              "type": "calculated",  
              "expression": "'Product Class'"  
            },  
            }  
]  

完整語法

以下是資料分割物件的架構表示。

"partitions": {  
                "type": "array",  
                "items": {  
                  "description": "Partition object of Tabular Object Model (TOM)",  
                  "type": "object",  
                  "properties": {  
                    "name": {  
                      "type": "string"  
                    },  
                    "description": {  
                      "anyOf": [  
                        {  
                          "type": "string"  
                        },  
                        {  
                          "type": "array",  
                          "items": {  
                            "type": "string"  
                          }  
                        }  
                      ]  
                    },  
                    "mode": {  
                      "enum": [  
                        "import",  
                        "directQuery",  
                        "default"  
                      ]  
                    },  
                    "dataView": {  
                      "enum": [  
                        "full",  
                        "sample",  
                        "default"  
                      ]  
                    },  
                    "source": {  
                      "anyOf": [  
                        {  
                          "description": "QueryPartitionSource object of Tabular Object Model (TOM)",  
                          "type": "object",  
                          "properties": {  
                            "type": {  
                              "enum": [  
                                "query",  
                                "calculated",  
                                "none"  
                              ]  
                            },  
                            "query": {  
                              "anyOf": [  
                                {  
                                  "type": "string"  
                                },  
                                {  
                                  "type": "array",  
                                  "items": {  
                                    "type": "string"  
                                  }  
                                }  
                              ]  
                            },  
                            "dataSource": {  
                              "type": "string"  
                            }  
                          },  
                          "additionalProperties": false  
                        },  
                        {  
                          "description": "CalculatedPartitionSource object of Tabular Object Model (TOM)",  
                          "type": "object",  
                          "properties": {  
                            "type": {  
                              "enum": [  
                                "query",  
                                "calculated",  
                                "none"  
                              ]  
                            },  
                            "expression": {  
                              "anyOf": [  
                                {  
                                  "type": "string"  
                                },  
                                {  
                                  "type": "array",  
                                  "items": {  
                                    "type": "string"  
                                  }  
                                }  
                              ]  
                            }  
                          },  
                          "additionalProperties": false  
                        }  
                      ]  
                    },  
                    "annotations": {  
                      "type": "array",  
                      "items": {  
                        "description": "Annotation object of Tabular Object Model (TOM)",  
                        "type": "object",  
                        "properties": {  
                          "name": {  
                            "type": "string"  
                          },  
                          "value": {  
                            "anyOf": [  
                              {  
                                "type": "string"  
                              },  
                              {  
                                "type": "array",  
                                "items": {  
                                  "type": "string"  
                                }  
                              }  
                            ]  
                          }  
                        },  
                        "additionalProperties": false  
                      }  
                    }  
                  },  
                  "additionalProperties": false  
                }  
              },