schema_merge 插件

将表格架构定义合并到统一架构中。

架构定义应采用 getschema 运算符生成的格式。

schema merge 操作会联接输入架构中的列,并尝试将数据类型化简为常见的数据类型。 如果无法化简数据类型,则会在有问题的列上显示错误。

该插件通过 evaluate 运算符调用。

语法

T|evaluateschema_merge(PreserveOrder)

详细了解语法约定

参数

客户 类型​​ 必需 说明
PreserveOrder bool 设置为 true 时,指示插件按保留的第一个表格架构的定义验证列顺序。 如果同一列采用多个架构,则列序号必须与该列显示时采用的第一个架构的列序号相同。 默认值为 true

返回

schema_merge 插件返回的输出与 getschema 运算符返回的内容类似。

示例

与追加了新列的架构合并。

let schema1 = datatable(Uri:string, HttpStatus:int)[] | getschema;
let schema2 = datatable(Uri:string, HttpStatus:int, Referrer:string)[] | getschema;
union schema1, schema2 | evaluate schema_merge()

输出

ColumnName ColumnOrdinal 数据类型 ColumnType
Uri 0 System.String string
HttpStatus 1 System.Int32 int
Referrer 2 System.String string

与列排序不同的架构合并(在新变体中,HttpStatus 序号从 1 更改为 2)。

let schema1 = datatable(Uri:string, HttpStatus:int)[] | getschema;
let schema2 = datatable(Uri:string, Referrer:string, HttpStatus:int)[] | getschema;
union schema1, schema2 | evaluate schema_merge()

输出

ColumnName ColumnOrdinal 数据类型 ColumnType
Uri 0 System.String string
Referrer 1 System.String string
HttpStatus -1 错误(CSL 类型未知:错误(列乱序)) 错误(列乱序)

与列排序不同但 PreserveOrder 设置为 false 的架构合并。

let schema1 = datatable(Uri:string, HttpStatus:int)[] | getschema;
let schema2 = datatable(Uri:string, Referrer:string, HttpStatus:int)[] | getschema;
union schema1, schema2 | evaluate schema_merge(PreserveOrder = false)

输出

ColumnName ColumnOrdinal 数据类型 ColumnType
Uri 0 System.String string
Referrer 1 System.String string
HttpStatus 2 System.Int32 int