.create ingestion mapping

创建可与特定格式和特定表或数据库关联的引入映射。

语法

.createtableTableNameingestionMappingKindmappingMappingNameMappingFormattedAsJson

.createdatabaseDatabaseNameingestionMappingKindmappingMappingNameMappingFormattedAsJson

注意

  • 创建映射后,可在引入命令中按名称引用映射,而不必将完整映射指定为命令的一部分。
  • MappingKind 的有效值为:CSVJSONavroparquetorc
  • 如果该表已经存在相同名称的映射:
    • .create 将失败
    • .create-or-alter 将更改现有映射
  • 如果在表范围和数据库范围中创建了同名的映射,则表范围中的映射将具有更高的优先级。
  • 在将数据引入到表中并引用其架构与所引入的表架构不匹配的映射时,引入操作将失败。

示例

.create table MyTable ingestion csv mapping "Mapping1"
'['
'   { "column" : "rownumber", "DataType":"int", "Properties":{"Ordinal":"0"}},'
'   { "column" : "rowguid", "DataType":"string", "Properties":{"Ordinal":"1"}}'
']'

.create-or-alter table MyTable ingestion json mapping "Mapping1"
'['
'    { "column" : "rownumber", "datatype" : "int", "Properties":{"Path":"$.rownumber"}},'
'    { "column" : "rowguid", "Properties":{"Path":"$.rowguid"}}'
']'

.create database MyDatabase ingestion csv mapping "Mapping2"
'['
'   { "column" : "rownumber", "DataType":"int", "Properties":{"Ordinal":"0"}},'
'   { "column" : "rowguid", "DataType":"string", "Properties":{"Ordinal":"1"}}'
']'

示例输出

名称 种类 映射
mapping1 CSV [{"Name":"rownumber","DataType":"int","CsvDataType":null,"Ordinal":0,"ConstValue":null},{"Name":"rowguid","DataType":"string","CsvDataType":null,"Ordinal":1,"ConstValue":null}]
mapping2 CSV [{"Name":"rownumber","DataType":"int","CsvDataType":null,"Ordinal":0,"ConstValue":null},{"Name":"rowguid","DataType":"string","CsvDataType":null,"Ordinal":1,"ConstValue":null}]

示例:创建包含转义符的引入映射

.create table test_table ingestion json mapping "test_mapping_name"
'['
'{"column":"timeStamp","path":"$[\'timeStamp\']","datatype":"","transform":null},{"column":"name","path":"$[\'name\']","datatype":"","transform":null},{"column":"x-opt-partition-key","path":"$[\'x-opt-partition-key\']","datatype":"","transform":null}'
']'

后续步骤

有关引入映射的详细信息,请参阅数据映射