我正在尝试将varchar横向展平到数组中,以爆炸数组中的元素
例如[trJGrODW4n4iLRN2A4WeraV740vH4L81ikd7KnRfsD bE578vR4L81isq7YnRchM]
我尝试了以下操作:
替换varchar空间,"
(无效)。strtok_to_array
->获取字符串的unicode开头 Select s.value, replace(varchar_col,' ',',"') as to_array_format,
strtok_to_array(varchar_col,'')as strtok_to_array,* from table , lateral flatten(input => strtok_to_array(varchar_col,''))s
实际结果:
1. trJGrODW4n4iLRN2A4WeraV740vH4L81ikd7KnRfsD bE578vR4L81isq7YnRchM
2. [ "trJGrODW4n4iLRN2A4Wer\u0002aV740vH4L81ikd7KnRfsD\u0002bE578vR4L81isq7YnRchM" ]
预期结果:
1. ["trJGrODW4n4iLRN2A4Wer","aV740vH4L81ikd7KnRfsD","bE578vR4L81isq7YnRchM"]
2. ["trJGrODW4n4iLRN2A4Wer","aV740vH4L81ikd7KnRfsD","bE578vR4L81isq7YnRchM"]
答案 0 :(得分:1)
从您得到的输出中,您的数据看起来包含空字节。如果要将字符串以空字节为边界拆分为数组,可以使用
adventurer.Skills = adventurer.Skills
.Select(s => s.LinkedTo.ContainsKey(Roles.Fighter) ? s.LinkedTo[Roles.Fighter] : null)
.Where(s => s != null).ToList();
hex_decode_string以十六进制编码的字符串作为输入,传递'00'返回一个空字节,然后我们将其用作分隔符。