我正在加入 2 个表,它们都有数百个类似命名的列。我想更改每个表中的所有列名以包含表名。为了使查询简单,我不想显式地调用每个列名。下面的查询实现了这个目标。但是,以下查询在应用于大型数据集时非常慢。我假设性能缓慢是由于 replace_regex() 函数在整个数据集上运行。是否有另一种方法可以在提高更大数据集的性能的同时实现相同的结果?
let T1 = datatable (Key:string , Col2:string , Col3:string )
[
"1", "b", "c",
"2", "e", "f",
"3", "h", "i"
]
| project PackedRecord = todynamic(replace_regex(tostring(pack_all()), '"([a-zA-Z0-9_]*)":"', @'"T1_\1":"'))
| evaluate bag_unpack(PackedRecord);
let T2 = datatable (Key:string , Col2:string , Col3:string )
[
"1", "B", "C",
"2", "E", "F",
"4", "H", "I"
]
| project PackedRecord = todynamic(replace_regex(tostring(pack_all()), '"([a-zA-Z0-9_]*)":"', @'"T2_\1":"'))
| evaluate bag_unpack(PackedRecord);
let JoinTable = T1 | join kind=inner T2 on $left.T1_Key == $right.T2_Key;
JoinTable
上一个问题供参考