gpt4 book ai didi

azure - 如何爆炸而不丢失空值?

转载 作者:行者123 更新时间:2023-12-03 02:44:55 25 4
gpt4 key购买 nike

如何在 U-SQL 中分解数组而不丢失 Null 值?

在正常情况下交叉应用 | Explode(),空值丢失。

我从 here 中提取了以下脚本:

@content =
SELECT *
FROM(
VALUES
(
12,
"a, b, c,NULL"
),
( 75,
"f, g, h, i, j"
)) AS t([ID], LetterList);
@inArray =
SELECT [ID],
SqlArray.Create(LetterList.Split(',')) AS LetterArray
FROM @content;
@exploded =
SELECT [ID],
letter.Trim() AS Letter
FROM @inArray
CROSS APPLY
EXPLODE(LetterArray) AS r(letter);
OUTPUT @exploded
TO "/Outputs/explosion.tsv"
USING Outputters.Tsv();

我期望的输出是:


ID - 信件
------------
12 - 一个
12 - b
12-c
12 - 空
75 - f
75克
75 - 小时
75 - 我
75 - j

最佳答案

您可以使用OUTER APPLY :

When OUTER APPLY is specified, one row is produced for each row of the left rowset even when the right-side rowset expression returns an empty rowset for that row.

@exploded =
SELECT [ID],
letter.Trim() AS Letter
FROM @inArray
OUTER APPLY
EXPLODE(LetterArray) AS r(letter);

关于azure - 如何爆炸而不丢失空值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59294458/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com