SSMS 表格模型:通过一个 xmla 脚本创建多个分区

SSMS Tabular Model: create multiple partition via one single xmla script

我需要通过 SSMS 使用 XMLA 脚本运行创建大量分区。
有没有办法将多个分区的创建合并到一个脚本中。

在下面的例子中,我需要执行第一个脚本。完成后,我可以打开另一个脚本并执行它。很费时间。

我怎样才能将代码重组为 运行 它只执行一次?

脚本 1:

  "createOrReplace": {
    "object": {
      "database": "MYDB",
      "table": "MYTABLE1",      "partition": "Partition"
    },
    "partition": {
      "name": "Process_OLD",      "dataView": "full",
      "source": {
        "type": "m",
        "expression": [
          "let",
          "    Source = #\"mySQL/MY_SCHEMA\",",          "    MY_SCHEMA= Source{[Schema=\"MY_SCHEMA\"]}[Data],",
          "    AllData = MY_SCHEMA{[Name=\"MYTABLE1\"]}[Data],",          "\t#\"Filtered Rows\" = Table.SelectRows(AllData, each  [DATE]  < 20170101)",
          "in",
          "    #\"Filtered Rows\""
        ]
      }
    }
  }
}

脚本 2:

  "createOrReplace": {
    "object": {
      "database": "MYDB",
      "table": "MYTABLE2",      "partition": "Partition"
    },
    "partition": {
      "name": "Process_NEW",      "dataView": "full",
      "source": {
        "type": "m",
        "expression": [
          "let",
          "    Source = #\"mySQL/MY_SCHEMA\",",          "    MY_SCHEMA= Source{[Schema=\"MY_SCHEMA\"]}[Data],",
          "    AllData = MY_SCHEMA{[Name=\"MYTABLE1\"]}[Data],",          "\t#\"Filtered Rows\" = Table.SelectRows(AllData, each  [DATE]  >= 20170101)",
          "in",
          "    #\"Filtered Rows\""
        ]
      }
    }
  }
}

您可以在其周围放置一个 sequence 命令:

{
  "sequence": {
    "operations": [
      {
        "createOrReplace": {
          "object": {
            "database": "MYDB",
            "table": "MYTABLE1",
            "partition": "Partition"
          },
          "partition": {
            "name": "Process_OLD",
            "dataView": "full",
            "source": {
              "type": "m",
              "expression": [
                "let",
                "    Source = #\"mySQL/MY_SCHEMA\",",
                "    MY_SCHEMA= Source{[Schema=\"MY_SCHEMA\"]}[Data],",
                "    AllData = MY_SCHEMA{[Name=\"MYTABLE1\"]}[Data],",
                "\t#\"Filtered Rows\" = Table.SelectRows(AllData, each  [DATE]  < 20170101)",
                "in",
                "    #\"Filtered Rows\""
              ]
            }
          }
        }
      },
      {
        "createOrReplace": {
          "object": {
            "database": "MYDB",
            "table": "MYTABLE2",
            "partition": "Partition"
          },
          "partition": {
            "name": "Process_NEW",
            "dataView": "full",
            "source": {
              "type": "m",
              "expression": [
                "let",
                "    Source = #\"mySQL/MY_SCHEMA\",",
                "    MY_SCHEMA= Source{[Schema=\"MY_SCHEMA\"]}[Data],",
                "    AllData = MY_SCHEMA{[Name=\"MYTABLE1\"]}[Data],",
                "\t#\"Filtered Rows\" = Table.SelectRows(AllData, each  [DATE]  >= 20170101)",
                "in",
                "    #\"Filtered Rows\""
              ]
            }
          }
        }
      }
    ]
  }
}