将具有不同字段的不同csv导入ADX表

时间:2019-07-17 06:39:27

标签: azure-data-explorer

想知道是否可以将具有不同数量/类型的字段的多个CSV摄取到一个ADX表中吗? (请参阅下面的csv示例)

对我来说,可以使用csv的标头作为字段吗?


CSV类型示例:

类型A

+--------+-----+--------+
| Name   | Age | Uni    |
+--------+-----+--------+
| Hazriq | 27  | UNITEN |
+--------+-----+--------+

类型B

+------+------+-----+
| Name | Uni  | Age |
+------+------+-----+
| John | UNIx | 31  |
+------+------+-----+

类型C

+------+------+--------------+-----+
| Name | Uni  | Hometown     | Age |
+------+------+--------------+-----+
| Jane | UNIt | Kuala Lumpur | 31  |
+------+------+--------------+-----+

1 个答案:

答案 0 :(得分:0)

是的,您可以创建多个CSV映射并为给定文件提供适用的映射。您不能使用CSV标头。这是一个示例:

.create table demo(name:string, age:int, uni:string, hometown:string)

//define the mappings
.create table demo ingestion csv mapping "typeA" '[{"Name":"name", "Ordinal":0}, {"Name":"age", "Ordinal":1}, {"Name":"uni", "Ordinal":2}]'

.create table demo ingestion csv mapping "typeB" '[{"Name":"name", "Ordinal":0}, {"Name":"uni", "Ordinal":1}, {"Name":"age", "Ordinal":2}]'

.create table demo ingestion csv mapping "typeC" '[{"Name":"name", "Ordinal":0}, {"Name":"uni", "Ordinal":1}, {"Name":"age", "Ordinal":3}, {"Name":"hometown", "Ordinal":2} ]'

//Ingest some test date
.ingest inline into table demo with (csvMappingReference="typeA", pushbypull=true) <| Hazriq,27,UNITEN

.ingest inline into table demo with (csvMappingReference="typeB", pushbypull=true) <| John,UNIx,31

.ingest inline into table demo with (csvMappingReference="typeC", pushbypull=true) <| Jane,UNIt,Kuala Lumpur,31 

//test
demo