# Table is

对于 Excel、XML、Parquet 或 JSON 文件，可以在表格式说明符中指定要从中加载数据的表。

语法：

Table is table name

参数：

参数

| 参数 | 描述 |
| --- | --- |
| table name | 指定表的名称。该值取决于表格式：<br><br><ul> <li> <p>Excel：工作表名称。</p> </li> <li> <p>XML：指定要加载的 XML 部分的路径。</p> </li> <li> <p>Parquet：指定表的路径，格式为 <span>&lt;node&gt;.&lt;node&gt;.&lt;node&gt;</span>。 </p> <p>在嵌套结构中指定表时使用 <span>Table  is</span>。</p> <p>例如，您有以下模式中的 Parquet 数据：</p> <pre><code>Schema:Field(name: "Name", datatype: String),Field(name: "Age", datatype: Float),Field(name: "Phone", datatype: List(	Field(name: "Item", datatype: Struct[    	Field(name: "Number", datatype: String)</code></pre> <p>您可以将 Phone 及其嵌套字段加载为带有参数 <code>Table is [Schema:Phone.Item]</code> 的表。这将与表一起生成关键字段 <span>%Key_Phone</span>。</p> </li> <li> <p>JSON：在带数组的 JSON 文件中，子表迭代器的路径。</p> <p>您可以通过指定<span>所有表</span>而不是 <span>Table is</span> 来加载所有表。例如：</p> <pre><code>LOAD&nbsp;*&nbsp;FROM&nbsp;[lib://DataFiles/Sales.json] (json, all tables);</code></pre> <p>如果您的数据包含多个内容相同的数组，请在子表 LOAD 语句中使用关键字 <span>DISTINCT</span>。例如：</p> <pre><code>LOAD&nbsp;DISTINCT&nbsp;*&nbsp;FROM [lib://DataFiles/Sales.json] (json, all tables);</code></pre> </li> </ul> |

示例： Excel

LOAD "Item Number", "Product Group", "Product Line", "Product Sub Group", "Product Type" FROM [lib://AttachedFiles/Item master.xlsx] (ooxml, embedded labels, table is [Item master]);

示例： 数据截断，

LOAD city%Table, %Key\_row\_7FAC1F878EC01ECB FROM [lib://AttachedFiles/cities.xml] (XmlSimple, table is [root/row/country/city]);

示例： Parquet

文件 company.parquet 包含以下模式：

company (String) contact (String) company:salesrep (List) salesrep (Group) salesrep (String) company:headquarter (List) headquarter (Group) country (String) city (String) city:region (List) region (Group) region (String)

以下操作将把文件中的内容加载到表中。第一个 LOAD 语句加载根组。第二个 LOAD 语句将 salesrep 组的内容加载为一个表。第三个 LOAD 语句将总部组加载为一个表。第四个 LOAD 语句将地区组加载为表。

LOAD \* FROM […] (parquet); LOAD \* FROM […] (parquet, table is [company:salesrep.salesrep]); LOAD \* FROM […] (parquet, table is [company:headquarter.headquarter] LOAD \* FROM […] (parquet, table is [company:headquarter.headquarter.city:region.region]

示例： JSON

LOAD customers.customerid, customers.companyname, customers.contactname, customers.contacttitle, customers.address, customers.city, customers.postalcode, customers.country, customers.phone, customers.fax, %Key\_customers, customers.region FROM [lib://DataFiles/example.json] (json, table is [/\*/customers]);

限制：

Table is 说明符仅对 Excel、XML、Parquet、JSON 文件相关。